using AccountsBLL.CostCenterPattern; using AccountsDAL.DTO.CostCenterPattern; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.CostCenterPattern { public class SaveCostCenterPattern : BaseEndpoint> { private readonly ICostCenterPatternBLL _CostCenterPatternBLL; public SaveCostCenterPattern(ICostCenterPatternBLL costCenterPatternBLL) { _CostCenterPatternBLL = costCenterPatternBLL; } public override void Configure() { Post("/CostCenterPattern/SaveCostCenterPattern"); AllowAnonymous(); } public record SaveCostCenterPatternParameters( [property: FromHeader] string Login, [property: FromBody] CostCenterPatternDTO CostCenterPatternDTO ); protected override async Task> ExecuteAsync(SaveCostCenterPatternParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CostCenterPatternBLL.SaveCostCenterPattern(req.CostCenterPatternDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }