NonInventPurchasingSystem/CPRNIMS.WebApi/Controllers/Inventory/InventoryReportsController.cs

69 lines
2.5 KiB
C#

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<IActionResult> 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<IActionResult> 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<IActionResult> 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);
}
}
}