public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } LodgerRole = await _roleManager.FindByIdAsync(id); IdentityResult roleRuslt = await _roleManager.DeleteAsync(LodgerRole); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } LodgerRole = await _roleManager.FindByIdAsync(id); if (LodgerRole == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } LodgerRole = await _context.LodgerRole.FirstOrDefaultAsync(m => m.Id == id); if (LodgerRole == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } LodgerRole appRole = await _roleManager.FindByIdAsync(LodgerRole.Id); appRole.Name = LodgerRole.Name; appRole.RoleDescription = LodgerRole.RoleDescription; IdentityResult roleRuslt = await _roleManager.UpdateAsync(appRole); if (roleRuslt.Succeeded) { return(RedirectToPage("./Index")); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string selectedusername, string selectedrolename) { //When the Assign button is pressed if ((selectedusername == null) || (selectedrolename == null)) { return(RedirectToPage("Manage")); } Lodger AppUser = _context.Users.SingleOrDefault(u => u.UserName == selectedusername); LodgerRole AppRole = await _roleManager.FindByNameAsync(selectedrolename); IdentityResult roleResult = await _userManager.AddToRoleAsync(AppUser, AppRole.Name); if (roleResult.Succeeded) { TempData["message"] = "Role added to this user successfully"; return(RedirectToPage("Manage")); } return(RedirectToPage("Manage")); }