public ActionResult Create() { CupWinnerViewModel model = new CupWinnerViewModel(); PopulateStaticData(model); return(View(model)); }
public ActionResult Create(CupWinnerViewModel model) { if (ModelState.IsValid) { CupWinner leagueWinner = new CupWinner(competitionService.GetCurrentSeason(), cupService.Get(model.CupId), teamService.Get(model.TeamId)); this.cupWinnerService.Insert(leagueWinner); this.cupWinnerService.Commit(); SuccessMessage(FormMessages.SaveSuccess); return(RedirectToAction("Index")); } PopulateStaticData(model); return(View(model)); }
private void PopulateStaticData(CupWinnerViewModel model) { model.Teams = teamService.GetTeamsForCurrentSeason().ToSelectList(x => x.ToString(), x => x.Id.ToString(), model.TeamId.ToString()); model.Cups = this.cupService.Get(orderBy: q => q.OrderByDescending(s => s.Id)).ToSelectList(x => x.ToString(), x => x.Id.ToString(), model.CupId.ToString()); }