Exemplo n.º 1
0
        public async Task Seed()
        {
            var playlists = CreatePlaylistSeed();

            _context.AddRange(playlists);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task Seed()
        {
            var coupons = GetCouponFromJson();

            if (!_context.Coupons.Any())
            {
                // add static data for course arrtribute
                _context.AddRange(coupons);
                await _context.SaveChangesAsync();
            }
        }
Exemplo n.º 3
0
        public static void Seed()
        {
            var context = new CourseContext();

            if (context.Database.GetPendingMigrations().Count() == 0)
            {
                if (context.School.Count() == 0)
                {
                    context.School.AddRange(Schools);
                    context.Course.AddRange(Courses);
                    context.City.AddRange(Cities);
                    context.State.AddRange(States);
                    context.Country.AddRange(Countries);
                    context.Language.AddRange(Languages);
                    context.Time.AddRange(Times);
                    context.SImage.AddRange(SImages);
                    context.SaveChanges();
                    context.AddRange(CourseLanguages);
                    context.AddRange(CourseTimes);
                    context.AddRange(BranchCountries);
                    context.AddRange(BranchStates);
                    context.AddRange(BranchCities);
                    context.AddRange(BranchAccommodations);
                    context.AddRange(BranchBImages);
                    context.AddRange(SchoolSImages);
                    context.AddRange(BranchCourses);
                    context.AddRange(CountryStates);
                    context.AddRange(StateCities);
                    context.AddRange(CountryCities);
                    context.AddRange(BranchCountries);
                    context.AddRange(SchoolBranches);
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 4
0
        public async Task Seed()
        {
            // step 1: setup the Course Attribute
            var entityAttributeTypes = CreateEntityAttributeTypeSeed();

            if (!_context.EntityAttributeTypes.Any())
            {
                // add static data for course arrtribute
                _context.AddRange(entityAttributeTypes);
                await _context.SaveChangesAsync();
            }

            // step 2: setup the Entity Attribute values
            var entityAttributes = CreateEntityAttributeSeed();

            if (!_context.EntityAttributes.Any())
            {
                // TODO: Move the transaction block out!!!
                // must to use transaction + SET IDENTITY_INSERT ON to preset Id for entityAttribute datas
                using (var transaction = _context.Database.BeginTransaction())
                {
                    _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [course].[EntityAttributes] ON");
                    _context.AddRange(entityAttributes);
                    await _context.SaveChangesAsync();

                    _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [course].[EntityAttributes] OFF");
                    transaction.Commit();
                }
            }

            //// step 3: setup the courses
            var user = await _userRepository.GetUserByUserNameAsync("yaduolmailinatorcom");

            if (user == null)
            {
                return;
            }

            //var courses = CreateCourseSeed(user);
            var courses = new List <Course>
            {
                // K12
                GetCourseSeed(user, "K12/K12_Calculus_AP.json"),
                GetCourseSeed(user, "K12/K12_Chemistry_11.json"),
                GetCourseSeed(user, "K12/K12_Chemistry_AP.json"),
                GetCourseSeed(user, "K12/K12_Chemistry_IB.json"),
                GetCourseSeed(user, "K12/K12_Chemistry_SAT.json"),
                GetCourseSeed(user, "K12/K12_MATH_SAT.json"),
                GetCourseSeed(user, "K12/K12_MYP1_IB.json"),
                GetCourseSeed(user, "K12/K12_MYP2_IB.json"),
                GetCourseSeed(user, "K12/K12_MYP3_IB.json"),
                GetCourseSeed(user, "K12/K12_MYP4_IB.json"),
                GetCourseSeed(user, "K12/K12_MYP5_IB.json"),
                GetCourseSeed(user, "K12/K12_MYP5_PLUS_IB.json"),
                GetCourseSeed(user, "K12/K12_Physics_AP.json"),
                GetCourseSeed(user, "K12/K12_Physics_IB.json"),
                GetCourseSeed(user, "K12/K12_Physics_SAT.json"),

                // College
                // SFU
                GetCourseSeed(user, "College/SFU/Sfu_BUEC_232.json"),
                GetCourseSeed(user, "College/SFU/Sfu_BUEC_333.json"),
                GetCourseSeed(user, "College/SFU/Sfu_BUS_200.json"),
                GetCourseSeed(user, "College/SFU/Sfu_BUS_251.json"),
                GetCourseSeed(user, "College/SFU/Sfu_CHEM_110.json"),
                GetCourseSeed(user, "College/SFU/Sfu_CMPT_120.json"),
                GetCourseSeed(user, "College/SFU/Sfu_CMPT_165.json"),
                GetCourseSeed(user, "College/SFU/Sfu_ECON_103.json"),
                GetCourseSeed(user, "College/SFU/Sfu_ECON_105.json"),
                GetCourseSeed(user, "College/SFU/Sfu_LING_111.json"),
                GetCourseSeed(user, "College/SFU/Sfu_MATH_100.json"),
                GetCourseSeed(user, "College/SFU/Sfu_MATH_157.json"),
                GetCourseSeed(user, "College/SFU/Sfu_PHIL_105.json"),
                GetCourseSeed(user, "College/SFU/Sfu_PHIL_110.json"),
                GetCourseSeed(user, "College/SFU/Sfu_STAT_203.json"),
                // UBC
                GetCourseSeed(user, "College/UBC/Ubc_CHEM_111.json"),
                GetCourseSeed(user, "College/UBC/Ubc_CHEM_121.json"),
                GetCourseSeed(user, "College/UBC/Ubc_COMM_204.json"),
                GetCourseSeed(user, "College/UBC/Ubc_ECON_101.json"),
                GetCourseSeed(user, "College/UBC/Ubc_LPI.json"),
                GetCourseSeed(user, "College/UBC/Ubc_MATH_100.json"),
                GetCourseSeed(user, "College/UBC/Ubc_MATH_101.json"),
                GetCourseSeed(user, "College/UBC/Ubc_MATH_102.json"),
                GetCourseSeed(user, "College/UBC/Ubc_PSYC_101.json"),
                GetCourseSeed(user, "College/UBC/Ubc_STAT_200.json"),

                // Certifications
                GetCourseSeed(user, "Cer/CFA_1.json"),
                GetCourseSeed(user, "Cer/CFA_2.json"),
                GetCourseSeed(user, "Cer/CPA_1.json"),
                GetCourseSeed(user, "Cer/CPA_2.json"),
                GetCourseSeed(user, "Cer/CSC_Volume_1.json"),
                GetCourseSeed(user, "Cer/CSC_Volume_2.json"),
                GetCourseSeed(user, "Cer/NCA_1.json"),
                GetCourseSeed(user, "Cer/NCA_2.json"),
                GetCourseSeed(user, "Cer/Realtor_1.json")
            };

            if (!_context.Courses.Any())
            {
                // add courses
                _context.AddRange(courses);
                await _context.SaveChangesAsync();
            }
        }
Exemplo n.º 5
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new CourseContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <CourseContext> >()))
            {
                if (context.Courses.Any())
                {
                    return;
                }
                var locations = new Location[]
                {
                    new Location
                    {
                        Country = "USA",
                        State   = "PA",
                        City    = "Philadelphia",
                        ZipCode = 19103
                    },
                    new Location
                    {
                        Country = "USA",
                        State   = "PA",
                        City    = "Pittsburgh",
                        ZipCode = 15213
                    },
                    new Location
                    {
                        Country = "USA",
                        State   = "PA",
                        City    = "Pittsburgh",
                        ZipCode = 15068
                    },
                    new Location
                    {
                        Country = "USA",
                        State   = "PA",
                        City    = "Philadelphia",
                        ZipCode = 19130
                    },
                    new Location
                    {
                        Country = "USA",
                        State   = "NY",
                        City    = "New York City",
                        ZipCode = 17890
                    },
                    new Location
                    {
                        Country = "USA",
                        State   = "NJ",
                        City    = "Newark",
                        ZipCode = 18909
                    }
                };
                context.AddRange(locations);
                context.SaveChanges();

                var courses = new Course[]
                {
                    new Course {
                        Name = "Cabin Greens", LocationId = 1, Type = CourseType.Executive, Par = 72, DateFounded = DateTime.Parse("02/12/1989")
                    },
                    new Course {
                        Name = "Saxonburg Golf Club", LocationId = 2, Type = CourseType.Links, Par = 72, DateFounded = DateTime.Parse("03/17/1949")
                    },
                    new Course {
                        Name = "Sewickly Golf Club", LocationId = 3, Type = CourseType.Links, Par = 72, DateFounded = DateTime.Parse("12/22/1933")
                    },
                    new Course {
                        Name = "Buffalo Golf Course", LocationId = 4, Type = CourseType.PitchAndPutt, Par = 36, DateFounded = DateTime.Parse("10/02/1889")
                    },
                    new Course {
                        Name = "Fox Chapel Country Club", LocationId = 3, Type = CourseType.Links, Par = 72, DateFounded = DateTime.Parse("05/05/1895")
                    },
                };
                context.AddRange(courses);
                context.SaveChanges();
                InitializeSomeHoles(context);
                context.SaveChanges();
                InitializeRoundsOfGolf(context);
                context.SaveChanges();
                IntializeGolfers(context);
                context.SaveChanges();
                //InitializeLocations(context);
                //context.SaveChanges();
                //InitializeCourses(context);
                //context.SaveChanges();
            }
        }