public ActionResult Create(_League model, FormCollection fc) { Return cR = new Return(); FantasyTeam modelFantasyTeam = new FantasyTeam(); string errMsg = ""; string leagueType = "public"; string errType = "League"; int rowNum = 0; try { //Get connection dbconAPP = GetConnection(); dbconAPP.Open(); //Get league public or private type ViewBag.LeaguePrivate = "false"; var test = fc["isPrivate"].ToString(); if (fc["isPrivate"].ToString() == "false") { ViewBag.LeaguePrivate = "false"; model.cLeague.isPublic = true; leagueType = "public"; } else { ViewBag.LeaguePrivate = "true"; model.cLeague.isPublic = false; leagueType = "private"; } //Assign password model.cLeague.Password = fc["lPwd"].ToString(); //Get all league stat types and their values //need to think of a solution for when a user enters //a comma within the input value List <string> listStatName = new List <string>(); listStatName = fc["StatTypeName"].Split(',').ToList(); List <string> listStatCode = new List <string>(); listStatCode = fc["StatTypeCode"].Split(',').ToList(); List <string> listStatID = new List <string>(); listStatID = fc["StatTypeID"].Split(',').ToList(); List <string> listStatDesc = new List <string>(); listStatDesc = fc["StatTypeDesc"].Split(',').ToList(); List <string> listStatValue = new List <string>(); listStatValue = fc["StatTypeValue"].Split(',').ToList(); rowNum = listStatID.Count; model.list_cStatType = new List <StatType>(); for (int i = 0; i < rowNum; i++) { StatType temp = new StatType(); temp.cStatTypeValue = new StatTypeValue(); temp.StatTypeID = Convert.ToInt32(listStatID[i]); temp.Name = listStatName[i]; temp.NameCode = listStatCode[i]; temp.Description = listStatDesc[i]; temp.cStatTypeValue.StatValue = Convert.ToDouble(listStatValue[i]); model.list_cStatType.Add(temp); } //Create the league cR = model.CreateNewLeague(dbconAPP, model); if (cR.ReturnFlag == false) { errMsg += cR.ReturnMsg; return(RedirectToAction("CreateLeague", new { leagueType = leagueType, errMsg = errMsg })); } //Get Fantasy Team info errType = "FantasyTeam"; modelFantasyTeam.UserID = model.cUser.UserID; modelFantasyTeam.LeagueID = model.cLeague.LeagueID; modelFantasyTeam.LeagueName = model.cLeague.LeagueName; } catch (Exception ex) { return(Content("ERROR: " + ex.Message + " (League.Create[POST]).")); } finally { if (dbconAPP != null && dbconAPP.State == System.Data.ConnectionState.Open) { dbconAPP.Close(); } } //if (model.cLeague.isPublic) //{ // //return RedirectToAction("JoinPublicLeague", "Home", new { leagueID = model.cLeague.LeagueID, userID = model.cUser.UserID }); // ViewBag.LeagueType = "public"; //} //else //{ // //return RedirectToAction("JoinPrivateLeague", "Home", new { leagueID = model.cLeague.LeagueID, userID = model.cUser.UserID }); // ViewBag.LeagueType = "private"; //} return(PartialView("_JoinLeague", modelFantasyTeam)); }