using AdminBLL.LocationTrack; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.LocationTrack { public class GetLocationBasedonGeo : BaseEndpoint> { private readonly ILocationTrackBLL _LocationTrackBLL; public GetLocationBasedonGeo(ILocationTrackBLL locationTrackBLL) { _LocationTrackBLL = locationTrackBLL; } public override void Configure() { Get("/Location/BasedOn/Geo"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] string GeoCode, [property: QueryParam] decimal Distance, [property: QueryParam] int NumberOfRecord ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO loginDTO, CancellationToken ct) { try { var data = await _LocationTrackBLL.GetLocationBasedonGeo( req.GeoCode, req.Distance, req.NumberOfRecord, loginDTO, ct); var response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( data, CacheKeyLevel.NOT_REQUIRED, loginDTO); response.Total = 0; return response; } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }