private List <ChampionshipTeamTableDetailsModel> getListTeamTableByChampionship(int id, connectionMySQL db) { ChampionshipTeamTableDetailsModel modelDetails = new ChampionshipTeamTableDetailsModel(); List <ChampionshipTeamTableDetailsModel> listOfModel = new List <ChampionshipTeamTableDetailsModel>(); DataTable dt = null; try { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(id) }; dt = db.executePROC("spGetFirstClassificacaoTimeOfCampeonatoForSummary", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipTeamTableDetailsModel(); modelDetails.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString()); modelDetails.teamName = dt.Rows[i]["NM_TIME"].ToString(); modelDetails.teamType = dt.Rows[i]["DS_TIPO"].ToString(); modelDetails.totalPoint = Convert.ToInt16(dt.Rows[i]["QT_PONTOS_GANHOS"].ToString()); modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString(); listOfModel.Add(modelDetails); } return(listOfModel); } catch (Exception ex) { listOfModel = new List <ChampionshipTeamTableDetailsModel>(); return(listOfModel); } finally { dt = null; listOfModel = null; modelDetails = null; } }
public IHttpActionResult getPost(CurrentSeasonSummaryViewModel model) { CurrentSeasonSummaryViewModel CurrentSeasonModel = new CurrentSeasonSummaryViewModel(); CurrentSeasonMenuViewModel MenuModel = new CurrentSeasonMenuViewModel(); ChampionshipTeamTableDetailsModel teamTableDetailsModel = new ChampionshipTeamTableDetailsModel(); db.openConnection(); DataTable dt = null; string returnMessage = String.Empty; StringBuilder strConcat = new StringBuilder(); try { CurrentSeasonModel.listOfScorersH2H = new List <listScorers>(); CurrentSeasonModel.listOfScorersPRO = new List <listScorers>(); CurrentSeasonModel.listOfTeamTableSerieA = new List <ChampionshipTeamTableDetailsModel>(); CurrentSeasonModel.listOfTeamTableSerieB = new List <ChampionshipTeamTableDetailsModel>(); CurrentSeasonModel.userID = model.userID; CurrentSeasonModel.modeType = model.modeType; CurrentSeasonModel.actionUser = model.actionUser; CurrentSeasonModel.championshipID = model.championshipID; if (model.actionUser == "summary") { CurrentSeasonModel.menuCurrentSeason = getDetailsMenu(CurrentSeasonModel.modeType, CurrentSeasonModel.userID, 0, db); paramName = new string[] { "pType" }; paramValue = new string[] { model.modeType }; dt = db.executePROC("spGetSummaryCurrentSeason", paramName, paramValue); CurrentSeasonModel.modeType = model.modeType; if (dt.Rows.Count > 0) { CurrentSeasonModel.totalGoals = Convert.ToInt16(dt.Rows[0]["totalGoals"].ToString()); CurrentSeasonModel.totalMatches = Convert.ToInt16(dt.Rows[0]["totalMatches"].ToString()); CurrentSeasonModel.averageGoals = Convert.ToInt16(dt.Rows[0]["averageGoals"].ToString()); if (CurrentSeasonModel.modeType == "H2H") { CurrentSeasonModel.listOfScorersH2H = GlobalFunctions.getListScorers("H2H", db, 0); } else if (CurrentSeasonModel.modeType == "PRO") { CurrentSeasonModel.listOfScorersPRO = GlobalFunctions.getListScorers("PRO", db, 0); } if (CurrentSeasonModel.menuCurrentSeason.championshipSerieAID > 0 && CurrentSeasonModel.menuCurrentSeason.championshipSerieAForGroup == 0) { CurrentSeasonModel.listOfTeamTableSerieA = getListTeamTableByChampionship(CurrentSeasonModel.menuCurrentSeason.championshipSerieAID, db); } if (CurrentSeasonModel.menuCurrentSeason.championshipSerieBID > 0 && CurrentSeasonModel.menuCurrentSeason.championshipSerieBForGroup == 0) { CurrentSeasonModel.listOfTeamTableSerieB = getListTeamTableByChampionship(CurrentSeasonModel.menuCurrentSeason.championshipSerieBID, db); } CurrentSeasonModel.menuCurrentSeason.listOActiveChampionship = GlobalFunctions.getAllActiveChampionshipCurrentSeason(db, CurrentSeasonModel.menuCurrentSeason.currentChampionshipID, CurrentSeasonModel.modeType); CurrentSeasonModel.menuCurrentSeason.currentChampionshipDetails = GlobalFunctions.getChampionshipDetails(db, CurrentSeasonModel.menuCurrentSeason.currentChampionshipID); CurrentSeasonModel.returnMessage = "CurrentSeasonSuccessfully"; } else { CurrentSeasonModel.returnMessage = "CurrentSeasonNotFound"; } return(CreatedAtRoute("DefaultApi", new { id = 0 }, CurrentSeasonModel)); } else if (model.actionUser == "summary_update_team") { model.menuCurrentSeason = getDetailsMenu(CurrentSeasonModel.modeType, model.userID, model.championshipID, db); model.menuCurrentSeason.listOActiveChampionship = GlobalFunctions.getAllActiveChampionshipCurrentSeason(db, model.championshipID, model.modeType); model.menuCurrentSeason.currentChampionshipDetails = GlobalFunctions.getChampionshipDetails(db, model.championshipID); model.returnMessage = "CurrentSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "just_menu") { MenuModel = getDetailsMenu(CurrentSeasonModel.modeType, CurrentSeasonModel.userID, 0, db); return(CreatedAtRoute("DefaultApi", new { id = 0 }, MenuModel)); } else if (model.actionUser == "getAllForecastSecondStage") { CurrentSeasonModel.listOfForecastTeamQualified = new List <ChampionshipTeamTableDetailsModel>(); CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace = new List <ChampionshipTeamTableDetailsModel>(); for (int j = 1; j <= model.totalGroupPerChampionship; j++) { paramName = new string[] { "pIdCamp", "pIdGrupo", "pTotalQualified" }; paramValue = new string[] { model.championshipID.ToString(), j.ToString(), model.totalQualifiedPerGroup.ToString() }; dt = db.executePROC("spGetAllClassificacaoTimeOfCampeonatoByGrupo", paramName, paramValue); for (int i = 0; i < dt.Rows.Count; i++) { teamTableDetailsModel = new ChampionshipTeamTableDetailsModel(); teamTableDetailsModel.teamID = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString()); CurrentSeasonModel.listOfForecastTeamQualified.Add(teamTableDetailsModel); } } if (CurrentSeasonModel.listOfForecastTeamQualified.Count > 0) { strConcat.Clear(); foreach (ChampionshipTeamTableDetailsModel item in CurrentSeasonModel.listOfForecastTeamQualified) { if (strConcat.ToString() != string.Empty) { strConcat.Append(","); } strConcat.Append(item.teamID.ToString()); } CurrentSeasonModel.listOfForecastTeamQualified = new List <ChampionshipTeamTableDetailsModel>(); paramName = new string[] { "pIdCamp", "pIdsTime" }; paramValue = new string[] { model.championshipID.ToString(), strConcat.ToString() }; dt = db.executePROC("spGetLoadClassificacaoTimeOfCampeonato", paramName, paramValue); for (int i = 0; i < dt.Rows.Count; i++) { teamTableDetailsModel = new ChampionshipTeamTableDetailsModel(); teamTableDetailsModel.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString()); teamTableDetailsModel.teamID = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString()); teamTableDetailsModel.groupID = Convert.ToInt16(dt.Rows[i]["ID_GRUPO"].ToString()); teamTableDetailsModel.totalPoint = Convert.ToInt16(dt.Rows[i]["QT_PONTOS_GANHOS"].ToString()); teamTableDetailsModel.totalPlayed = Convert.ToInt16(dt.Rows[i]["QT_JOGOS"].ToString()); teamTableDetailsModel.teamName = dt.Rows[i]["NM_TIME"].ToString(); teamTableDetailsModel.teamType = dt.Rows[i]["DS_TIPO"].ToString(); teamTableDetailsModel.userName = dt.Rows[i]["NM_USUARIO"].ToString(); teamTableDetailsModel.psnID = dt.Rows[i]["PSN_ID"].ToString(); CurrentSeasonModel.listOfForecastTeamQualified.Add(teamTableDetailsModel); } } if (model.placeQualifiedPerGroup > 0) { for (int j = 1; j <= model.totalGroupPerChampionship; j++) { paramName = new string[] { "pIdCamp", "pIdGrupo", "pTotalQualified" }; paramValue = new string[] { model.anotherChampionshipID.ToString(), j.ToString(), model.placeQualifiedPerGroup.ToString() }; dt = db.executePROC("spGetAllClassificacaoTimeOfCampeonato", paramName, paramValue); for (int i = 0; i < dt.Rows.Count; i++) { if (i == (model.placeQualifiedPerGroup - 1)) { teamTableDetailsModel = new ChampionshipTeamTableDetailsModel(); teamTableDetailsModel.teamID = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString()); CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace.Add(teamTableDetailsModel); } } } if (CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace.Count > 0) { strConcat.Clear(); foreach (ChampionshipTeamTableDetailsModel item in CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace) { if (strConcat.ToString() != string.Empty) { strConcat.Append(","); } else { strConcat.Append(item.teamID.ToString()); } } CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace = new List <ChampionshipTeamTableDetailsModel>(); paramName = new string[] { "pIdCamp", "pIdsTime" }; paramValue = new string[] { model.anotherChampionshipID.ToString(), strConcat.ToString() }; dt = db.executePROC("spGetLoadClassificacaoTimeOfCampeonato", paramName, paramValue); for (int i = 0; i < dt.Rows.Count; i++) { teamTableDetailsModel = new ChampionshipTeamTableDetailsModel(); teamTableDetailsModel.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString()); teamTableDetailsModel.teamID = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString()); teamTableDetailsModel.groupID = Convert.ToInt16(dt.Rows[i]["ID_GRUPO"].ToString()); teamTableDetailsModel.totalPoint = Convert.ToInt16(dt.Rows[i]["QT_PONTOS_GANHOS"].ToString()); teamTableDetailsModel.totalPlayed = Convert.ToInt16(dt.Rows[i]["QT_JOGOS"].ToString()); teamTableDetailsModel.teamName = dt.Rows[i]["NM_TIME"].ToString(); teamTableDetailsModel.teamType = dt.Rows[i]["DS_TIPO"].ToString(); teamTableDetailsModel.userName = dt.Rows[i]["NM_USUARIO"].ToString(); teamTableDetailsModel.psnID = dt.Rows[i]["PSN_ID"].ToString(); CurrentSeasonModel.listOfForecastTeamQualifiedThirdPlace.Add(teamTableDetailsModel); } } } CurrentSeasonModel.returnMessage = "CurrentSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, CurrentSeasonModel)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { CurrentSeasonModel.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, CurrentSeasonModel)); } finally { db.closeConnection(); dt = null; CurrentSeasonModel = null; MenuModel = null; teamTableDetailsModel = null; strConcat = null; } }
public IHttpActionResult GetAllForChampionship(int id) { ChampionshipTeamTableDetailsModel modelDetails = new ChampionshipTeamTableDetailsModel(); ChampionshipTeamTableListViewModel mainModel = new ChampionshipTeamTableListViewModel(); List <ChampionshipTeamTableDetailsModel> listOfModel = new List <ChampionshipTeamTableDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(id) }; dt = db.executePROC("spGetAllClassificacaoTimeOfCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipTeamTableDetailsModel(); modelDetails.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString()); modelDetails.teamID = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString()); modelDetails.groupID = Convert.ToInt16(dt.Rows[i]["ID_GRUPO"].ToString()); modelDetails.totalPoint = Convert.ToInt16(dt.Rows[i]["QT_PONTOS_GANHOS"].ToString()); modelDetails.totalWon = Convert.ToInt16(dt.Rows[i]["QT_VITORIAS"].ToString()); modelDetails.totalPlayed = Convert.ToInt16(dt.Rows[i]["QT_JOGOS"].ToString()); modelDetails.totalDraw = Convert.ToInt16(dt.Rows[i]["QT_EMPATES"].ToString()); modelDetails.totalLost = Convert.ToInt16(dt.Rows[i]["QT_DERROTAS"].ToString()); modelDetails.totalGoalsFOR = Convert.ToInt16(dt.Rows[i]["QT_GOLS_PRO"].ToString()); modelDetails.totalGoalsAGainst = Convert.ToInt16(dt.Rows[i]["QT_GOLS_CONTRA"].ToString()); if (!String.IsNullOrEmpty(dt.Rows[i]["IN_ORDENACAO_GRUPO"].ToString())) { modelDetails.orden = Convert.ToInt16(dt.Rows[i]["IN_ORDENACAO_GRUPO"].ToString()); } if (dt.Rows[i]["DS_TIPO"].ToString().IndexOf("PRO") > -1 || dt.Rows[i]["DS_TIPO"].ToString().IndexOf("FUT") > -1) { modelDetails.teamName = GlobalFunctions.UppercaseFirstWords(dt.Rows[i]["NM_TIME"].ToString()); } else { modelDetails.teamName = dt.Rows[i]["NM_TIME"].ToString(); } modelDetails.teamType = dt.Rows[i]["DS_TIPO"].ToString(); modelDetails.teamURL = dt.Rows[i]["DS_URL_TIME"].ToString(); modelDetails.userID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); modelDetails.userName = dt.Rows[i]["NM_USUARIO"].ToString(); modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString(); if (!String.IsNullOrEmpty(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString())) { modelDetails.deletedCurrentSeason = Convert.ToInt16(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString()); } if (!String.IsNullOrEmpty(dt.Rows[i]["PosicaoAnterior"].ToString())) { modelDetails.previousPosition = Convert.ToInt16(dt.Rows[i]["PosicaoAnterior"].ToString()); } listOfModel.Add(modelDetails); } mainModel.listOfTeamTable = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new ChampionshipTeamTableListViewModel(); mainModel.listOfTeamTable = new List <ChampionshipTeamTableDetailsModel>(); mainModel.returnMessage = "errorGetAllTeamTableForChampionship_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }