using FastEndpoints; using FrameworkBLL.UOM; using FrameworkDAL.DTO.UOM; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.UOM { public class SaveUOM : BaseEndpoint> { private readonly IUOMBLL _UOMBLL; public SaveUOM(IUOMBLL UOMBLL) { _UOMBLL = UOMBLL; } public override void Configure() { Post("/UOM/SaveUOM"); AllowAnonymous(); } public record SaveUOMParameters( [property: FromHeader] string Login, [property: FromBody] UOMDTO UOMDTO ); protected override async Task> ExecuteAsync(SaveUOMParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _UOMBLL.SaveUOM(req.UOMDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }