96 lines
3.8 KiB
C#
96 lines
3.8 KiB
C#
using CPRNIMS.Domain.UIContracts.Inventory;
|
|
using CPRNIMS.Domain.UIContracts.Account;
|
|
using CPRNIMS.Infrastructure.Dto.Inventory;
|
|
using CPRNIMS.Infrastructure.Dto.Inventory.Request;
|
|
using CPRNIMS.Infrastructure.Helper;
|
|
using CPRNIMS.WebApps.Controllers.Base;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CPRNIMS.WebApps.Controllers.Inventory
|
|
{
|
|
public partial class MRSMgmtController : BaseMethod
|
|
{
|
|
private readonly IMRS _mrs;
|
|
public MRSMgmtController(ErrorLogHelper errorMessageService,IWebHostEnvironment webHostEnvironment,TokenHelper tokenHelper,
|
|
IMRS mrs, IAccount account) : base(errorMessageService, webHostEnvironment, tokenHelper, account) => _mrs = mrs;
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetMRS([FromQuery] string? searchMRSNo,string? searchRISNo,string? searchItemName,string?
|
|
searchReturnedBy,string? status,string? condition,int pageNumber = 1,int pageSize = 12,CancellationToken ct = default)
|
|
{
|
|
short? statusCode = status switch
|
|
{
|
|
"0" => 0,
|
|
"1" => 1,
|
|
"2" => 2,
|
|
_ => null
|
|
};
|
|
|
|
var result = await _mrs.GetMRSPaged(new MRSPagedRequest
|
|
{
|
|
SearchMRSNo = searchMRSNo,
|
|
SearchRISNo = searchRISNo,
|
|
SearchItemName = searchItemName,
|
|
SearchReturnedBy = searchReturnedBy,
|
|
Status = statusCode,
|
|
Condition = condition,
|
|
PageNumber = pageNumber,
|
|
PageSize = pageSize
|
|
}, ct);
|
|
|
|
return Json(new { data = result.Data, recordsTotal = result.RecordsTotal});
|
|
}
|
|
[HttpGet]
|
|
public async Task<IActionResult> SearchRIS([FromQuery] int? searchProjectCodeId, string? searchRISNo , CancellationToken ct = default)
|
|
{
|
|
var result = await _mrs.SearchRIS(new SearchRISProjectCodeRequest
|
|
{
|
|
SearchRISNo = searchRISNo,
|
|
SearchProjectCodeId = searchProjectCodeId,
|
|
}, ct);
|
|
|
|
return Json(new { data = result.data, success = result.success, message = result.message });
|
|
}
|
|
[HttpGet]
|
|
public async Task<IActionResult> SearchProjects([FromQuery] string? searchProjectCode, CancellationToken ct = default)
|
|
{
|
|
var result = await _mrs.SearchProjects(new SearchRISProjectCodeRequest
|
|
{ SearchProjectCode = searchProjectCode,}, ct);
|
|
|
|
return Json(new { data = result.data, success = result.success, message = result.message });
|
|
}
|
|
[HttpPost]
|
|
public async Task<IActionResult> CreateMRS([FromBody] CreateMRSRequest request,CancellationToken ct)
|
|
{
|
|
var result = await _mrs.CreateMRS(request, ct);
|
|
|
|
if (!result.success)
|
|
return BadRequest(new { success = false, message = result.message });
|
|
|
|
return Ok(new { success = true, message = result.message });
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> ApproveMRS([FromBody] ApproveMRSRequest request,CancellationToken ct)
|
|
{
|
|
var result = await _mrs.ApproveMRS(request, ct);
|
|
|
|
if (!result.success)
|
|
return BadRequest(new { success = false, message = result.message });
|
|
|
|
return Ok(new { success = true, message = result.message });
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> CancelMRS([FromBody] CancelMRSRequest request,CancellationToken ct)
|
|
{
|
|
var result = await _mrs.CancelMRS(request, ct);
|
|
|
|
if (!result.success)
|
|
return BadRequest(new { success = false, message = result.message });
|
|
|
|
return Ok(new { success = true, message = result.message });
|
|
}
|
|
}
|
|
}
|