Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public static TeamEdit GetModelView(Team team)
        {
            if (team == null)
                return null;

            var teamEdit = new TeamEdit(team);
            return teamEdit;
        }