Пример #1
0
        public MountainResource Convert(Mountain mountain)
        {
            var mountainResource = _mapper.Map <MountainResource>(mountain);

            mountainResource.Location = _locationConverter.Convert(mountain.Latitude, mountain.Longitude, mountain.Location.RegionName);
            mountainResource.Trails   = mountain.MountainTrail.Select(x => _mountainTrailResourceConverter.Convert(x));
            return(mountainResource);
        }
Пример #2
0
        public MountainBriefResource Convert(Mountain mountain)
        {
            var result = _mapper.Map <MountainBriefResource>(mountain);

            result.UpcomingTripsCount = mountain.TripDestinations.Count(x => x.Trip.DateFrom > DateTime.Now);
            result.Location           = _locationConverter.Convert(mountain.Latitude, mountain.Longitude, mountain.Location.RegionName);
            if (mountain.MountainTrail != null)
            {
                result.Trails = new MountainTrailBriefResource
                {
                    Href  = $"/api/mountains/{mountain.Id}/trails",
                    Count = mountain.MountainTrail.Count()
                };
            }

            return(result);
        }