Пример #1
0
        private static void SeedCountries(HomeMyDayDbContext context)
        {
            //Generate a list of countries to be deduplicated later.
            var countries = new List <Country>();

            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            foreach (CultureInfo culture in cultures)
            {
                RegionInfo cultureRegion = new RegionInfo(culture.Name);
                countries.Add(new Country()
                {
                    CountryCode = cultureRegion.ThreeLetterISORegionName,
                    Name        = cultureRegion.EnglishName
                });
            }

            //Deduplicate list
            countries = countries.GroupBy(c => c.CountryCode)
                        .Select(i => i.First())
                        .ToList();

            context.Countries.AddRange(countries);

            context.SaveChanges();
        }
Пример #2
0
        private static void SeedSurprise(HomeMyDayDbContext context)
        {
            var generator = new LipsumGenerator();

            context.Page.Add(new Page()
            {
                Page_Name = "TheSurprise", Title = "Surprise", Content = generator.GenerateParagraphs(1)[0]
            });
            context.SaveChanges();
        }
        public static void Seed(HomeMyDayDbContext context)
        {
            if (context.Reviews.Any())
            {
                return;
            }

            context.Reviews.Add(new Review()
            {
                Accommodation = context.Accommodations.First(),
                Title         = "Review 1",
                Name          = "Pieter B.",
                Date          = new DateTime(2017, 9, 23),
                Text          = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis mi vestibulum, finibus leo nec, iaculis ante. Aenean maximus dui in dolor finibus iaculis. Ut nisl risus, ultricies sit amet pretium eu, iaculis vel diam. Ut quis sollicitudin lorem. Nullam fermentum iaculis elit et aliquet. Fusce elementum aliquet nunc ut lacinia. Donec aliquam consectetur vehicula. Curabitur porttitor justo neque, at consequat augue fringilla id. In viverra interdum massa eu sodales. Morbi bibendum feugiat quam, sit amet euismod velit posuere nec. Ut eu urna est. Morbi felis erat, congue a magna eget, facilisis ultrices justo."
            });

            context.Reviews.Add(new Review()
            {
                Accommodation = context.Accommodations.First(),
                Title         = "Review 2",
                Name          = "Ingrid Andriesse",
                Date          = new DateTime(2017, 9, 24),
                Text          = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis mi vestibulum, finibus leo nec, iaculis ante. Aenean maximus dui in dolor finibus iaculis. Ut nisl risus, ultricies sit amet pretium eu, iaculis vel diam. Ut quis sollicitudin lorem. Nullam fermentum iaculis elit et aliquet. Fusce elementum aliquet nunc ut lacinia. Donec aliquam consectetur vehicula. Curabitur porttitor justo neque, at consequat augue fringilla id. In viverra interdum massa eu sodales. Morbi bibendum feugiat quam, sit amet euismod velit posuere nec. Ut eu urna est. Morbi felis erat, congue a magna eget, facilisis ultrices justo."
            });

            context.Reviews.Add(new Review()
            {
                Accommodation = context.Accommodations.First(),
                Title         = "Review 3",
                Name          = "Lennart achternaam",
                Date          = new DateTime(2017, 9, 25),
                Text          = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis mi vestibulum, finibus leo nec, iaculis ante. Aenean maximus dui in dolor finibus iaculis. Ut nisl risus, ultricies sit amet pretium eu, iaculis vel diam. Ut quis sollicitudin lorem. Nullam fermentum iaculis elit et aliquet. Fusce elementum aliquet nunc ut lacinia. Donec aliquam consectetur vehicula. Curabitur porttitor justo neque, at consequat augue fringilla id. In viverra interdum massa eu sodales. Morbi bibendum feugiat quam, sit amet euismod velit posuere nec. Ut eu urna est. Morbi felis erat, congue a magna eget, facilisis ultrices justo."
            });

            context.Reviews.Add(new Review()
            {
                Accommodation = context.Accommodations.First(),
                Title         = "Review 4",
                Name          = "Pieter paulus",
                Date          = new DateTime(2017, 9, 26),
                Text          = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis mi vestibulum, finibus leo nec, iaculis ante. Aenean maximus dui in dolor finibus iaculis. Ut nisl risus, ultricies sit amet pretium eu, iaculis vel diam. Ut quis sollicitudin lorem. Nullam fermentum iaculis elit et aliquet. Fusce elementum aliquet nunc ut lacinia. Donec aliquam consectetur vehicula. Curabitur porttitor justo neque, at consequat augue fringilla id. In viverra interdum massa eu sodales. Morbi bibendum feugiat quam, sit amet euismod velit posuere nec. Ut eu urna est. Morbi felis erat, congue a magna eget, facilisis ultrices justo."
            });

            context.Reviews.Add(new Review()
            {
                Accommodation = context.Accommodations.First(),
                Title         = "Review 5",
                Name          = "Marco Havermans",
                Date          = new DateTime(2017, 9, 27),
                Text          = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis mi vestibulum, finibus leo nec, iaculis ante. Aenean maximus dui in dolor finibus iaculis. Ut nisl risus, ultricies sit amet pretium eu, iaculis vel diam. Ut quis sollicitudin lorem. Nullam fermentum iaculis elit et aliquet. Fusce elementum aliquet nunc ut lacinia. Donec aliquam consectetur vehicula. Curabitur porttitor justo neque, at consequat augue fringilla id. In viverra interdum massa eu sodales. Morbi bibendum feugiat quam, sit amet euismod velit posuere nec. Ut eu urna est. Morbi felis erat, congue a magna eget, facilisis ultrices justo."
            });

            context.SaveChanges();
        }
