private void getAllTeamToTheMainModel(ref GenerateNewSeasonDetailsModel model) { GenerateNewSeasonStandardDetailsModel modelItemDetails = null; DataTable dt = null; int j = 0; try { model.listOfTeams = new List <GenerateNewSeasonStandardDetailsModel>(); paramName = new string[] { "pTpModalidade" }; paramValue = new string[] { model.modeType }; dt = db.executePROC("spGetAllChampionshipItensNewTemporadaByModalidade", paramName, paramValue); for (j = 0; j < dt.Rows.Count; j++) { modelItemDetails = new GenerateNewSeasonStandardDetailsModel(); modelItemDetails.modeType = dt.Rows[j]["TP_MODALIDADE"].ToString(); modelItemDetails.championshipType = dt.Rows[j]["SG_CAMPEONATO"].ToString(); modelItemDetails.typeStandard = Convert.ToInt16(dt.Rows[j]["ID_STANDARD"].ToString()); modelItemDetails.id = Convert.ToInt32(dt.Rows[j]["ITEM_ID"].ToString()); modelItemDetails.name = dt.Rows[j]["ITEM_NAME"].ToString(); modelItemDetails.psnID = dt.Rows[j]["ITEM_PSN"].ToString(); modelItemDetails.poteNumber = Convert.ToInt16(dt.Rows[j]["ITEM_POTE_NUMBER"].ToString()); model.listOfTeams.Add(modelItemDetails); } if (model.modeType == "H2H") { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetAllTeamGenerateNewSeasonH2H", paramName, paramValue); for (j = 0; j < dt.Rows.Count; j++) { modelItemDetails = new GenerateNewSeasonStandardDetailsModel(); modelItemDetails.id = Convert.ToInt32(dt.Rows[j]["ID_TIME"].ToString()); modelItemDetails.name = dt.Rows[j]["NM_TIME"].ToString(); modelItemDetails.typeItem = dt.Rows[j]["DS_TIPO"].ToString(); model.listOfTeams.Add(modelItemDetails); } } } catch { } finally { modelItemDetails = null; dt = null; } }
public ActionResult GenerateNewSeason(FormCollection formHTML) { HttpResponseMessage response = new HttpResponseMessage(); GenerateNewSeasonDetailsModel modelReturnJSON = new GenerateNewSeasonDetailsModel(); GenerateNewSeasonDetailsModel modelReturnView = new GenerateNewSeasonDetailsModel(); StandardGenerateNewSeasonChampionshipLeagueDetailsModel modelLeague = null; StandardGenerateNewSeasonChampionshipCupDetailsModel modelCup = null; GenerateNewSeasonStandardDetailsModel modelTeam = null; GenerateNewSeasonStandardDetailsModel modelTeamDetails = null; string actionForm = "show-settings"; if (formHTML["actionForm"] != null) { actionForm = formHTML["actionForm"].ToLower(); } setViewBagVariables(); ViewBag.inFormScript = "1"; try { modelReturnView = (GenerateNewSeasonDetailsModel)TempData["FullModel"]; if (actionForm == "save-details-championship-league") { modelReturnView.drawDate = Convert.ToDateTime(formHTML["txtDrawDate"]); for (int i = 0; i < modelReturnView.listChampionshipLeagueDetails.Count; i++) { modelLeague = modelReturnView.listChampionshipLeagueDetails[i]; modelLeague.startDate = Convert.ToDateTime(formHTML["txtStartDate-" + modelLeague.championshipType]); modelLeague.totalTeams = Convert.ToInt16(formHTML["txtTotalTeams-" + modelLeague.championshipType]); modelLeague.totalDaysToPlayStage0 = Convert.ToInt16(formHTML["txtDaysStage0-" + modelLeague.championshipType]); modelLeague.totalDaysToPlayPlayoff = Convert.ToInt16(formHTML["txtDaysPlayoff-" + modelLeague.championshipType]); modelLeague.totalRelegate = Convert.ToInt16(formHTML["txtRelegate-" + modelLeague.championshipType]); modelLeague.totalGroups = Convert.ToInt16(formHTML["txtTotalGroups-" + modelLeague.championshipType]); if (formHTML["chkChampionshipActive-" + modelLeague.championshipType] == "on") { modelLeague.hasChampionship = true; } else { modelLeague.hasChampionship = false; } if (formHTML["chkChampionshipByGroup-" + modelLeague.championshipType] == "on") { modelLeague.championship_ByGroup = true; } else { modelLeague.championship_ByGroup = false; } if (formHTML["chkChampionshipGroupsByPots-" + modelLeague.championshipType] == "on") { modelLeague.championship_byGroupPots = true; } else { modelLeague.championship_byGroupPots = false; } if (formHTML["chkChampionshipDoubleRound-" + modelLeague.championshipType] == "on") { modelLeague.championship_DoubleRound = true; } else { modelLeague.championship_DoubleRound = false; } } TempData["actionSuccessfully"] = "Set Up Initial for " + modelReturnJSON.modeType + " for league-mode was saved successfully"; modelReturnView.actionUser = "******"; response = GlobalVariables.WebApiClient.PostAsJsonAsync("GenerateNewSeason", modelReturnView).Result; modelReturnView = response.Content.ReadAsAsync <GenerateNewSeasonDetailsModel>().Result; modelReturnJSON = modelReturnView; } else if (actionForm == "save-details-championship-cup") { for (int i = 0; i < modelReturnView.listChampionshipCupDetails.Count; i++) { modelCup = modelReturnView.listChampionshipCupDetails[i]; modelCup.startDate = Convert.ToDateTime(formHTML["txtStartDate-" + modelCup.championshipType]); modelCup.totalTeams = Convert.ToInt16(formHTML["txtTotalTeams-" + modelCup.championshipType]); modelCup.totalDaysToPlayStage0 = Convert.ToInt16(formHTML["txtDaysStage0-" + modelCup.championshipType]); modelCup.totalDaysToPlayPlayoff = Convert.ToInt16(formHTML["txtDaysPlayoff-" + modelCup.championshipType]); modelCup.totalGroups = Convert.ToInt16(formHTML["txtTotalGroups-" + modelCup.championshipType]); modelCup.totalTeamsPreCup = Convert.ToInt16(formHTML["txtTotalTeamsPreCup-" + modelCup.championshipType]); if (formHTML["chkChampionshipActive-" + modelCup.championshipType] == "on") { modelCup.hasChampionship = true; } else { modelCup.hasChampionship = false; } if (formHTML["chkChampionshipByGroup-" + modelCup.championshipType] == "on") { modelCup.championship_ByGroup = true; } else { modelCup.championship_ByGroup = false; } if (formHTML["chkChampionshipGroupsByPots-" + modelCup.championshipType] == "on") { modelCup.championship_byGroupPots = true; } else { modelCup.championship_byGroupPots = false; } if (formHTML["chkChampionshipJustSerieA-" + modelCup.championshipType] == "on") { modelCup.hasJust_SerieA = true; } else { modelCup.hasJust_SerieA = false; } if (formHTML["chkChampionshipJustSerieB-" + modelCup.championshipType] == "on") { modelCup.hasJust_SerieB = true; } else { modelCup.hasJust_SerieB = false; } if (formHTML["chkChampionshipJustSerieC-" + modelCup.championshipType] == "on") { modelCup.hasJust_SerieC = true; } else { modelCup.hasJust_SerieC = false; } if (formHTML["chkChampionshipSerieA_B-" + modelCup.championshipType] == "on") { modelCup.has_SerieA_B = true; } else { modelCup.has_SerieA_B = false; } if (formHTML["chkChampionshipSerieA_B_C-" + modelCup.championshipType] == "on") { modelCup.has_SerieA_B_C_D = true; } else { modelCup.has_SerieA_B_C_D = false; } if (formHTML["chkChampionshipNationalTeams-" + modelCup.championshipType] == "on") { modelCup.has_NationalTeams = true; } else { modelCup.has_NationalTeams = false; } if (formHTML["chkChampionshipDestiny-" + modelCup.championshipType] == "on") { modelCup.hasChampionshipDestiny = true; } else { modelCup.hasChampionshipDestiny = false; } if (formHTML["chkChampionshipSource-" + modelCup.championshipType] == "on") { modelCup.hasChampionshipSource = true; } else { modelCup.hasChampionshipSource = false; } } TempData["actionSuccessfully"] = "Set Up Initial for " + modelReturnJSON.modeType + " for cup-mode was saved successfully"; modelReturnView.actionUser = "******"; response = GlobalVariables.WebApiClient.PostAsJsonAsync("GenerateNewSeason", modelReturnView).Result; modelReturnView = response.Content.ReadAsAsync <GenerateNewSeasonDetailsModel>().Result; modelReturnJSON = modelReturnView; } else if (actionForm == "delete-team") { modelReturnView.championshipType = formHTML["championshipType"]; modelReturnView.itemID = Convert.ToInt32(formHTML["itemID"]); modelReturnView.itemName = formHTML["itemName"]; modelReturnView.actionUser = "******"; response = GlobalVariables.WebApiClient.PostAsJsonAsync("GenerateNewSeason", modelReturnView).Result; modelReturnView = response.Content.ReadAsAsync <GenerateNewSeasonDetailsModel>().Result; TempData["actionSuccessfully"] = "The team (" + modelReturnView.itemName + ") was deleted successfully from " + modelReturnView.championshipType; modelReturnJSON = modelReturnView; } else if (actionForm == "add-team") { modelReturnView.championshipType = formHTML["txtChampionshipType"]; modelReturnView.itemID = Convert.ToInt32(formHTML["txtTeam"]); modelReturnView.poteNumber = Convert.ToInt16(formHTML["txtPotNumber"]); TempData["actionSuccessfully"] = "The team (" + modelReturnView.itemName + ") was added successfully to " + modelReturnView.championshipType; modelReturnView.actionUser = "******"; response = GlobalVariables.WebApiClient.PostAsJsonAsync("GenerateNewSeason", modelReturnView).Result; modelReturnView = response.Content.ReadAsAsync <GenerateNewSeasonDetailsModel>().Result; modelReturnJSON = modelReturnView; } else { modelReturnJSON.returnMessage = "GenerateNewSeasonSuccessfully"; modelReturnJSON.actionUser = actionForm.ToUpper(); response.StatusCode = HttpStatusCode.Created; } switch (response.StatusCode) { case HttpStatusCode.Created: if (modelReturnJSON.returnMessage == "GenerateNewSeasonSuccessfully") { //nothing to do } else { TempData["returnMessage"] = "Some error occurred when the system was trying to show the view: Generate New Season - Set Up Initial. (" + modelReturnJSON.returnMessage + ")"; } return(View(modelReturnJSON)); default: TempData["returnMessage"] = "Some error occurred when the system was trying to show the view: Generate New Season - Set Up Initial. (" + response.StatusCode + ")"; ModelState.AddModelError("", "application error."); return(View(modelReturnJSON)); } } catch (Exception ex) { TempData["returnMessage"] = "Internal error - when the system was trying to show the view: Generate New Season - Set Up Initial. (" + ex.Message + ")"; ModelState.AddModelError("", "application error."); return(View(modelReturnView)); } finally { response = null; modelReturnJSON = null; modelReturnView = null; modelLeague = null; modelCup = null; modelTeam = null; modelTeamDetails = null; } }