removeuserfromrole

This commit is contained in:
Michael 2017-05-22 21:34:35 -04:00
parent 3e9e9b5e9c
commit afa3271c8f

View file

@ -65,6 +65,21 @@ public ActionResult AddUserToRole(AddUserToRoleViewModel model)
return RedirectToAction("Index", new { id = "roles" }); return RedirectToAction("Index", new { id = "roles" });
} }
public ActionResult RemoveUserFromRole(string id, string usr)
{
var usermanager = HttpContext.GetOwinContext().Get<ApplicationUserManager>();
var db = new ApplicationDbContext();
Role role = null;
foreach (var r in db.Roles)
{
if (r is Role)
if ((r as Role).Id == id)
role = r as Role;
}
usermanager.RemoveFromRole(usr, role.Name);
return RedirectToAction("Index", new { id = "roles" });
}
public ActionResult RoleDetails(string id) public ActionResult RoleDetails(string id)
{ {
var db = new ApplicationDbContext(); var db = new ApplicationDbContext();