public virtual ActionResult UserGroups(SelectUserGroupsViewModel model) { if (ModelState.IsValid) { var idManager = new IdentityManager(); var user = _db.Users.First(u => u.UserName == model.UserName); idManager.ClearUserGroups(user.Id); foreach (var group in model.Groups) { if (group.Selected) { idManager.AddUserToGroup(user.Id, group.GroupId); } } return RedirectToAction("index"); } return View(); }
public virtual ActionResult UserGroups(string id) { var user = _db.Users.First(u => u.UserName == id); var model = new SelectUserGroupsViewModel(user); return View(model); }