public ActionResult Create(TeamEdit teamEdit) { ModelState.Merge(teamEdit.Validate(Db)); if (ModelState.IsValid) { int[] memberIds; Team team = teamEdit.GetModel(UserId, out memberIds); TeamCache.Insert(Db, UserId, team, memberIds); return RedirectToAction("Index"); } PopulateMemberIds(teamEdit.MemberIds); return View(teamEdit); }
public ActionResult Edit(TeamEdit teamEdit) { ModelState.Merge(teamEdit.Validate(Db)); if (ModelState.IsValid) { int[] memberIds; Team team = teamEdit.GetModel(UserId, out memberIds); bool success = TeamCache.Update(Db, memberIds, ref team); if (!success) { return RedirectToAccessDenied(); } return RedirectToAction("Index"); } PopulateMemberIds(teamEdit.MemberIds); return View(teamEdit); }
public static TeamEdit GetModelView(Team team) { if (team == null) return null; var teamEdit = new TeamEdit(team); return teamEdit; }