using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.EmiChangeRequest; using PayRollDAL.DTO.EmiChangeRequest; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.EmiChangeRequest { public class SaveEmiChangeRequest : BaseEndpoint> { private readonly IEmiChangeRequestBLL _EmiChangeRequestBLL; public SaveEmiChangeRequest(IEmiChangeRequestBLL _IEmiChangeRequestBLL) { _EmiChangeRequestBLL = _IEmiChangeRequestBLL; } public override void Configure() { Post("/EmiChangeRequest/SaveEmiChangeRequest"); AllowAnonymous(); } public record SaveEmiChangeRequestParameters( [property: FromHeader] string Login, [property: FromBody] EmiChangeRequestDTO EmiChangeRequestDTO ); protected override async Task> ExecuteAsync(SaveEmiChangeRequestParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EmiChangeRequestBLL.SaveEmiChangeRequest(req.EmiChangeRequestDTO, 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); } } } }