using FastEndpoints; using FrameworkBLL.Country; using FrameworkDAL.DTO.Country; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.Country { public class SaveCountry : BaseEndpoint> { private readonly ICountryBLL _CountryBLL; public SaveCountry(ICountryBLL CountryBLL) { _CountryBLL = CountryBLL; } public override void Configure() { Post("/Country/SaveCountry"); AllowAnonymous(); } public record SaveCountryParameters( [property: FromHeader] string Login, [property: FromBody] CountryDTO CountryDTO ); protected override async Task> ExecuteAsync(SaveCountryParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CountryBLL.SaveCountry(req.CountryDTO, 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); } } } }