Пример #1
0
        public async Task <ActionResult <IEnumerable <MountainBriefResource> > > GetMountainsWithUpcomingTripsByRadius([FromQuery]
                                                                                                                       double latitude,
                                                                                                                       [FromQuery] double longitude,
                                                                                                                       [FromQuery] int radiusKilometers)
        {
            try
            {
                var mountains = await _mediator.Send(new GetMountainsNearbyLocationQuery(latitude, longitude, radiusKilometers));

                return(Ok(mountains.Select(x => _mountainBriefResourceConverter.Convert(x))));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #2
0
        public TripDestinationResource Convert(TripDestination tripDestination)
        {
            var result = _mapper.Map <TripDestinationResource>(tripDestination);

            if (result.Type == TripDestinationType.Mountain)
            {
                result.Mountain = _mountainBriefResourceConverter.Convert(tripDestination.Mountain);
            }
            else if (result.Type == TripDestinationType.Rock)
            {
                result.Rock = _rockBriefResourceConverter.Convert(tripDestination.Rock);
            }
            return(result);
        }