using Microsoft.AspNetCore.Mvc; namespace Distribution.Features.DashboardReport; [ApiController] [Route("api/reports/dashboard")] public class DashboardReportController(DashboardReportService service) : ControllerBase { [HttpGet("sales")] public async Task Sales( [FromQuery] DateTime? from, [FromQuery] DateTime? to, [FromQuery] Guid? regionId, [FromQuery] Guid? categoryId) { var f = DashboardReportService.BuildFilter(from, to, regionId, categoryId, null); var error = DashboardReportService.Validate(f); return error is null ? Ok(await service.GetSalesSummaryAsync(f)) : BadRequest(new { message = error }); } [HttpGet("inventory")] public async Task Inventory( [FromQuery] DateTime? from, [FromQuery] DateTime? to, [FromQuery] Guid? warehouseId, [FromQuery] Guid? categoryId) { var f = DashboardReportService.BuildFilter(from, to, null, categoryId, warehouseId); var error = DashboardReportService.Validate(f); return error is null ? Ok(await service.GetInventorySummaryAsync(f)) : BadRequest(new { message = error }); } }