Ejemplo n.º 1
0
        /// <summary>
        /// Ensure data filling
        /// </summary>
        /// <returns></returns>
        public async Task EnsureSeedDataAsync()
        {
            if (await _userManager.FindByEmailAsync("*****@*****.**") == null)
            {
                //Add the user.
                var newUser = new PawelbyUser()
                {
                    UserName = "******",
                    Email = "*****@*****.**"
                };

                await _userManager.CreateAsync(newUser, "Possword6!");
            }

            if (!_context.Trips.Any())
            {
                //Add new Data
                var euTrip = new Trip()
                {
                    Name = "EU Trip",
                    Created = DateTime.UtcNow,
                    UserName = "******",
                    Stops = new List<Stop>()
                    {
						new Stop() { Name = "Vilnius", Arrival = new DateTime(2013, 5, 8), Latitude = 54.68938650, Longitude = 25.28002430, Order = 0 },
						new Stop() { Name = "Eindhoven", Arrival = new DateTime(2013, 5, 9), Latitude = 51.441642, Longitude = 5.4697225, Order = 1},
						new Stop() { Name = "Amsterdam", Arrival = new DateTime(2013, 5, 9), Latitude = 52.3702157, Longitude = 4.8951679, Order = 2},
                        new Stop() { Name = "Eindhoven", Arrival = new DateTime(2013, 5, 13), Latitude = 51.441642, Longitude = 5.4697225, Order = 3},
						new Stop() { Name = "Warsaw", Arrival = new DateTime(2013, 5, 13), Latitude = 52.2296756, Longitude = 21.0122287, Order = 4}
                    }
                };

                _context.Trips.Add(euTrip);
				_context.Stops.AddRange(euTrip.Stops);

                var indianTrip = new Trip()
                {
                    Name = "Indian Trip",
                    Created = DateTime.UtcNow,
                    UserName = "******",
                    Stops = new List<Stop>()
                    {
						new Stop() { Name = "Kiev", Arrival = new DateTime(2014, 2, 13), Latitude = 50.4501, Longitude = 30.5234, Order = 0 },
                        new Stop() { Name = "Dubai", Arrival = new DateTime(2014, 2, 14), Latitude = 25.271139, Longitude = 55.307485, Order = 1 },
                        new Stop() { Name = "Delhi", Arrival = new DateTime(2014, 2, 14), Latitude = 28.635308, Longitude = 77.22496, Order = 2 },
                        new Stop() { Name = "Panaji, Goa", Arrival = new DateTime(2014, 2, 16), Latitude = 15.495602, Longitude = 73.825209, Order = 3 },
                        new Stop() { Name = "Delhi", Arrival = new DateTime(2014, 2, 26), Latitude = 28.635308, Longitude = 77.22496, Order = 4 },
                        new Stop() { Name = "Dubai", Arrival = new DateTime(2014, 2, 28), Latitude = 25.271139, Longitude = 55.307485, Order = 5 },
                        new Stop() { Name = "Kiev", Arrival = new DateTime(2014, 3, 1), Latitude = 50.4501, Longitude = 30.5234, Order = 6 },
                    }
                };

                _context.Trips.Add(indianTrip);
				_context.Stops.AddRange(indianTrip.Stops);

                _context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Add a new trip
 /// </summary>
 /// <param name="newTrip">New trip</param>
 public void AddTrip(Trip newTrip)
 {
     _context.Add(newTrip);
 }