using Microsoft.AspNetCore.Mvc; using WmsLite.Api.Common; using WmsLite.Api.Dtos.Inventory; using WmsLite.Api.Infrastructure.Auth; using WmsLite.Api.Services.Interfaces; namespace WmsLite.Api.Controllers; [ApiController] [Route("api/[controller]")] public class InventoryController : WmsLiteControllerBase { private readonly IInventoryService _inventoryService; public InventoryController(IInventoryService inventoryService, ICurrentUserContext currentUser) : base(currentUser) { _inventoryService = inventoryService; } [HttpPost("move")] public async Task> Move([FromBody] InventoryMoveRequest request) { var result = await _inventoryService.MoveAsync(request); return result is null ? NotFound(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result)); } [HttpPost("paged-list")] public async Task> GetPagedList([FromBody] InventoryPagedQuery request) { var result = await _inventoryService.GetPagedListAsync(request); return Ok(BusinessResult.Ok(result)); } [HttpPost("create")] public async Task> Create([FromBody] InventorySaveRequest request) { var result = await _inventoryService.CreateAsync(request); return Ok(BusinessResult.Ok(result)); } [HttpPut("update")] public async Task> Update([FromBody] InventoryUpdateRequest request) { var result = await _inventoryService.UpdateAsync(request); return result is null ? NotFound(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result)); } [HttpDelete("{id:long}")] public async Task> Delete(long id) { var affectedRows = await _inventoryService.DeleteAsync(id, TenantId, OwnerCode); return Ok(BusinessResult.Ok(new { AffectedRows = affectedRows })); } }