using CPRNIMS.Domain.Contracts.Inventory; using CPRNIMS.Domain.Services; using CPRNIMS.Infrastructure.Dto.Inventory; using CPRNIMS.Infrastructure.Dto.Inventory.Request; using CPRNIMS.WebApi.Controllers.Base; using Microsoft.AspNetCore.Mvc; namespace CPRNIMS.WebApi.Controllers.Inventory { [Security.AuthorizeRoles("InventoryMgmt")] public class InventoryMgmtController : BaseController { private readonly IInventory _inventory; public InventoryMgmtController(ErrorMessageService errorMessageService, IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IInventory inventory) : base(errorMessageService, webHostEnvironment,configuration) => _inventory = inventory; #region Get [HttpGet("GetTransactContext")] public async Task GetTransactContext([FromQuery] int inventoryId, CancellationToken ct) { var ctx = await _inventory.GetTransactContextAsync(inventoryId, ct); if (ctx == null) return NotFound(new { success = false, message = "Inventory record not found." }); return Ok(ctx); } [HttpPost("GetInventoryByUserId")] public async Task GetInventoryByUserId(InventoryDto itemCodeDto) { return Ok(await _inventory.GetInventoryByUserId(itemCodeDto)); } [HttpPost("GetRequestedItemByUserId")] public async Task GetRequestedItemByUserId(InventoryDto itemCodeDto) { var allPR = await _inventory.GetRequestedItemByUserId(itemCodeDto); return Ok(allPR); } [HttpPost("GetInventory")] public async Task GetInventory(InventoryRequest request, CancellationToken ct) { var result = await _inventory.GetInventory(request, ct); return Ok(result); } [HttpPost("GetInventoryById")] public async Task GetInventoryById(InventoryRequest request, CancellationToken ct) { var result = await _inventory.GetInventoryById(request, ct); return Ok(result); } [HttpPost("GetLotNo")] public async Task GetLotNo(InventoryDto itemCodeDto) { var allPR = await _inventory.GetLotNo(itemCodeDto); return Ok(allPR); } [HttpPost("GetLotNoById")] public async Task GetLotNoById(InventoryDto itemCodeDto) { var allPR = await _inventory.GetLotNoById(itemCodeDto); return Ok(allPR); } [HttpPost("GetLotQtyByItem")] public async Task GetLotQtyByItem(InventoryDto itemCodeDto) { var allPR = await _inventory.GetLotQtyByItem(itemCodeDto); return Ok(allPR); } #endregion #region Post Put [HttpPost("PostPutReqItems")] public async Task PostPutReqItems(InventoryDto InventoryDto) { var pR = await _inventory.PostPutReqItems(InventoryDto); return Ok(pR); } [HttpPost("PostPutReqApproval")] public async Task PostPutReqApproval(InventoryDto InventoryDto) { var pR = await _inventory.PostPutReqApproval(InventoryDto); return Ok(pR); } [HttpPost("PostPutLotNo")] public async Task PostPutLotNo(InventoryDto InventoryDto) { var pR = await _inventory.PostPutLotNo(InventoryDto); return Ok(pR); } [HttpPost("PostPutLotBin")] public async Task PostPutLotBin(InventoryDto InventoryDto) { var pR = await _inventory.PostPutLotBin(InventoryDto); return Ok(pR); } #endregion } }