public ActionResult EditMatch(int id) { Match match = matchProvider.GetMatchById(id); if (match == null) { log.Error("Controller: Match, Action: EditMatch Don't GetMatchById"); return(RedirectToAction("InfoError", "Error")); } SelectList sports = new SelectList(betListProvider.GetSports(), "SportId", "Name", match.SportId); if (sports == null) { log.Error("Controller: Match, Action: EditMatch Don't GetSports"); return(RedirectToAction("InfoError", "Error")); } ViewBag.Sports = sports; int selected = match.Tournament.TournamentId; SelectList tournaments = new SelectList(betListProvider.GetTournamentes(), "TournamentId", "Name", selected); if (tournaments == null) { log.Error("Controller: Match, Action: EditMatch Don't GetTournamentes"); return(RedirectToAction("InfoError", "Error")); } ViewBag.Tournaments = betListProvider.GetTournamentes(); IReadOnlyList <Team> teamsAll = teamProvider.GetTeamsAll(); if (teamsAll == null) { log.Error("Controller: Match, Action: EditMatch Don't GetTeamsAll"); return(RedirectToAction("InfoError", "Error")); } selected = match.Teams[0].TeamId; SelectList teamsHome = new SelectList(teamsAll, "TeamId", "Name", selected); ViewBag.TeamsHome = teamsHome; selected = match.Teams[1].TeamId; SelectList teamsGuest = new SelectList(teamsAll, "TeamId", "Name", selected); ViewBag.TeamsGuest = teamsGuest; selected = match.Result.ResultId; SelectList results = new SelectList(matchProvider.GetResultsAll(), "ResultId", "Name", selected); if (results == null) { log.Error("Controller: Match, Action: EditMatch Don't GetResultsAll"); return(RedirectToAction("InfoError", "Error")); } ViewBag.Results = results; return(View(match)); }