using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Cors; using Microsoft.EntityFrameworkCore; using RadicadeServer.DB; using RadicadeServer.RecNet.Store; using RadicadeServer.Utils; namespace RadicadeServer.Admin; [Route("admin/store")] [EnableCors("AdminPanel")] public class AdminStorefrontsAPI(RecDBContext db) : Controller { private Task RejectInvalidKey(string key) { return Task.FromResult(key.IsAdminKey() ? null : Unauthorized("Invalid secret")); } [HttpGet("{key}/itemset/{itemSetId}")] public async Task GetItemSet(string key, long itemSetId) { var rejection = await RejectInvalidKey(key); if (rejection != null) return rejection; return Ok("Item sets not implemented for GiftDropDB."); } [HttpGet("{key}/gift/{giftId}")] public async Task GetGift(string key, long giftId) { var rejection = await RejectInvalidKey(key); if (rejection != null) return rejection; var gift = await db.GiftItems.FirstOrDefaultAsync(x => x.GiftDropId == giftId); if (gift == null) return Ok("Not found."); return Ok(gift); } [HttpGet("{key}/gift/{giftId}/set")] public async Task SetGift() { return Ok("todo."); } [HttpGet("{key}/gift/new")] public async Task CreateGift() { return Ok("todo."); } }