public ActionResult UserRoles(SelectUserRolesViewModel model) { if (ModelState.IsValid) { var idManager = new ClinikeIdentityManager(); var user = ClinikeUserEx.Find(u => u.UserName == model.UserName); idManager.ClearUserRoles(user.Id); foreach (var role in model.Roles) { if (role.Selected) { idManager.AddUserToRole(user.Id, role.Name); } } return RedirectToRoute("AccountIndex"); } return View(); }
public ActionResult UserRoles(string id) { var user = ClinikeUserEx.Find(u => u.Id == id, includes: new List<string> { "Roles" }); var model = new SelectUserRolesViewModel(user); return View(model); }