Exemple #1
0
 protected override void Seed(DataContext.StuDBContext context)
 {
     context.Database.ExecuteSqlCommand("delete Students");
     context.Database.ExecuteSqlCommand("delete DepartMents");
     DepartMentSeed.Seed(context);
     StudentSeed.Seed(context);
 }
        public static async void UseSeed(this IApplicationBuilder app)
        {
            IServiceScope  scope         = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope();
            PgsqlContext   context       = scope.ServiceProvider.GetService <PgsqlContext>();
            IRepository    repository    = scope.ServiceProvider.GetService <IRepository>();
            IConfiguration configuration = scope.ServiceProvider.GetService <IConfiguration>();

            using (context)
            {
                // Crea la BD si no existe
                context.Database.Migrate();

                // ejecuta los seeds necesarios en la BD
                // se deben agregar
                bool runSeed = bool.Parse(configuration.GetValue <string>("Seed"));
                if (runSeed)
                {
                    if (!context.Student.Any())
                    {
                        StudentSeed studentSeed = new StudentSeed(repository);
                        await studentSeed.Run();
                    }
                }
            }
        }
        protected override void Seed(ModelContext context)
        {
            context.Students.AddRange(StudentSeed.Seed());
            context.Courses.AddRange(CourseSeed.Seed());

            base.Seed(context);
        }
        protected override void Seed(AppContext context)
        {
            //  UserSeed.VandGrow(context);
            EstateStatusSeed.VandGrow(context);
            CourseHoldingTypeSeed.VandGrow(context);
            BankSeed.VandGrow(context);
            MaritalStatusSeed.VandGrow(context);
            ReligionSeed.VandGrow(context);
            EducationDegreeSeed.VandGrow(context);
            MilitaryStatusSeed.VandGrow(context);

            ShiftSeed.VandGrow(context);
            RoleSeed.VandGrow(context);
            MenuSeed.VandGrow(context);
            SexSeed.VandGrow(context);
            //ProvinceSeed.VandGrow(context);
            CategorySeed.VandGrow(context);
            SiteSeed.VandGrow(context);

            TeacherSeed.VandGrow(context);
            EducationalCenterUserSeed.VandGrow(context);
            StudentSeed.VandGrow(context);

            MenuSeed.VandGrow(context);
            RecruitmentTypeSeed.VandGrow(context);

            //OrganizationSeed.VandGrow(context);

            //DepartmentTypeSeed.VandGrow(context);
            //SiteSeed.VandGrow(context);
            //LanguageCenterUserRoleSeed.VandGrow(context);
            ClassroomTypeSeed.VandGrow(context);
            //MinistryOfEducationUserSeed.VandGrow(context);
            base.Seed(context);
        }
 public static void Seed(MainContext context)
 {
     MovieSeed.Initialize(context);
     StudentSeed.Initialize(context);
     InstructorSeed.Initialize(context);
     DepartmentSeed.Initialize(context);
     CourseSeed.Initialize(context);
     OfficeAssignmentSeed.Initialize(context);
     CourseAssignmentSeed.Initialize(context);
     EnrollmentSeed.Initialize(context);
 }
Exemple #6
0
        //This class tells Entity Framework where our seed files are,
        //and to use them to add records to our operational database.
        //We do them in this order so that foreign keys can be established.
        protected override async void Seed(OracleContext context)
        {
            //System-specific
            context.Users.AddOrUpdate(UserSeed.ToArray());
            await context.SaveChangesAsync();

            context.Permissions.AddOrUpdate(PermissionSeed.ToArray());
            await context.SaveChangesAsync();

            //Operational
            context.Campuses.AddOrUpdate(CampusSeed.ToArray());
            await context.SaveChangesAsync();

            context.Countries.AddOrUpdate(CountrySeed.ToArray());
            await context.SaveChangesAsync();

            context.AcademicYears.AddOrUpdate(AcademicYearSeed.ToArray());
            await context.SaveChangesAsync();

            context.Modules.AddOrUpdate(ModuleSeed.ToArray());
            await context.SaveChangesAsync();

            context.Courses.AddOrUpdate(CourseSeed.ToArray());
            await context.SaveChangesAsync();

            context.CourseModules.AddOrUpdate(CourseModuleSeed.ToArray());
            await context.SaveChangesAsync();

            context.Lecturers.AddOrUpdate(LecturerSeed.ToArray());
            await context.SaveChangesAsync();

            context.ModuleRuns.AddOrUpdate(ModuleRunSeed.ToArray());
            await context.SaveChangesAsync();

            context.Students.AddOrUpdate(StudentSeed.ToArray());
            await context.SaveChangesAsync();

            context.Enrollments.AddOrUpdate(EnrollmentSeed.ToArray());
            await context.SaveChangesAsync();

            context.Assignments.AddOrUpdate(AssignmentSeed.ToArray());
            await context.SaveChangesAsync();

            context.Results.AddOrUpdate(ResultSeed.ToArray());
            await context.SaveChangesAsync();

            context.Graduations.AddOrUpdate(GraduationSeed.ToArray());
            await context.SaveChangesAsync();

            context.Complaints.AddOrUpdate(ComplaintSeed.ToArray());
            await context.SaveChangesAsync();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AaaSeed aaaSeed, StudentSeed sSeed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
                    );
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            aaaSeed.MigrateAsync().Wait();
            aaaSeed.SeedAsync().Wait();

            sSeed.MigrateAsync().Wait();
            sSeed.SeedAsync();
        }