using Microsoft.AspNetCore.Mvc; using WmsLite.Api.Common; using WmsLite.Api.Dtos.Zone; using WmsLite.Api.Infrastructure.Auth; using WmsLite.Api.Services.Interfaces; namespace WmsLite.Api.Controllers; [ApiController] [Route("api/[controller]")] public class ZoneController : WmsLiteControllerBase { private readonly IZoneService _zoneService; public ZoneController(IZoneService zoneService, ICurrentUserContext currentUser) : base(currentUser) { _zoneService = zoneService; } [HttpPost("paged-list")] public async Task> GetPagedList([FromBody] ZonePagedQuery request) { var result = await _zoneService.GetPagedListAsync(request); return Ok(BusinessResult.Ok(result)); } [HttpGet("{id:long}")] public async Task> GetById(long id) { var result = await _zoneService.GetByIdAsync(id, TenantId, OwnerCode); return result is null ? NotFound(BusinessResult.NotFound("Resource not found.")) : Ok(BusinessResult.Ok(result)); } [HttpPost("create")] public async Task> Create([FromBody] ZoneSaveRequest request) { var result = await _zoneService.CreateAsync(request); return Ok(BusinessResult.Ok(result)); } [HttpPut("update")] public async Task> Update([FromBody] ZoneUpdateRequest request) { var result = await _zoneService.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 _zoneService.DeleteAsync(id, TenantId, OwnerCode); return Ok(BusinessResult.Ok(new { AffectedRows = affectedRows })); } }