Ejemplo n.º 1
0
        public async Task SeedAsync(DanubeJourneyDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Trips.Any())
            {
                return;
            }

            var trips = new Dictionary <string, string>
            {
                ["TheBlackSea"]   = "https://images.globusfamily.com/Maps/AVALON/2020/WOBB.jpg",
                ["VienneseWaltz"] = "https://images.globusfamily.com/Maps/AVALON/2020/WOBB.jpg",
                ["Symphony"]      = "https://images.globusfamily.com/Maps/AVALON/2020/WOBB.jpg",
                ["Serenade"]      = "https://images.globusfamily.com/Maps/AVALON/2020/WOBB.jpg",
            };

            foreach (var kvp in trips)
            {
                var name = kvp.Key;
                var img  = kvp.Value;

                await dbContext.AddAsync(new Trip
                {
                    Name        = name,
                    MapUrl      = img,
                    Description = "River Cruise Ruse to Budapest",
                    Duration    = 12,
                });
            }

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task SeedAsync(DanubeJourneyDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Ships.Any())
            {
                return;
            }

            var ships = new Dictionary <string, string>
            {
                ["Passion"]    = "https://images.cruisecritic.com/image/2109/image_1000x500_21.webp",
                ["Impression"] = "https://images.cruisecritic.com/image/2103/image_1000x500_21.webp",
            };

            foreach (var kvp in ships)
            {
                var name = kvp.Key;
                var img  = kvp.Value;

                await dbContext.AddAsync(new Ship
                {
                    Name        = name,
                    ImageUrl    = img,
                    Description = "Vivamus ultricies ex in faucibus fermentum. Vivamus a neque interdum, porta dolor vitae, dignissim velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi est mauris, imperdiet eget ante in, tincidunt commodo nisl. Mauris lacinia bibendum lacus, ac ultricies justo mattis bibendum. Cras finibus eros vitae urna ullamcorper, nec lacinia elit placerat. Ut tristique ornare enim ac convallis.",
                    Passengers  = 166,
                    Crew        = 47,
                    Length      = 443,
                    Staterooms  = 16,
                    Suites      = 67,
                });
            }

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task SeedAsync(DanubeJourneyDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Employees.Any())
            {
                return;
            }

            var employees = new Dictionary <string, string>
            {
                ["Ivan Georgiev"]    = "https://randomuser.me/api/portraits/men/91.jpg",
                ["Petar Petrov"]     = "https://robohash.org/officiavoluptatemeum.png?size=125x125&set=set1",
                ["Georgi Ivanov"]    = "https://robohash.org/placeatsitin.png?size=125x125&set=set1",
                ["Maya Manolova"]    = "https://robohash.org/etquodquo.png?size=125x125&set=set1",
                ["Korneliya Ninova"] = "https://robohash.org/doloresfugavoluptate.png?size=125x125&set=set1",
                ["Simeon Hristov"]   = "https://robohash.org/etquodquo.png?size=125x125&set=set1",
            };

            foreach (var employee in employees)
            {
                var fullName   = employee.Key;
                var firstName  = fullName.Split(" ")[0];
                var lastName   = fullName.Split(" ")[1];
                var avatar     = employee.Value;
                var salary     = (decimal) new Random().Next(2000, 5000);
                var experience = new Random().Next(5, 15);

                await dbContext.AddAsync(new Employee
                {
                    FirstName  = firstName,
                    LastName   = lastName,
                    Salary     = salary,
                    Experience = experience,
                    Avatar     = avatar,
                });
            }

            await dbContext.SaveChangesAsync();
        }