public ActionResult Create() { TeamLeagueViewModel model = new TeamLeagueViewModel(); PopulateStaticData(model); return View(model); }
public ActionResult Create(TeamLeagueViewModel model) { if (ModelState.IsValid) { Team team = teamService.Get(model.TeamId); TeamLeague teamLeague = new TeamLeague(competitionService.GetLeague(model.LeagueId), team, team.TeamName, team.TeamNameLong); teamLeagueService.Insert(teamLeague); teamLeagueService.Commit(); SuccessMessage(FormMessages.SaveSuccess); return RedirectToAction("Index"); } PopulateStaticData(model); return View(model); }
private void PopulateStaticData(TeamLeagueViewModel model) { model.Teams = teamService.Get(orderBy: q => q.OrderBy(t => t.TeamNameLong)).ToSelectList(x => x.ToString(), x => x.Id.ToString(), model.TeamId.ToString()); model.Leagues = competitionService.GetLeaguesForCurrentSeason().ToSelectList(x => x.Season.ToString() + " " + x.ToString(), x => x.Id.ToString(), model.LeagueId.ToString()); }