public async Task <IActionResult> DeleteApplicationRole(string id) { string name = string.Empty; if (!String.IsNullOrEmpty(id)) { IdentityRole applicationRole = await roleManager.FindByIdAsync(id); if (applicationRole != null) { name = applicationRole.Name; } } return(PartialView("_DeleteApplicationRole", name)); }
public async Task <IActionResult> DeleteApplicationRole(string id, FormCollection form) { if (!String.IsNullOrEmpty(id)) { IdentityRole applicationRole = await roleManager.FindByIdAsync(id); if (applicationRole != null) { IdentityResult roleRuslt = roleManager.DeleteAsync(applicationRole).Result; if (roleRuslt.Succeeded) { return(RedirectToAction("Index")); } } } return(View()); }
public async Task <IActionResult> AddEditApplicationRole(string id) { ApplicationRoleViewModel model = new ApplicationRoleViewModel(); if (!String.IsNullOrEmpty(id)) { IdentityRole applicationRole = await roleManager.FindByIdAsync(id); if (applicationRole != null) { model.Id = applicationRole.Id; model.RoleName = applicationRole.Name; // model.Description = applicationRole.Description; } } return(PartialView("_AddEditApplicationRole", model)); }
public async Task <IActionResult> AddEditApplicationRole(string id, ApplicationRoleViewModel model) { if (ModelState.IsValid) { bool isExist = !String.IsNullOrEmpty(id); IdentityRole applicationRole = isExist ? await roleManager.FindByIdAsync(id) : new IdentityRole { //CreatedDate = DateTime.UtcNow }; applicationRole.Name = model.RoleName; /* applicationRole.Description = model.Description; * applicationRole.IPAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();*/ IdentityResult roleRuslt = isExist ? await roleManager.UpdateAsync(applicationRole) : await roleManager.CreateAsync(applicationRole); if (roleRuslt.Succeeded) { return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }