using AdminBLL.BIZTransactionType; using AdminDAL.DTO.BIZTransactionType; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.BIZTransactionType { // GB4 route: BizTransactionType.svc/ (POST, BodyStyle.Bare) — Save(BIZTransactionTypeDTO). public class SaveBIZTransactionType : BaseEndpoint> { private readonly IBIZTransactionTypeBLL _BIZTransactionTypeBLL; public SaveBIZTransactionType(IBIZTransactionTypeBLL IBIZTransactionTypeBLL) { _BIZTransactionTypeBLL = IBIZTransactionTypeBLL; } public override void Configure() { Post("/BIZTransactionType/SaveBIZTransactionType"); AllowAnonymous(); } public record SaveBIZTransactionTypeParameters( [property: FromHeader] string Login, [property: FromBody] BIZTransactionTypeDTO BIZTransactionTypeDTO ); protected override string? GetCacheKey(SaveBIZTransactionTypeParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveBIZTransactionTypeParameters req, LoginDTO loginDTO, CancellationToken ct) { try { bool isNew = req.BIZTransactionTypeDTO.BIZTransactionTypeId == 0; var id = await _BIZTransactionTypeBLL.SaveBIZTransactionType(req.BIZTransactionTypeDTO, loginDTO, null, ct); string message = isNew ? $"Details saved successfully with Id: {id}" : $"Details updated successfully with Id: {id}"; return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(message, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }