using Azure.Core; using CPRNIMS.Domain.Contracts.Inventory; using CPRNIMS.Domain.Contracts.Reports; using CPRNIMS.Infrastructure.Dto.Inventory.Reports; using CPRNIMS.Infrastructure.Dto.Inventory.Request; using CPRNIMS.WebApi.Security; using Microsoft.AspNetCore.Mvc; namespace CPRNIMS.WebApi.Controllers.Inventory { [Route("api/[controller]")] [ApiController] public class InventoryReportsController : ControllerBase { private readonly IReportDataService _data; private readonly IInventoryReports _reports; public InventoryReportsController(IReportDataService data, IInventoryReports reports) { _data = data; _reports = reports; } [HttpGet("GetRISReport")] public async Task GetRISReport([FromQuery] InventoryReportsRequest request, CancellationToken ct) { var currentUser = User.ToUserClaims(); if (currentUser == null) return BadRequest(); var data = await _reports.GetRISReportAsync(request, currentUser.UserName,currentUser.DepartmentId, ct); return Ok(data); } [HttpGet("GetMRSReport")] public async Task GetMRSReport([FromQuery] InventoryReportsRequest request, CancellationToken ct) { var currentUser = User.ToUserClaims(); if (currentUser == null) return BadRequest(); var data = await _reports.GetMRSReportAsync(request, currentUser.UserName, currentUser.DepartmentId, ct); return Ok(data); } [HttpGet("GetInventoryReport")] public async Task GetInventoryReport([FromQuery] InventoryReportsRequest request, CancellationToken ct) { var currentUser = User.ToUserClaims(); if (currentUser == null) return BadRequest(); var data = await _reports.GetInventoryReportAsync(request, currentUser.UserName, currentUser.DepartmentId, ct); return Ok(data); } [HttpGet("GetRISData")] public IActionResult GetData([FromQuery] DateTime dateFrom, [FromQuery] DateTime dateTo,CancellationToken ct) { var result = new RISReportDataDto { Rows = _data.GetMain(dateFrom, dateTo), Disciplines = _data.GetDisciplines(dateFrom, dateTo), Recipients = _data.GetRecipients(dateFrom, dateTo) }; return Ok(result); } } }