using FastEndpoints; using FrameworkBLL.City; using FrameworkBLL.User; using FrameworkDAL.DTO.City; using FrameworkSL.Endpoints.User; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.City { public class SaveCity : BaseEndpoint> { private readonly ICityBLL _CityBLL; public SaveCity(ICityBLL CityBLL) { _CityBLL = CityBLL; } public override void Configure() { Post("/City/SaveCity"); AllowAnonymous(); } public record SaveCityParameters( [property: FromHeader] string Login, [property: FromBody] CityDTO CityDTO ); protected override async Task> ExecuteAsync(SaveCityParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CityBLL.SaveCity(req.CityDTO, 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); } } } }