NonInventPurchasingSystem/CPRNIMS.WebApi/Controllers/Inventory/InventoryMgmtController.cs
2026-06-15 16:41:50 +08:00

112 lines
3.9 KiB
C#

using CPRNIMS.Domain.Contracts.Inventory;
using CPRNIMS.Domain.Services;
using CPRNIMS.Infrastructure.Dto.Inventory;
using CPRNIMS.Infrastructure.Dto.Inventory.Request;
using CPRNIMS.Infrastructure.Dto.PR;
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<IActionResult> 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<IActionResult> GetInventoryByUserId(InventoryDto itemCodeDto)
{
return Ok(await _inventory.GetInventoryByUserId(itemCodeDto));
}
[HttpPost("GetRequestedItemByUserId")]
public async Task<IActionResult> GetRequestedItemByUserId(InventoryDto itemCodeDto)
{
var allPR = await _inventory.GetRequestedItemByUserId(itemCodeDto);
return Ok(allPR);
}
[HttpPost("GetInventory")]
public async Task<IActionResult> GetInventory(InventoryRequest request, CancellationToken ct)
{
var result = await _inventory.GetInventory(request, ct);
return Ok(result);
}
[HttpPost("GetInventoryById")]
public async Task<IActionResult> GetInventoryById(InventoryRequest request, CancellationToken ct)
{
var result = await _inventory.GetInventoryById(request, ct);
return Ok(result);
}
[HttpPost("GetLotNo")]
public async Task<IActionResult> GetLotNo(InventoryDto itemCodeDto)
{
var allPR = await _inventory.GetLotNo(itemCodeDto);
return Ok(allPR);
}
[HttpPost("GetLotNoById")]
public async Task<IActionResult> GetLotNoById(InventoryDto itemCodeDto)
{
var allPR = await _inventory.GetLotNoById(itemCodeDto);
return Ok(allPR);
}
[HttpPost("GetLotQtyByItem")]
public async Task<IActionResult> GetLotQtyByItem(InventoryDto itemCodeDto)
{
var allPR = await _inventory.GetLotQtyByItem(itemCodeDto);
return Ok(allPR);
}
#endregion
#region Post Put
[HttpPost("PostPutReqItems")]
public async Task<IActionResult> PostPutReqItems(InventoryDto InventoryDto)
{
var pR = await _inventory.PostPutReqItems(InventoryDto);
return Ok(pR);
}
[HttpPost("PostPutReqApproval")]
public async Task<IActionResult> PostPutReqApproval(InventoryDto InventoryDto)
{
var pR = await _inventory.PostPutReqApproval(InventoryDto);
return Ok(pR);
}
[HttpPost("PostPutLotNo")]
public async Task<IActionResult> PostPutLotNo(InventoryDto InventoryDto)
{
var pR = await _inventory.PostPutLotNo(InventoryDto);
return Ok(pR);
}
[HttpPost("PostPutLotBin")]
public async Task<IActionResult> PostPutLotBin(InventoryDto InventoryDto)
{
var pR = await _inventory.PostPutLotBin(InventoryDto);
return Ok(pR);
}
#endregion
}
}