// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Assignment1Context context, RoleManager <IdentityRole> roleManager, UserManager <Assignment1User> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DummyData.Initialize(context, roleManager, userManager).Wait();// seed here CompoundController.context = context; }
public StudentsController(Assignment1Context context) { _context = context; }
public RoleManagerController(Assignment1Context context, RoleManager <IdentityRole> roleManager) { _context = context; _roleManager = roleManager; }
public static async Task Initialize(Assignment1Context context, RoleManager <IdentityRole> roleManager, UserManager <Assignment1User> userManager) { context.Database.EnsureCreated(); String adminId1 = ""; String adminId2 = ""; string role1 = "Admin"; string desc1 = "This is the administrator role"; string role2 = "Member"; string desc2 = "This is the members role"; if (await roleManager.FindByNameAsync(role1) == null) { await roleManager.CreateAsync(new IdentityRole(role1)); } if (await roleManager.FindByNameAsync(role2) == null) { await roleManager.CreateAsync(new IdentityRole(role2)); } if (await userManager.FindByEmailAsync("[email protected]") == null) { Assignment1User newUser = new Assignment1User(); newUser.AddressCity = "vancouver"; newUser.AddressCountry = "canada"; newUser.AddressProvince = "bc"; newUser.AddressStreet = "123"; newUser.Email = "[email protected]"; newUser.FirstName = "wow"; newUser.LastName = "weow"; newUser.UserName = "******"; newUser.Role = "Admin"; var result = await userManager.CreateAsync(newUser, "P@$$w0rd"); if (result.Succeeded) { await userManager.AddToRoleAsync(newUser, "Admin"); } } if (await userManager.FindByEmailAsync("[email protected]") == null) { Assignment1User newUser = new Assignment1User(); newUser.AddressCity = "vancouver"; newUser.AddressCountry = "canada"; newUser.AddressProvince = "bc"; newUser.AddressStreet = "123"; newUser.Email = "[email protected]"; newUser.FirstName = "wow"; newUser.LastName = "weow"; newUser.UserName = "******"; newUser.Role = "Member"; var result = await userManager.CreateAsync(newUser, "P@$$w0rd"); if (result.Succeeded) { await userManager.AddToRoleAsync(newUser, "Member"); } } }
public UserManagerController(Assignment1Context context, RoleManager <IdentityRole> roleManager, UserManager <Assignment1User> userManager) { _context = context; _userManager = userManager; _roleManager = roleManager; }
public PlayersController(Assignment1Context context) { _context = context; }
public GuildsController(Assignment1Context context) { _context = context; }