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