public ActionResult Add() { var viewModel = new TeamsAddViewModel(); viewModel.Init(Repository, _eventsRepository, _teamMembersRepository); return(View(viewModel)); }
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)); }