public ActionResult Edit(long id) { SubjectManager subjectManager = new SubjectManager(); Group group = subjectManager.GetGroupById(id); return PartialView("_EditPartial", GroupEditModel.Convert(group)); }
public ActionResult Edit(GroupEditModel model) { if (ModelState.IsValid) { SubjectManager subjectManager = new SubjectManager(); Group group = subjectManager.GetGroupById(model.GroupId); group.Name = model.GroupName; group.Description = model.Description; long[] users = group.Users.Select(g => g.Id).ToArray(); foreach (long userId in users) { subjectManager.RemoveUserFromGroup(userId, group.Id); } if (Session["Users"] != null) { foreach (GroupMembershipGridRowModel user in (GroupMembershipGridRowModel[]) Session["Users"]) { if (user.IsUserInGroup) { subjectManager.AddUserToGroup(user.Id, group.Id); } } } subjectManager.UpdateGroup(group); return Json(new { success = true }); } else { return PartialView("_EditPartial", model); } }
public ActionResult Membership_Select(long id, long[] selectedUsers) { SubjectManager subjectManager = new SubjectManager(); List<GroupMembershipGridRowModel> users = new List<GroupMembershipGridRowModel>(); if (selectedUsers != null) { users = subjectManager.GetAllUsers().Select(u => GroupMembershipGridRowModel.Convert(u, selectedUsers.Contains(u.Id))).ToList(); } else { Group group = subjectManager.GetGroupById(id); users = subjectManager.GetAllUsers().Select(u => GroupMembershipGridRowModel.Convert(u, u.Groups.Any(g => g.Id == id))).ToList(); } return View(new GridModel<GroupMembershipGridRowModel> { Data = users }); }