Implement Warehouse Dashboard features
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Distribution.Features.Warehouse;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/warehouses")]
|
||||
public class WarehouseController(WarehouseService service) : ControllerBase
|
||||
public class WarehouseController(WarehouseService service, WarehouseDashboardService dashboardService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
@@ -17,6 +17,16 @@ public class WarehouseController(WarehouseService service) : ControllerBase
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/dashboard")]
|
||||
public async Task<IActionResult> Dashboard(
|
||||
Guid id, [FromQuery] DateTime? from, [FromQuery] DateTime? to, [FromQuery] int deadStockDays = 30)
|
||||
{
|
||||
var error = WarehouseDashboardService.Validate(from, to, deadStockDays);
|
||||
if (error is not null) return BadRequest(new { message = error });
|
||||
var result = await dashboardService.GetAsync(id, from, to, deadStockDays);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateWarehouseRequest request, CancellationToken ct)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user