Exemple #1
0
        public ActionResult Add()
        {
            var viewModel = new TeamsAddViewModel();

            viewModel.Init(Repository, _eventsRepository, _teamMembersRepository);

            return(View(viewModel));
        }
Exemple #2
0
        public ActionResult Add(TeamsAddViewModel viewModel)
        {
            ValidateTeam(viewModel.Team);

            if (TempData["Error"] == null)
            {
                if (ModelState.IsValid)
                {
                    var team = viewModel.Team;
                    team.AddTeamMember(viewModel.TeamMemberId, viewModel.RoleId);

                    _teamsRepository.Add(team);

                    TempData["Message"] = "Your team was successfully added!";

                    return(RedirectToAction("Detail", new { id = team.Id }));
                }
            }

            viewModel.Init(Repository, _eventsRepository, _teamMembersRepository);

            return(View(viewModel));
        }