public ActionResult NewSeason(int leagueID, int seasonID, int userID, int teamID, DateTime draftDate, DateTime startDate, DateTime endDate) { League model = new League(); string leagueType = ""; try { //Get connection dbconAPP = GetConnection(); dbconAPP.Open(); //Get league info to create season model = model.GetLeagueInfo(dbconAPP, leagueID, seasonID); model.FantasyTeamID = teamID; model.DraftDate = draftDate; model.StartDate = startDate; model.EndDate = endDate; //Create new season using existing league info model.CreateSeason(dbconAPP, model); //Get new season id Season modelSeason = new Season(); model.SeasonID = modelSeason.GetSeasonID(dbconAPP, model); //Get league info for the new season model = model.GetLeagueInfo(dbconAPP, model.LeagueID, model.SeasonID); model.FantasyTeamID = teamID; if (model.isPublic) { leagueType = "public"; } else { leagueType = "private"; } //Disable editing league settings if past season end date if (DateTime.Now > model.EndDate) { ViewBag.SeasonEnded = true; } } catch (Exception ex) { return(RedirectToAction("Index", new { leagueType = leagueType, leagueID = model.LeagueID, seasonID = model.SeasonID, fantasyTeamID = model.FantasyTeamID, errMsg = "ERROR: " + ex.Message + " (League.NewSeason[POST])." })); } finally { if (dbconAPP != null && dbconAPP.State == System.Data.ConnectionState.Open) { dbconAPP.Close(); } } return(RedirectToAction("Index", new { leagueType = leagueType, leagueID = model.LeagueID, seasonID = model.SeasonID, fantasyTeamID = model.FantasyTeamID })); }