public RouteRespDto MapToDto(TourEntity tourEntity, bool includeGeoJson = true)
        {
            var dto = new RouteRespDto
            {
                Id        = tourEntity.Id,
                Waypoints = tourEntity.Stops.OrderBy(s => s.WayPointIndex).Select(s => MapToDto(s)).ToList(),
                GeoJson   = includeGeoJson ? new FeatureCollectionDto
                {
                    features = new List <FeatureDto>
                    {
                        new FeatureDto {
                            geometry = new LineString
                            {
                                coordinates = tourEntity.Stops
                                              .OrderBy(s => s.WayPointIndex)
                                              .Select(s => new List <double> {
                                    s.Longitude, s.Latitude
                                })
                                              .ToList()
                            }
                        }
                    }
                } : null
            };

            return(dto);
        }
Example #2
0
        public bool AddTour(TourDto tour)
        {
            TourEntity tourEntity = BaseMapper <TourDto, TourEntity> .Map(tour);

            this.unitOfWork.TourRepository.Add(tourEntity);
            this.unitOfWork.Commit();

            return(true);
        }
 public Tour MapToClass(TourEntity tourEntity)
 {
     return(new Tour(tourEntity.Stops.Skip(1).Select(s => new Stop(s.Latitude, s.Longitude)).ToList())
     {
         Id = tourEntity.Id,
         TourStops = tourEntity.Stops
                     .OrderBy(s => s.WayPointIndex)
                     .Select(s => MapToClass(s)).ToList()
     });
 }
Example #4
0
        public async Task <int> AddTourAsync(TourDto tour)
        {
            TourEntity tourEntity = BaseMapper <TourDto, TourEntity> .Map(tour);

            await this.unitOfWork.TourRepository.AddAsync(tourEntity);

            await this.unitOfWork.CommitAsync();

            return(tourEntity.TourId);
        }
        public TourEntity MapToEntity(Tour tour)
        {
            var entity = new TourEntity
            {
                Id    = tour.Id,
                Stops = new List <StopEntity>()
            };

            for (int i = 0; i < tour.TourStops.Count; i++)
            {
                Stop stop       = tour.TourStops[i];
                var  stopEntity = new StopEntity
                {
                    Latitude      = stop.Latitude,
                    Longitude     = stop.Longitude,
                    Tour          = entity,
                    WayPointIndex = i
                };
                entity.Stops.Add(stopEntity);
            }
            return(entity);
        }
 public async Task UpdateAsync(TourEntity item)
 {
     exploreDb.Tours.Update(item);
 }
 public void Update(TourEntity item)
 {
     exploreDb.Tours.Update(item);
 }
 public async Task AddAsync(TourEntity item)
 {
     await exploreDb.Tours.AddAsync(item);
 }
 public void Add(TourEntity item)
 {
     exploreDb.Tours.Add(item);
 }
Example #10
0
 public async Task SaveTour(TourEntity entity)
 {
     _dbContext.Tours.Add(entity);
     await _dbContext.SaveChangesAsync();
 }