public async Task <ActionResult <IEnumerable <FoodTruck> > > Get(double longitude, double latitude, int distance)
        {
            if (longitude > 180 || longitude < -180)
            {
                return(BadRequest("longitude invalid"));
            }
            if (latitude > 90 || latitude < -90)
            {
                return(BadRequest("latitude invalid"));
            }
            if (distance <= 0)
            {
                return(BadRequest("distance must be positive"));
            }

            CosmosResult <FoodTruck> result = new CosmosResult <FoodTruck>();

            try
            {
                result = await _repo.GetItemsAsync(t =>
                                                   t.Location.Distance(new Point(longitude, latitude)) < distance);

                _logger.LogInformation($"Get: ItemCount={result.Items.Count}, RequestChage={result.RequestCharge}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Get Failed");
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
            return(Ok(result.Items));
        }
Beispiel #2
0
        public async Task <IList <HfeaFormReadOnlyDto> > GetAll()
        {
            var hfeaForms = await _hfeaRepository
                            .GetItemsAsync <HfeaFormReadOnlyDto>("c.IsActive");

            var result = hfeaForms.OrderByDescending(m => m.Name)
                         .ToList()
                         .MapTo <List <HfeaFormReadOnlyDto> >();

            return(result);
        }