Ejemplo n.º 1
0
        public ActionResult ChangeRole(string userName, string role)
        {
            var user        = Logic.Find(u => u.UserName == userName);
            var oldRoleId   = user.Roles.SingleOrDefault().RoleId;
            var oldRoleName = Logic.GetRole(oldRoleId).Name;

            if (oldRoleName != role)
            {
                UserManager.RemoveFromRole(user.Id, oldRoleName);
                UserManager.AddToRole(user.Id, role);
                Logic.ModifyUser(user);
            }

            return(RedirectToAction("Index"));
        }