public ActionResult Create(UpsertGroupViewModel model) { try { if (ModelState.IsValid) { Group newGroup = new Group(); int leaderId = 0; int.TryParse(model.GroupLeaderId, out leaderId); newGroup.Name = model.GroupName; newGroup.GroupLeaderId = leaderId; GroupsManager.Add(newGroup); Member groupLeader = MembersManager.SelectByMemberId(leaderId); groupLeader.GroupId = newGroup.ID; MembersManager.Update(groupLeader); if (model.GroupMemberIds != null && model.GroupMemberIds.Count > 0) { foreach (var memberId in model.GroupMemberIds) { int id = 0; int.TryParse(memberId, out id); Member member = MembersManager.SelectByMemberId(id); member.GroupId = newGroup.ID; MembersManager.Update(member); } } } } catch { return View(new UpsertGroupViewModel()); } return RedirectToAction("EditMode"); }
public ActionResult Rename(UpsertGroupViewModel model) { Group group = GroupsManager.SelectByGroupId(model.GroupId); group.Name = model.GroupName; GroupsManager.Update(group); return RedirectToAction("EditMode"); }