Пример #4
0
 private static void SeedFaqCategory(HomeMyDayDbContext context)
 {
     context.FaqCategory.AddRange(new FaqCategory()
     {
         CategoryName = "Cat1"
     }, new FaqCategory()
     {
         CategoryName = "Cat2"
     }, new FaqCategory()
     {
         CategoryName = "Cat3"
     });
     context.SaveChanges();
 }
Пример #5
0
        private static void SeedAccommodations(HomeMyDayDbContext context)
        {
            var generator = new LipsumGenerator();

            context.Accommodations.Add(new Accommodation()
            {
                Price            = 310,
                Recommended      = true,
                Name             = "Casa del Sol",
                Description      = String.Join(Environment.NewLine, generator.GenerateParagraphs(2)),
                Continent        = "Europe",
                Country          = "Spain",
                Location         = "Barcelona",
                Latitude         = 51.5891178m,
                Longitude        = 4.7730457m,
                Beds             = 2,
                MaxPersons       = 2,
                Rooms            = 4,
                CancellationText = generator.GenerateParagraphs(1)[0],
                RulesText        = generator.GenerateParagraphs(1)[0],
                PricesText       = generator.GenerateParagraphs(1)[0],
                SpaceText        = generator.GenerateParagraphs(1)[0],
                ServicesText     = generator.GenerateParagraphs(1)[0],
                MediaObjects     = new List <MediaObject>()
                {
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-1.jpg",
                        Type        = MediaType.Image,
                        Title       = "Indoor living room",
                        Description = "Example description",
                        Primary     = true
                    },
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-2.jpg",
                        Type        = MediaType.Image,
                        Title       = "Outdoor house",
                        Description = "Example description",
                    }
                }
            });

            context.Accommodations.Add(new Accommodation()
            {
                Price            = 340,
                Recommended      = true,
                Name             = "Greece House",
                Description      = String.Join(Environment.NewLine, generator.GenerateParagraphs(2)),
                Continent        = "Europe",
                Country          = "Greece",
                Location         = "Athens",
                Latitude         = 51.5891178m,
                Longitude        = 4.7730457m,
                Beds             = 1,
                MaxPersons       = 2,
                Rooms            = 3,
                CancellationText = generator.GenerateParagraphs(1)[0],
                RulesText        = generator.GenerateParagraphs(1)[0],
                PricesText       = generator.GenerateParagraphs(1)[0],
                SpaceText        = generator.GenerateParagraphs(1)[0],
                ServicesText     = generator.GenerateParagraphs(1)[0],
                MediaObjects     = new List <MediaObject>()
                {
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-3.jpg",
                        Type        = MediaType.Image,
                        Title       = "Sea sight",
                        Description = "Example description",
                        Primary     = true
                    },
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-4.jpg",
                        Type        = MediaType.Image,
                        Title       = "Terras view",
                        Description = "Example description"
                    }
                }
            });

            context.Accommodations.Add(new Accommodation()
            {
                Price            = 320,
                Recommended      = false,
                Name             = "Germany House",
                Description      = String.Join(Environment.NewLine, generator.GenerateParagraphs(2)),
                Continent        = "Europe",
                Country          = "Germany",
                Location         = "Frankfurt",
                Latitude         = 51.5891178m,
                Longitude        = 4.7730457m,
                Beds             = 4,
                MaxPersons       = 6,
                Rooms            = 7,
                CancellationText = generator.GenerateParagraphs(1)[0],
                RulesText        = generator.GenerateParagraphs(1)[0],
                PricesText       = generator.GenerateParagraphs(1)[0],
                SpaceText        = generator.GenerateParagraphs(1)[0],
                ServicesText     = generator.GenerateParagraphs(1)[0],
                MediaObjects     = new List <MediaObject>()
                {
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-1.jpg",
                        Type        = MediaType.Image,
                        Title       = "Indoor living room",
                        Description = "Example description",
                        Primary     = true
                    },
                    new MediaObject()
                    {
                        Url         = "/images/holiday/image-2.jpg",
                        Type        = MediaType.Image,
                        Title       = "Outdoor house",
                        Description = "Example description"
                    }
                }
            });

            context.SaveChanges();
        }