From afa3271c8f8a3dab5715fa01a333d1c541e94ce0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 22 May 2017 21:34:35 -0400 Subject: [PATCH] removeuserfromrole --- Project-Unite/Controllers/AdminController.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Project-Unite/Controllers/AdminController.cs b/Project-Unite/Controllers/AdminController.cs index 57bd245..91cbf81 100644 --- a/Project-Unite/Controllers/AdminController.cs +++ b/Project-Unite/Controllers/AdminController.cs @@ -65,6 +65,21 @@ public ActionResult AddUserToRole(AddUserToRoleViewModel model) return RedirectToAction("Index", new { id = "roles" }); } + public ActionResult RemoveUserFromRole(string id, string usr) + { + var usermanager = HttpContext.GetOwinContext().Get(); + 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) { var db = new ApplicationDbContext();