using System.Security.Claims; using LctMonolith.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace LctMonolith.Controllers; /// /// Inventory endpoints for viewing owned store items and artifacts. /// [ApiController] [Route("api/inventory")] [Authorize] public class InventoryController : ControllerBase { private readonly IInventoryService _inventory; public InventoryController(IInventoryService inventory) { _inventory = inventory; } private Guid GetUserId() => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); /// List owned store inventory entries. [HttpGet("store-items")] public async Task GetStoreItems(CancellationToken ct) { var items = await _inventory.GetStoreInventoryAsync(GetUserId(), ct); return Ok(items.Select(i => new { i.StoreItemId, i.Quantity, i.AcquiredAt, i.IsReturned, i.StoreItem?.Name })); } /// List owned artifacts. [HttpGet("artifacts")] public async Task GetArtifacts(CancellationToken ct) { var artifacts = await _inventory.GetArtifactsAsync(GetUserId(), ct); return Ok(artifacts.Select(a => new { a.ArtifactId, a.ObtainedAt, a.Artifact?.Name, a.Artifact?.Rarity })); } }