using System.Threading.Tasks; using GameAuthApi.Models; using GameAuthApi.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GameAuthApi.Controllers; [ApiController] [Route("api/[controller]")] public class ItemController : ControllerBase { private readonly ItemService _itemService; private readonly LocationService _locationService; public ItemController(ItemService itemService, LocationService locationService) { _itemService = itemService; _locationService = locationService; } [HttpPost] [Authorize(Roles = "SUPER")] public async Task Create([FromBody] CreateItemRequest req) { var location = await _locationService.GetByIdAsync(req.LocationId); if (location == null) return BadRequest("Invalid location ID."); var item = new Item { Name = req.Name, LocationId = req.LocationId }; await _itemService.CreateAsync(item); return Ok(item); } }