Ejemplo n.º 1
0
        public ActionResult RemoveFromRole(string Id)
        {
            var role = db.Roles.Find(Id);
            var model = new RolesViewModel();
            model.RoleId = role.Id;
            model.RoleName = role.Name;
            var userRoleList = helper.UsersInRole(role.Name);

            model.Users = new MultiSelectList(userRoleList.OrderBy(m => m.DisplayName), "Id", "DisplayName", null);

            return View(model);
        }
Ejemplo n.º 2
0
 public ActionResult AssignToRole(RolesViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.SelectedUsers != null)
         {
             foreach (string id in model.SelectedUsers)
             {
                 helper.AddUserToRole(id, model.RoleName);
             }
         }
         return RedirectToAction("Index", "RoleManager");
     }
     return View(model);
 }