Esempio n. 1
0
        public async Task <object> Post([FromBody] MapViewPort viewPort)
        {
            try
            {
                IEnumerable <SpotModel> results = await _spotService.LoadSpotCollectionByViewPort(viewPort, 50);

                return(Mapper.Map <IEnumerable <SpotContract> >(results));
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, exception.StackTrace);

                return(StatusCode(StatusCodes.Status500InternalServerError, exception.Message));
            }
        }
Esempio n. 2
0
        public async Task <IEnumerable <SpotModel> > LoadSpotCollectionByViewPort(MapViewPort mapViewPort, int maxNumberOfSpots = 10)
        {
            var spotModels = await DbContext
                             .Spots
                             .Where(sp => !sp.Disabled &&
                                    mapViewPort.Contains(new Coordinate(sp.Latitude.Value, sp.Longitude.Value)))
                             .Select(sp => new SpotModel
            {
                Id          = sp.Id,
                AreaId      = sp.AreaId,
                PictureUrls = sp.PictureUrls,
                Vote        = sp.Vote,
                Height      = sp.Height,
                Latitude    = sp.Latitude,
                Longitude   = sp.Longitude,
                Name        = sp.Name,
                Type        = sp.Type
            })
                             .Take(maxNumberOfSpots)
                             .ToListAsync();

            return(spotModels);
        }