67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
using CPRNIMS.Domain.Contracts.Inventory;
|
|
using CPRNIMS.Domain.Contracts.Reports;
|
|
using CPRNIMS.Infrastructure.Dto.Inventory.Reports;
|
|
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(DateTime dateFrom, DateTime dateTo, CancellationToken ct)
|
|
{
|
|
var currentUser = User.ToUserClaims();
|
|
if (currentUser == null)
|
|
return BadRequest();
|
|
|
|
var data = await _reports.GetRISReportAsync(dateFrom, dateTo, ct, currentUser.DepartmentId, currentUser.UserName);
|
|
return Ok(data);
|
|
}
|
|
|
|
[HttpGet("GetMRSReport")]
|
|
public async Task<IActionResult> GetMRSReport(DateTime dateFrom, DateTime dateTo, CancellationToken ct)
|
|
{
|
|
var currentUser = User.ToUserClaims();
|
|
if (currentUser == null)
|
|
return BadRequest();
|
|
|
|
var data = await _reports.GetMRSReportAsync(dateFrom, dateTo, ct, currentUser.DepartmentId, currentUser.UserName);
|
|
return Ok(data);
|
|
}
|
|
|
|
[HttpGet("GetInventoryReport")]
|
|
public async Task<IActionResult> GetInventoryReport(DateTime dateFrom, DateTime dateTo, CancellationToken ct)
|
|
{
|
|
var currentUser = User.ToUserClaims();
|
|
if (currentUser == null)
|
|
return BadRequest();
|
|
|
|
var data = await _reports.GetInventoryReportAsync(dateFrom, dateTo, ct, currentUser.DepartmentId, currentUser.UserName);
|
|
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);
|
|
}
|
|
}
|
|
}
|