using AccountsBLL.Account; using AccountsDAL.DTO.Account; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Account { public class SaveAccount : BaseEndpoint> { private readonly IAccountBLL _AccountBLL; public SaveAccount(IAccountBLL accountBLL) => _AccountBLL = accountBLL; public override void Configure() { Post("/Account/SaveAccount"); AllowAnonymous(); } public record SaveAccountParameters( [property: FromHeader] string Login, [property: FromBody] AccountDTO AccountDTO ); //protected override string? GetCacheKey(SaveAccountParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveAccountParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountBLL.SaveAccount(req.AccountDTO, LoginDTO!); 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); } } } }