// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager, IDocumentTypeRepository typeRepository, IAccessTypeRepository accessType, IApprovalStatusRepository approvalStatus, IApprovalProgressStatusRepository approvalProgress, IAuditActionRepository actionRepository) { 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(); } SeedData.SeedDatas(roleManager, userManager, typeRepository, accessType, approvalProgress, approvalStatus, actionRepository); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public static void SeedDatas( RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager, IDocumentTypeRepository typeRepository, IAccessTypeRepository accessType, IApprovalProgressStatusRepository approvalProgress, IApprovalStatusRepository approvalStatus, IAuditActionRepository actionRepository ) { SeedRoles(roleManager); SeedUsers(userManager); SeedDocumentType(typeRepository); SeedAccessType(accessType); SeedApprovalProgressStatus(approvalProgress); SeedApprovalStatus(approvalStatus); SeedAuditAction(actionRepository); }
public static void SeedApprovalProgressStatus(IApprovalProgressStatusRepository statusRepository) { string[] statusList = new string[] { "Approval In Progress", "Approved", "Declined", "Queried" }; foreach (string status in statusList) { if (statusRepository.FindByNameAsync(status).Result == null) { ApprovalProgressStatus approval = new ApprovalProgressStatus() { Status = status }; try { statusRepository.SaveStatusAsync(approval); } catch (Exception ex) { Console.WriteLine(ex); } } } }