Ejemplo n.º 1
0
        public static void InitializeUrc(URCcontext context)
        {
            context.Database.EnsureCreated();

            if (!context.Opportunities.Any())
            {
                Opportunity_Seeding.GenerateSeed(context);
            }

            context.SaveChanges();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the needed databases after ensuring creation.
        /// </summary>
        /// <param name="services">The given service provider.</param>
        public static void Initialize(IServiceProvider services)
        {
            // Get required services
            var urc_db        = services.GetRequiredService <URC_Context>();
            var user_roles_db = services.GetRequiredService <UsersRolesDB>();
            var userManager   = services.GetRequiredService <UserManager <URCUser> >();
            var roleManager   = services.GetRequiredService <RoleManager <IdentityRole> >();

            // Ensure database creation
            urc_db.Database.EnsureCreated();
            user_roles_db.Database.EnsureCreated();

            // Initialize Opportunities/Skills/Tags
            Opportunity_Seeding.Initialize(urc_db);

            // Initialize UserRolesDB
            SeedUsersRolesDB.Initialize(userManager, roleManager, user_roles_db).Wait();

            // Initialize Student Applications
            Student_Application_Seeding.Initialize(urc_db, userManager);
        }