public ActionResult AssignRole(int id, int page = 0)
 {
     using (UsersContext db = new UsersContext())
     {
         var user = db.UserProfiles.FirstOrDefault(r => r.UserId == id);
         var roles = (SimpleRoleProvider)Roles.Provider;
         var roleList = roles.GetAllRoles().ToList();
         var ur = new UserRoleModelView();
         ur.roles = roleList;
         ur.page = page;
         ur.UserName = user.UserName;
         ur.selectedRoles = roles.GetRolesForUser(user.UserName);
         return View(ur);
     }
 }
 public ActionResult AssignRolesforUser(UserRoleModelView userRoleModelView)
 {
     var roles = (SimpleRoleProvider)Roles.Provider;
     roles.RemoveUsersFromRoles(new string[] { userRoleModelView.UserName }, roles.GetRolesForUser(userRoleModelView.UserName).ToArray());
     if (userRoleModelView.selectedRoles != null)
     {
         foreach (var role in userRoleModelView.selectedRoles)
         {
             if (!roles.GetRolesForUser(userRoleModelView.UserName).Contains(role))
             {
                 roles.AddUsersToRoles(new[] { userRoleModelView.UserName }, new[] { role });
             }
         }
     }
     return RedirectToAction("GetAllUsers", "User", new { page = userRoleModelView.page });
 }