public ActionResult Create(Matches matches) { try { // To validate Winner is one of the selected player if (matches.WinnerID == matches.Player1ID || matches.WinnerID == matches.Player2ID) { if (ModelState.IsValid) { MatchesDBContext matchesDBContext = new MatchesDBContext(); int MatchID = matchesDBContext.InsertMatchDetails(matches); matches.MatchID = MatchID; ScoresDBContext scoresDBContext = new ScoresDBContext(); int result = scoresDBContext.InsertScores(matches); if (result == 1 || result == -1) { return(RedirectToAction("Save")); } } return(RedirectToAction("Index")); } else { matches.playerNames = getPlayersList(); return(View(matches)); } } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Matches", "Create"))); } }