public void SetupRolesAndUsers(UserManager <RestaurantUser> userManager, RoleManager <RestaurantRole> roleManager) { if (roleManager.FindByNameAsync("Client").Result == null) { roleManager.CreateAsync(new RestaurantRole() { Name = "Client" }).Wait(); } if (roleManager.FindByNameAsync("Staff").Result == null) { roleManager.CreateAsync(new RestaurantRole() { Name = "Staff" }).Wait(); } if (roleManager.FindByNameAsync("Admin").Result == null) { roleManager.CreateAsync(new RestaurantRole() { Name = "Admin" }).Wait(); } if (userManager.FindByNameAsync("admin").Result == null) { var person = new Person(DateTime.Now, "Administrator", "", 0000000, 0); var abo = new AccountBusinessController(userManager, roleManager); var res = abo.Register("admin", "*****@*****.**", "Admin123!#", person, "Admin").Result; var roleRes = userManager.AddToRoleAsync(userManager.FindByNameAsync("admin").Result, "Admin"); } }
public void SetupRolesAndUsers(UserManager <User> userManager, RoleManager <Role> roleManager) { if (roleManager.FindByNameAsync("Visitor").Result == null) { roleManager.CreateAsync(new Role() { Name = "Visitor" }).Wait(); } if (roleManager.FindByNameAsync("Company").Result == null) { roleManager.CreateAsync(new Role() { Name = "Company" }).Wait(); } if (roleManager.FindByNameAsync("Admin").Result == null) { roleManager.CreateAsync(new Role() { Name = "Admin" }).Wait(); } if (userManager.FindByNameAsync("admin").Result == null) { var profile = new Profile("i'm the owner of this house", "anonymous"); var abo = new AccountBusinessController(userManager, roleManager); var res = abo.Register("admin", "*****@*****.**", "Admin123!#", profile, "Admin").Result; var roleRes = userManager.AddToRoleAsync(userManager.FindByNameAsync("admin").Result, "Admin"); } }
public async Task <IActionResult> Register(RegisterViewModel vm) { var accountBo = new AccountBusinessController(UserManager, RoleManager); var profile = new Profile(vm.VatNumber, vm.FirstName, vm.LastName, vm.PhoneNumber, vm.BirthDate); var registerOperation = await accountBo.Register(vm.UserName, vm.Email, vm.Password, profile, vm.Role); if (registerOperation.Success) { return(OperationSuccess("The account was successfuly registered!")); } TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, registerOperation.Message); return(View(vm)); }
public void SetupRolesAndUsers(UserManager <FullStoqUser> userManager, RoleManager <FullStoqRole> roleManager) { if (roleManager.FindByNameAsync("Client").Result == null) { roleManager.CreateAsync(new FullStoqRole() { Name = "Client" }).Wait(); } if (roleManager.FindByNameAsync("Staff").Result == null) { roleManager.CreateAsync(new FullStoqRole() { Name = "Staff" }).Wait(); } if (roleManager.FindByNameAsync("Security").Result == null) { roleManager.CreateAsync(new FullStoqRole() { Name = "Security" }).Wait(); } if (roleManager.FindByNameAsync("Management").Result == null) { roleManager.CreateAsync(new FullStoqRole() { Name = "Management" }).Wait(); } if (roleManager.FindByNameAsync("Admin").Result == null) { roleManager.CreateAsync(new FullStoqRole() { Name = "Admin" }).Wait(); } if (userManager.FindByNameAsync("admin").Result == null) { var person = new Profile(912345678, "Utilizador", "Exemplo", 0000000, DateTime.Now); var abo = new AccountBusinessController(userManager, roleManager); var res = abo.Register("admin", "*****@*****.**", "Admin123!#", person, "Admin").Result; var roleRes = userManager.AddToRoleAsync(userManager.FindByNameAsync("admin").Result, "Admin"); } }
public async Task <IActionResult> Register(RegisterViewModel vm) { var accountBo = new AccountBusinessController(UserManager, RoleManager); var person = new Profile(vm.Description, vm.PhotoPath); var registerOperation = await accountBo.Register(vm.UserName, vm.Email, vm.Password, person, vm.Role); if (registerOperation.Success) { if (vm.Role == "Visitor") { return(RedirectToAction("Create", "Visitors")); } if (vm.Role == "Company") { return(RedirectToAction("Create", "Companies")); } } //return OperationSuccess("The account was successfuly registered!"); TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, registerOperation.Message); return(View(vm)); }