using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.ItemStock; using MMDAL.DTO.ItemStock; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.ItemStock { public class SaveItemStock : BaseEndpoint> { private readonly IItemStockBLL _ItemStockBLL; public SaveItemStock(IItemStockBLL _IItemStockBLL) { _ItemStockBLL = _IItemStockBLL; } public override void Configure() { Post("/ItemStock/SaveItemStock"); AllowAnonymous(); } public record SaveItemStockParameters( [property: FromHeader] string Login, [property: FromBody] ItemStockDTO ItemStockDTO ); protected override async Task> ExecuteAsync( SaveItemStockParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ItemStockBLL.SaveItemStock(req.ItemStockDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }