public static async Task InitialSetup(IServiceProvider serviceProvider, IConfiguration configuration) { var context = new DataWebserviceContext(); var roleManager = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >(); var userManager = serviceProvider.GetRequiredService <UserManager <IdentityUser> >(); //Create Roles string[] roleNames = { "Super Admin", "Installer", "Demo", "User" }; IdentityResult roleResult; foreach (var name in roleNames) { var roleExist = await roleManager.RoleExistsAsync(name); if (!roleExist) { roleResult = await roleManager.CreateAsync(new IdentityRole(name)); } } //Create Admin var email = "*****@*****.**"; var password = "******"; var admin = new IdentityUser { UserName = email, Email = email }; var user = await userManager.FindByEmailAsync(email); if (user == null) { var createAdmin = await userManager.CreateAsync(admin, password); if (createAdmin.Succeeded) { foreach (var role in roleNames) { await userManager.AddToRoleAsync(admin, role); } } } }
public SensorLogsController(DataWebserviceContext context) { _context = context; }
public SensorTests(DataWebserviceContext context) { _context = context; }
public UserTests(DataWebserviceContext context) { _context = context; }
public UsersController(DataWebserviceContext context) { _context = context; }
public RoleController(DataWebserviceContext context, RoleManager <IdentityRole> roleManager, UserManager <IdentityUser> userManager) { _context = context; _roleManager = roleManager; _userManager = userManager; }
public RoomAccessesController(DataWebserviceContext context) { _context = context; }
public RoomTests(DataWebserviceContext context) { _context = context; }
public DataOriginalController(DataWebserviceContext context) { _context = context; }