public IHttpActionResult actionPost(ChampionshipCommentMatchDetailsModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser.ToLower() == "save_comment") { paramName = new string[] { "pIdJogo", "pIdUsu", "pDsComentario" }; paramValue = new string[] { Convert.ToString(model.matchID), Convert.ToString(model.userID), model.comment }; dt = db.executePROC("spAddComentarioJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorPostChampionshipCommentMatch_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult GenerateStage(ChampionshipStageListViewModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser.ToLower() == "generate_stage_playoff_from_playoff") { paramName = new string[] { "pIdCamp", "pIdFase", "pIdPreviousFase", "pDtInicioFase" }; paramValue = new string[] { Convert.ToString(model.championshipID), Convert.ToString(model.stageID), Convert.ToString(model.previousStageID), model.startStageDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]" }; dt = db.executePROC("spGenerateFasePlayOffFromPlayOff", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "generate_stage_playoff_from_stage0") { paramName = new string[] { "pIdCamp", "pIdFase", "pDtInicioFase" }; paramValue = new string[] { Convert.ToString(model.championshipID), Convert.ToString(model.stageID), model.startStageDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]" }; dt = db.executePROC("spGenerateFasePlayOffFromStage0", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "generate_stage_playoff_from_qualify1") { paramName = new string[] { "pIdCamp", "pIdFase", "pDtInicioFase" }; paramValue = new string[] { Convert.ToString(model.championshipID), Convert.ToString(model.stageID), model.startStageDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]" }; dt = db.executePROC("spGenerateFasePlayOffFromStageQualify1", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorPostChampionshipMatchTable_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult GetAllByChampionship(int id) { UserTeamDetailsModel modelDetails = new UserTeamDetailsModel(); UserTeamViewModel mainModel = new UserTeamViewModel(); List <UserTeamDetailsModel> listOfModel = new List <UserTeamDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { id.ToString() }; dt = db.executePROC("spGetAllUsuarioTimeOfCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new UserTeamDetailsModel(); modelDetails.championshipID = id; modelDetails.userID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); modelDetails.teamID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); modelDetails.userName = dt.Rows[i]["NM_USUARIO"].ToString(); modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString(); modelDetails.teamName = dt.Rows[i]["NM_TIME"].ToString(); modelDetails.teamType = dt.Rows[i]["DS_TIPO"].ToString(); listOfModel.Add(modelDetails); } if (dt.Rows.Count > 0) { mainModel.drawDone = 1; } else { mainModel.drawDone = 0; } mainModel.listOfUserTeam = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new UserTeamViewModel(); mainModel.listOfUserTeam = new List <UserTeamDetailsModel>(); mainModel.returnMessage = "errorGetAllChampionshipUser_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }
public static List <ChampionshipMatchTableDetailsModel> getListOfMatchForMyMatches(string typeMyMatches, connectionMySQL db, int teamID, int nationalTeamID, out string returnMessage) { ChampionshipMatchTableDetailsModel modelDetails = new ChampionshipMatchTableDetailsModel(); List <ChampionshipMatchTableDetailsModel> listOfModel = new List <ChampionshipMatchTableDetailsModel>(); DataTable dt = null; string[] paramName = null; string[] paramValue = null; try { paramName = new string[] { "pTypeMyMactches", "pIdTime", "pIdSelecao" }; paramValue = new string[] { typeMyMatches, teamID.ToString(), nationalTeamID.ToString() }; dt = db.executePROC("spGetTabelaJogoAllDetailsForMyMatches", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipMatchTableDetailsModel(); modelDetails.matchID = Convert.ToInt32(dt.Rows[i]["ID_TABELA_JOGO"].ToString()); modelDetails.championshipID = Convert.ToInt32(dt.Rows[i]["ID_CAMPEONATO"].ToString()); modelDetails.championshipName = dt.Rows[i]["NM_CAMPEONATO"].ToString(); modelDetails.stageID = Convert.ToInt16(dt.Rows[i]["ID_FASE"].ToString()); modelDetails.stageName = dt.Rows[i]["NM_FASE"].ToString(); modelDetails.startDate = Convert.ToDateTime(dt.Rows[i]["DT_TABELA_INICIO_JOGO"].ToString()); modelDetails.endDate = Convert.ToDateTime(dt.Rows[i]["DT_TABELA_FIM_JOGO"].ToString()); modelDetails.teamHomeID = Convert.ToInt16(dt.Rows[i]["ID_TIME_CASA"].ToString()); modelDetails.totalGoalsHome = dt.Rows[i]["QT_GOLS_TIME_CASA"].ToString(); modelDetails.teamAwayID = Convert.ToInt16(dt.Rows[i]["ID_TIME_VISITANTE"].ToString()); modelDetails.totalGoalsAway = dt.Rows[i]["QT_GOLS_TIME_VISITANTE"].ToString(); modelDetails.round = Convert.ToInt16(dt.Rows[i]["IN_NUMERO_RODADA"].ToString()); modelDetails.teamNameHome = dt.Rows[i]["1T"].ToString(); modelDetails.teamTypeHome = dt.Rows[i]["DT1"].ToString(); modelDetails.psnIDHome = dt.Rows[i]["PSN1"].ToString(); modelDetails.teamNameAway = dt.Rows[i]["2T"].ToString(); modelDetails.teamTypeAway = dt.Rows[i]["DT2"].ToString(); modelDetails.psnIDAway = dt.Rows[i]["PSN2"].ToString(); modelDetails.userHomeID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO_TIME_CASA"].ToString()); modelDetails.userAwayID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO_TIME_VISITANTE"].ToString()); listOfModel.Add(modelDetails); } returnMessage = "MyMatchesSuccessfully"; return(listOfModel); } catch (Exception ex) { returnMessage = "Erro na execução da procedure Lista " + typeMyMatches + " My Matches - Próximos Jogos: (" + ex.InnerException.Message + ")";; return(listOfModel); } finally { modelDetails = null; listOfModel = null; dt = null; } }
public IHttpActionResult season(SeasonModesViewModel model) { db.openConnection(); DataTable dt = null; SeasonDetails seasonDetails = new SeasonDetails(); try { if (model.actionUser == "add") { model.returnMessage = "subscribeBenchSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "current") { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetIDCurrentTemporada", paramName, paramValue); SetDetailsSeason(dt, seasonDetails); seasonDetails.returnMessage = "subscribeBenchSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, seasonDetails)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model = new SeasonModesViewModel(); model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; seasonDetails = null; } }
public IHttpActionResult postRequest(ScorerMatchViewModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser == "save_all_by_match") { paramName = new string[] { "pIdCamp", "pIdJogo", "pIdsGoleadorHome", "pQtGolsGoleadorHome", "pIdsGoleadorAway", "pQtGolsGoleadorAway" }; paramValue = new string[] { Convert.ToString(model.championshipID), Convert.ToString(model.matchID), model.loadScorersIDHome, model.loadScorersGoalsHome, model.loadScorersIDAway, model.loadScorersGoalsAway }; dt = db.executePROC("spAddLoadGoleadorJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "delete_all_by_match") { paramName = new string[] { "pIdJogo" }; paramValue = new string[] { Convert.ToString(model.matchID) }; dt = db.executePROC("spDeleteAllGoleadorJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorScorerMatch_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public static List <ChampionshipDetailsModel> getAllActiveChampionshipCurrentSeason(connectionMySQL db, int championshipID, string modeType) { ChampionshipDetailsModel modelDetails = new ChampionshipDetailsModel(); List <ChampionshipDetailsModel> listOfModel = new List <ChampionshipDetailsModel>(); DataTable dt = null; string[] paramName = null; string[] paramValue = null; try { paramName = new string[] { "pIdTemporada" }; paramValue = new string[] { "0" }; dt = db.executePROC("spGetAllCampeonatosActiveOfTemporada", paramName, paramValue); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["ID_CAMPEONATO"].ToString() != championshipID.ToString() && (dt.Rows[i]["MODE_TYPE"].ToString() == modeType || modeType == String.Empty)) { modelDetails = new ChampionshipDetailsModel(); modelDetails.id = Convert.ToInt32(dt.Rows[i]["ID_CAMPEONATO"].ToString()); modelDetails.seasonID = Convert.ToInt32(dt.Rows[i]["ID_TEMPORADA"].ToString()); modelDetails.seasonName = dt.Rows[i]["NM_TEMPORADA"].ToString(); modelDetails.name = dt.Rows[i]["NM_CAMPEONATO"].ToString(); modelDetails.type = dt.Rows[i]["SG_TIPO_CAMPEONATO"].ToString(); modelDetails.modeType = dt.Rows[i]["MODE_TYPE"].ToString(); modelDetails.totalTeam = Convert.ToInt32(dt.Rows[i]["QT_TIMES"].ToString()); modelDetails.startDate = Convert.ToDateTime(dt.Rows[i]["DT_INICIO"].ToString()); modelDetails.drawDate = Convert.ToDateTime(dt.Rows[i]["DT_SORTEIO"].ToString()); modelDetails.active = Convert.ToBoolean(dt.Rows[i]["IN_CAMPEONATO_ATIVO"].ToString()); listOfModel.Add(modelDetails); } } return(listOfModel); } catch (Exception ex) { return(listOfModel); } finally { modelDetails = null; listOfModel = null; dt = null; paramName = null; paramValue = null; } }
public static List <listScorers> getListScorers(string typeMode, connectionMySQL db, int userID = 0, Boolean isSummary = true, int championshiID = 0) { List <listScorers> modelList = new List <listScorers>(); listScorers listScorers = new listScorers(); DataTable dt = null; string[] paramName = null; string[] paramValue = null; string returnMessage = String.Empty; try { paramName = new string[] { "pMode", "pIdUsu", "pInSummary", "pIdCamp" }; paramValue = new string[] { typeMode, userID.ToString(), isSummary.ToString() + ";[BOOLEAN-TYPE]", championshiID.ToString() }; dt = db.executePROC("spGetSummaryRankingListScorers", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { listScorers = new listScorers(); listScorers.playerID = Convert.ToInt32(dt.Rows[i]["ID_GOLEADOR"].ToString()); listScorers.playerName = dt.Rows[i]["NM_GOLEADOR"].ToString(); listScorers.playerFullName = dt.Rows[i]["NM_GOLEADOR_COMPLETO"].ToString(); listScorers.psnID = dt.Rows[i]["PSN_ID"].ToString(); if (!String.IsNullOrEmpty(dt.Rows[i]["DS_Tipo"].ToString())) { listScorers.teamName = dt.Rows[i]["NM_TIME"].ToString() + "-" + dt.Rows[i]["DS_Tipo"].ToString(); } else { listScorers.teamName = dt.Rows[i]["NM_TIME"].ToString(); } listScorers.totalGoals = Convert.ToInt16(dt.Rows[i]["QT_GOLS_MARCADOS"].ToString()); modelList.Add(listScorers); } return(modelList); } catch (Exception ex) { returnMessage = "Erro na execução da procedure Lista de Artilheiros " + typeMode + ": (" + ex.InnerException.Message + ")";; modelList = new List <listScorers>(); return(modelList); } finally { modelList = null; listScorers = null; dt = null; } }
public IHttpActionResult GetAllByChampionship(int id) { ChampionshipTeamDetailsModel modelDetails = new ChampionshipTeamDetailsModel(); ChampionshipTeamListViewModel mainModel = new ChampionshipTeamListViewModel(); List <ChampionshipTeamDetailsModel> listOfModel = new List <ChampionshipTeamDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(id) }; dt = db.executePROC("spGetAllTimesOfCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipTeamDetailsModel(); modelDetails.id = Convert.ToInt32(dt.Rows[i]["ID_TIME"].ToString()); modelDetails.name = dt.Rows[i]["NM_TIME"].ToString(); modelDetails.type = dt.Rows[i]["DS_TIPO"].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(); listOfModel.Add(modelDetails); } mainModel.listOfTeam = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new ChampionshipTeamListViewModel(); mainModel.listOfTeam = new List <ChampionshipTeamDetailsModel>(); mainModel.returnMessage = "errorGetAllChampionshipTeam_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }
public static MyMatchesTotalModel getMyMatchesTotal(string typeMode, string typeMyMatches, connectionMySQL db, int userID) { MyMatchesTotalModel myMatchesTotal = new MyMatchesTotalModel(); DataTable dt = null; string[] paramName = null; string[] paramValue = null; try { paramName = new string[] { "pTypeMode", "pTypeMyMactches", "pIdUsu" }; paramValue = new string[] { typeMode, typeMyMatches, userID.ToString() }; dt = db.executePROC("spGetTotalsMyMatches", paramName, paramValue); if (dt.Rows.Count > 0) { myMatchesTotal.totalGoals = Convert.ToInt32(dt.Rows[0]["totalGoals"].ToString()); myMatchesTotal.totalGoalsFor = Convert.ToInt32(dt.Rows[0]["totalGoalsFOR"].ToString()); myMatchesTotal.totalGoalsAgainst = Convert.ToInt32(dt.Rows[0]["totalGoalsAGAINST"].ToString()); myMatchesTotal.totalMatchToPlay = Convert.ToInt32(dt.Rows[0]["totalMatchesToPlay"].ToString()); myMatchesTotal.totalMatchDelayed = Convert.ToInt32(dt.Rows[0]["totalMatchesDelayed"].ToString()); myMatchesTotal.totalMatches = Convert.ToInt32(dt.Rows[0]["totalMatches"].ToString()); myMatchesTotal.totalWins = Convert.ToInt32(dt.Rows[0]["totalWins"].ToString()); myMatchesTotal.totalLosses = Convert.ToInt32(dt.Rows[0]["totalLosses"].ToString()); myMatchesTotal.teamNameH2H = dt.Rows[0]["teamNameH2H"].ToString(); myMatchesTotal.nationalTeamNameCPDM = dt.Rows[0]["nationalTeamName"].ToString(); myMatchesTotal.teamNameFUT = dt.Rows[0]["teamNameFUT"].ToString(); myMatchesTotal.teamNamePRO = dt.Rows[0]["teamNamePRO"].ToString(); myMatchesTotal.teamIDH2H = Convert.ToInt32(dt.Rows[0]["teamIDH2H"].ToString()); myMatchesTotal.teamIDFUT = Convert.ToInt32(dt.Rows[0]["teamIDFUT"].ToString()); myMatchesTotal.teamIDPRO = Convert.ToInt32(dt.Rows[0]["teamIDPRO"].ToString()); myMatchesTotal.natonalTeamIDCPDM = Convert.ToInt32(dt.Rows[0]["nationalTeamID"].ToString()); } myMatchesTotal.returnMessage = "MyMatchesSuccessfully"; return(myMatchesTotal); } catch (Exception ex) { myMatchesTotal.returnMessage = "Erro na execução da procedure Total My Matches - Próximos Jogos " + typeMode + ": (" + ex.InnerException.Message + ")";; return(myMatchesTotal); } finally { myMatchesTotal = null; dt = null; } }
public IHttpActionResult GetAll() { ChampionshipTypeDetailsModel modelDetails = new ChampionshipTypeDetailsModel(); ChampionshipTypeListViewModel mainModel = new ChampionshipTypeListViewModel(); List <ChampionshipTypeDetailsModel> listOfModel = new List <ChampionshipTypeDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetAllTipoCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipTypeDetailsModel(); modelDetails.id = dt.Rows[i]["SG_TIPO_CAMPEONATO"].ToString(); modelDetails.name = dt.Rows[i]["DS_TIPO_CAMPEONATO"].ToString(); listOfModel.Add(modelDetails); } mainModel.listOfType = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new ChampionshipTypeListViewModel(); mainModel.listOfType = new List <ChampionshipTypeDetailsModel>(); mainModel.returnMessage = "errorGetAllChampionshipType_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }
public IHttpActionResult GetAll() { TeamTypeDetailsModel modelDetails = new TeamTypeDetailsModel(); TeamTypeListViewModel mainModel = new TeamTypeListViewModel(); List <TeamTypeDetailsModel> listOfModel = new List <TeamTypeDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetAllTiposTime", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new TeamTypeDetailsModel(); modelDetails.id = Convert.ToInt32(dt.Rows[i]["ID_TIPO_TIME"].ToString()); modelDetails.name = dt.Rows[i]["NM_TIPO_TIME"].ToString(); listOfModel.Add(modelDetails); } mainModel.listOfType = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new TeamTypeListViewModel(); mainModel.listOfType = new List <TeamTypeDetailsModel>(); mainModel.returnMessage = "errorGetAllTeamType_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }
public IHttpActionResult GetAllByChampionship(int id) { ChampionshipGroupDetailsModel modelDetails = new ChampionshipGroupDetailsModel(); ChampionshipGroupListViewModel mainModel = new ChampionshipGroupListViewModel(); List <ChampionshipGroupDetailsModel> listOfModel = new List <ChampionshipGroupDetailsModel>(); DataTable dt = null; db.openConnection(); try { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(id) }; dt = db.executePROC("spGetAllGrupoOfCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipGroupDetailsModel(); modelDetails.id = Convert.ToInt16(dt.Rows[i]["ID_GRUPO"].ToString()); modelDetails.name = dt.Rows[i]["NM_GRUPO"].ToString(); listOfModel.Add(modelDetails); } mainModel.listOfGroup = listOfModel; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } catch (Exception ex) { mainModel = new ChampionshipGroupListViewModel(); mainModel.listOfGroup = new List <ChampionshipGroupDetailsModel>(); mainModel.returnMessage = "errorGetAllGroupForChampionship_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } finally { db.closeConnection(); modelDetails = null; mainModel = null; listOfModel = null; dt = null; } }
public static List <squadListModel> getListOfSquadPROCLUB(connectionMySQL db, int seasonID, int managerID, out string returnMessage) { squadListModel modelDetails = new squadListModel(); List <squadListModel> listOfModel = new List <squadListModel>(); DataTable dt = null; string[] paramName = null; string[] paramValue = null; try { paramName = new string[] { "pIdTemporada", "pIdManager" }; paramValue = new string[] { seasonID.ToString(), managerID.ToString() }; dt = db.executePROC("spGetAllSquadOfClub", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new squadListModel(); modelDetails.playerID = Convert.ToInt32(dt.Rows[i]["ID_GOLEADOR"].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 (modelDetails.userID == managerID) { modelDetails.isCapitain = true; } modelDetails.recordDate = dt.Rows[i]["DT_CONFIRMACAO_FORMATADA"].ToString(); listOfModel.Add(modelDetails); } returnMessage = "MyMatchesSuccessfully"; return(listOfModel); } catch (Exception ex) { returnMessage = "Erro na execução da procedure Lista de Elencos do clube para a modalidade PRO CLUB: (" + ex.InnerException.Message + ")";; return(listOfModel); } finally { modelDetails = null; listOfModel = null; dt = null; } }
private CurrentSeasonMenuViewModel getDetailsMenu(string modeType, int userActionID, int championshipID, connectionMySQL db) { CurrentSeasonMenuViewModel model = new CurrentSeasonMenuViewModel(); DataTable dt = null; try { paramName = new string[] { "pType", "pIdUsu", "pIdCamp" }; paramValue = new string[] { modeType, userActionID.ToString(), championshipID.ToString() }; dt = db.executePROC("spGetDetailsMenuCurrentSeason", paramName, paramValue); model.modeType = modeType; if (dt.Rows.Count > 0) { model.currentSeasonName = dt.Rows[0]["seasonName"].ToString(); model.currentChampionshipID = Convert.ToInt16(dt.Rows[0]["championshipID"].ToString()); model.currentChampionshipName = dt.Rows[0]["championshipName"].ToString(); model.currentChampionshipForGroup = Convert.ToInt16(dt.Rows[0]["championchipForGroup"].ToString()); model.championshipSerieAID = Convert.ToInt16(dt.Rows[0]["serieA"].ToString()); model.championshipSerieBID = Convert.ToInt16(dt.Rows[0]["serieB"].ToString()); model.championshipSerieAForGroup = Convert.ToInt16(dt.Rows[0]["serieAForGroup"].ToString()); model.championshipSerieBForGroup = Convert.ToInt16(dt.Rows[0]["serieBForGroup"].ToString()); model.teamName = dt.Rows[0]["teamName"].ToString(); model.userHasTeamFUT = Convert.ToInt16(dt.Rows[0]["userHasTeamFUT"].ToString()); model.userHasTeamPRO = Convert.ToInt16(dt.Rows[0]["userHasTeamPRO"].ToString()); model.returnMessage = "CurrentSeasonSuccessfully"; } return(model); } catch (Exception ex) { model = new CurrentSeasonMenuViewModel(); return(model); } finally { dt = null; model = null; } }
public IHttpActionResult postAction(SpoolerViewModel model) { db.openConnection(); DataTable dt = null; var objFunctions = new Commons.functions(); try { if (model.actionUser.ToLower() == "add_spooler_draw_warning" || model.actionUser.ToLower() == "add_spooler_draw_done") { paramName = new string[] { "pIdCamp", "pDescription", "pTypeSpooler", "pIdUsuResponsible" }; paramValue = new string[] { Convert.ToString(model.championshipID), model.descriptionProcess, model.typeProcess, model.userIDResponsible.ToString() }; dt = db.executePROC("spAddSpoolerDraw", paramName, paramValue); if (dt.Rows.Count > 0) { model.totalSentEmails = Convert.ToInt32(dt.Rows[0]["TOTAL_EMAILS_SENT"].ToString()); } model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorPostSpooler_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; objFunctions = null; } }
private AcceptingDetails GetAccepting(connectionMySQL db, int seasonID, int userID, int championshipID) { AcceptingDetails modelDetails = new AcceptingDetails(); DataTable dt = null; try { modelDetails.seasonID = seasonID; modelDetails.userID = userID; modelDetails.championshipID = championshipID; paramName = new string[] { "pIdTemporada", "pIdCampeonato", "pIdUsu" }; paramValue = new string[] { Convert.ToString(modelDetails.seasonID), Convert.ToString(modelDetails.championshipID), Convert.ToString(modelDetails.userID) }; dt = db.executePROC("spGetConfirmacaoTemporada", paramName, paramValue); if (dt.Rows.Count > 0) { modelDetails.confirmation = dt.Rows[0]["IN_CONFIRMACAO"].ToString(); modelDetails.ordering = dt.Rows[0]["IN_ORDENACAO"].ToString(); modelDetails.DateconfirmationFormatted = dt.Rows[0]["DT_CONFIRMACAO_FORMATADA"].ToString(); modelDetails.psnID = dt.Rows[0]["PSN_ID"].ToString(); modelDetails.teamName = dt.Rows[0]["NM_TIME"].ToString(); modelDetails.statusID = dt.Rows[0]["DS_Status"].ToString(); modelDetails.statusDescription = dt.Rows[0]["DS_Descricao_Status"].ToString(); } return(modelDetails); } catch (Exception ex) { return(modelDetails); } finally { dt = null; modelDetails = null; } }
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 ranking(MyMatchesSummaryViewModel model) { MyNextMatchesViewModel MyMatchesModel = new MyNextMatchesViewModel(); db.openConnection(); DataTable dt = null; string returnMessage = String.Empty; try { if (model.actionUser == "summary") { paramName = new string[] { "pIdUsu" }; paramValue = new string[] { model.userID.ToString() }; dt = db.executePROC("spGetSummaryMyMatches", paramName, paramValue); model.totalGoals = Convert.ToInt16(dt.Rows[0]["totalGoals"].ToString()); model.totalMatches = Convert.ToInt16(dt.Rows[0]["totalMatches"].ToString()); model.averageGoals = Convert.ToInt16(dt.Rows[0]["averageGoals"].ToString()); model.teamNameH2H = dt.Rows[0]["teamNameH2H"].ToString(); model.teamNameFUT = dt.Rows[0]["teamNameFUT"].ToString(); model.teamNamePRO = dt.Rows[0]["teamNamePRO"].ToString(); model.listOfScorersH2H = GlobalFunctions.getListScorers("H2H", db, model.userID); model.listOfScorersPRO = GlobalFunctions.getListScorers("PRO", db, model.userID); model.returnMessage = "MyMatchesSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "myNextMatchesH2H") { MyMatchesModel.typeMode = "H2H"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("H2H", "NEXT", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("NEXT", db, MyMatchesModel.totalsMyMatches.teamIDH2H, MyMatchesModel.totalsMyMatches.natonalTeamIDCPDM, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myMatchesDoneH2H") { MyMatchesModel.typeMode = "H2H"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("H2H", "DONE", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("DONE", db, MyMatchesModel.totalsMyMatches.teamIDH2H, MyMatchesModel.totalsMyMatches.natonalTeamIDCPDM, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myListOfScorersH2H") { MyMatchesModel.typeMode = "H2H"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal(MyMatchesModel.typeMode, "SCORERS", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfScorers = GlobalFunctions.getListScorers(MyMatchesModel.typeMode, db, model.userID, false, 0); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myNextMatchesFUT") { MyMatchesModel.typeMode = "FUT"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("FUT", "NEXT", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("NEXT", db, MyMatchesModel.totalsMyMatches.teamIDFUT, 0, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myMatchesDoneFUT") { MyMatchesModel.typeMode = "FUT"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("FUT", "DONE", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("DONE", db, MyMatchesModel.totalsMyMatches.teamIDFUT, 0, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "uploadLogoTeamFUTDetails") { MyMatchesModel.typeMode = "FUT"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal(MyMatchesModel.typeMode, "NEXT", db, model.userID); MyMatchesModel.returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myNextMatchesPRO") { MyMatchesModel.typeMode = "PRO"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("PRO", "NEXT", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("NEXT", db, MyMatchesModel.totalsMyMatches.teamIDPRO, 0, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myMatchesDonePRO") { MyMatchesModel.typeMode = "PRO"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal("PRO", "DONE", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfMatch = GlobalFunctions.getListOfMatchForMyMatches("DONE", db, MyMatchesModel.totalsMyMatches.teamIDPRO, 0, out returnMessage); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "myListOfScorersPRO") { MyMatchesModel.typeMode = "PRO"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal(MyMatchesModel.typeMode, "SCORERS", db, model.userID); returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (returnMessage == "MyMatchesSuccessfully") { MyMatchesModel.listOfScorers = GlobalFunctions.getListScorers(MyMatchesModel.typeMode, db, model.userID, false, 0); } MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "uploadLogoTeamPRODetails") { MyMatchesModel.typeMode = "PRO"; MyMatchesModel.userID = model.userID; MyMatchesModel.totalsMyMatches = GlobalFunctions.getMyMatchesTotal(MyMatchesModel.typeMode, "NEXT", db, model.userID); MyMatchesModel.returnMessage = MyMatchesModel.totalsMyMatches.returnMessage; if (MyMatchesModel.returnMessage == "MyMatchesSuccessfully") { paramName = new string[] { "pIdUsuario" }; paramValue = new string[] { Convert.ToString(model.userID) }; dt = db.executePROC("spGetUsuarioById", paramName, paramValue); MyMatchesModel.psnID = dt.Rows[0]["PSN_ID"].ToString(); MyMatchesModel.userName = dt.Rows[0]["NM_USUARIO"].ToString(); MyMatchesModel.mobileNumber = dt.Rows[0]["NO_CELULAR"].ToString(); MyMatchesModel.codeMobileNumber = dt.Rows[0]["NO_DDD"].ToString(); MyMatchesModel.listOfSquad = GlobalFunctions.getListOfSquadPROCLUB(db, 0, model.userID, out returnMessage); MyMatchesModel.returnMessage = returnMessage; } else { MyMatchesModel.listOfSquad = new List <squadListModel>(); } return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "uploadLogoTeamPROListOfSquad") { MyMatchesModel.listOfSquad = GlobalFunctions.getListOfSquadPROCLUB(db, 0, model.userID, out returnMessage); MyMatchesModel.returnMessage = returnMessage; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } else if (model.actionUser == "updateMobileManagerPRO") { paramName = new string[] { "pIdUsuario", "pDDD", "pMobile" }; paramValue = new string[] { Convert.ToString(model.userID), model.codeMobileNumber, model.mobileNumber }; db.executePROCNonResult("spUpdateMobile", paramName, paramValue); model.returnMessage = "MyMatchesSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "spAddPlayerSquadPro") { paramName = new string[] { "pIdClub", "pPsnJogador" }; paramValue = new string[] { Convert.ToString(model.teamID), model.psnID }; dt = db.executePROC("spAddPlayerSquadPro", paramName, paramValue); if (dt.Rows[0]["COD_VALIDATION"].ToString() == "0") { model.returnMessage = "MyMatchesSuccessfully"; } else if (dt.Rows[0]["COD_VALIDATION"].ToString() == "1") { model.returnMessage = "PsnNotFound"; } else if (dt.Rows[0]["COD_VALIDATION"].ToString() == "2") { model.returnMessage = "PlayerIsInYourClub"; } else if (dt.Rows[0]["COD_VALIDATION"].ToString() == "3") { model.returnMessage = "PlayerIsInAnotherClub"; } return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "spDeletePlayerSquadPro") { paramName = new string[] { "pIdGoleador" }; paramValue = new string[] { Convert.ToString(model.userID) }; db.executePROCNonResult("spDeteleGoleador", paramName, paramValue); model.returnMessage = "MyMatchesSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { MyMatchesModel = new MyNextMatchesViewModel(); MyMatchesModel.listOfMatch = new List <Models.ChampionshipMatchTableModel.ChampionshipMatchTableDetailsModel>(); MyMatchesModel.totalsMyMatches = new MyMatchesTotalModel(); MyMatchesModel.userID = model.userID; MyMatchesModel.actionUser = model.actionUser; MyMatchesModel.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, MyMatchesModel)); } finally { db.closeConnection(); dt = null; MyMatchesModel = null; } }
public IHttpActionResult hallOfFame(GenerateRenewalViewModel model) { if (String.IsNullOrEmpty(model.dataBaseName)) { model.dataBaseName = GlobalVariables.DATABASE_NAME_ONLINE; } db.openConnection(model.dataBaseName); DataTable dt = null; try { if (model.actionUser == "summary") { getSummaryDetails(ref model, db); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "prepareDatabaseBefore") { paramName = new string[] { }; paramValue = new string[] { }; db.executePROCNonResult("spDeleteAllRecords", paramName, paramValue); db.executePROCNonResult("spTransferDataFromOnlineDtb", paramName, paramValue); getSummaryDetails(ref model, db, true); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "generateRenewal") { string inWorldCup_Euro = "0"; if (model.inRenewalWithEuro == 1 || model.inRenewalWithWorldCup == 1) { inWorldCup_Euro = "1"; } paramName = new string[] { "pInWorldCupNextSeason" }; paramValue = new string[] { inWorldCup_Euro }; db.executePROCNonResult("spGenerateRenewalsForNextSeason", paramName, paramValue); getSummaryDetails(ref model, db, true); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "createSpooler") { paramName = new string[] { "pIdUsuAction" }; paramValue = new string[] { model.userActionID.ToString() }; db.executePROCNonResult("spCreateRenewalSpoolerForNextSeason", paramName, paramValue); getSummaryDetails(ref model, db, true); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "cancelRenewal") { paramName = new string[] { }; paramValue = new string[] { }; db.executePROCNonResult("spCancelRenewalsForNextSeason", paramName, paramValue); getSummaryDetails(ref model, db, true); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "cancelSpooler") { paramName = new string[] { }; paramValue = new string[] { }; db.executePROCNonResult("spCancelRenewalSpoolerForNextSeason", paramName, paramValue); getSummaryDetails(ref model, db, true); return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getDetailsRenewalHome") { paramName = new string[] { "pIdUser" }; paramValue = new string[] { model.renewalModel.userID.ToString() }; dt = db.executePROC("spGetAllDetailsRenewalHome", paramName, paramValue); model.renewalModel.seasonID = Convert.ToInt16(dt.Rows[0]["temporadaID"].ToString()); if (!String.IsNullOrEmpty(dt.Rows[0]["confirmH2H"].ToString())) { if (dt.Rows[0]["confirmH2H"].ToString() == "1") { model.renewalModel.checkYESH2H = true; } else if (dt.Rows[0]["confirmH2H"].ToString() == "0") { model.renewalModel.checkNOH2H = true; } } if (!String.IsNullOrEmpty(dt.Rows[0]["confirmFUT"].ToString())) { if (dt.Rows[0]["confirmFUT"].ToString() == "1") { model.renewalModel.checkYESFUT = true; } else if (dt.Rows[0]["confirmFUT"].ToString() == "0") { model.renewalModel.checkNOFUT = true; } } if (!String.IsNullOrEmpty(dt.Rows[0]["confirmPRO"].ToString())) { if (dt.Rows[0]["confirmPRO"].ToString() == "1") { model.renewalModel.checkYESPRO = true; } else if (dt.Rows[0]["confirmPRO"].ToString() == "0") { model.renewalModel.checkNOPRO = true; } } if (!String.IsNullOrEmpty(dt.Rows[0]["confirmWC"].ToString())) { if (dt.Rows[0]["confirmWC"].ToString() == "1") { model.renewalModel.checkYESWDC = true; } else if (dt.Rows[0]["confirmWC"].ToString() == "0") { model.renewalModel.checkNOWDC = true; } } if (!String.IsNullOrEmpty(dt.Rows[0]["nmTimeFUT"].ToString())) { model.renewalModel.teamNameFUT = dt.Rows[0]["nmTimeFUT"].ToString(); } if (!String.IsNullOrEmpty(dt.Rows[0]["nmTimePRO"].ToString())) { model.renewalModel.teamNamePRO = dt.Rows[0]["nmTimePRO"].ToString(); } if (!String.IsNullOrEmpty(dt.Rows[0]["mobile"].ToString())) { model.renewalModel.ddd = dt.Rows[0]["ddd"].ToString(); model.renewalModel.mobile = dt.Rows[0]["mobile"].ToString(); } model.returnMessage = "GenerateRenewalSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "saveRenewalNewSeasonHome") { int confirmH2H = -1; int confirmFUT = -1; int confirmPRO = -1; int confirmWC = -1; if (model.renewalModel.checkYESH2H) { confirmH2H = 1; } else if (model.renewalModel.checkYESH2H) { confirmH2H = 0; } if (model.renewalModel.checkYESFUT) { confirmFUT = 1; } else if (model.renewalModel.checkNOFUT) { confirmFUT = 0; } if (model.renewalModel.checkYESPRO) { confirmPRO = 1; } else if (model.renewalModel.checkNOPRO) { confirmPRO = 0; } if (model.renewalModel.checkYESWDC) { confirmWC = 1; } else if (model.renewalModel.checkNOWDC) { confirmWC = 0; } paramName = new string[] { "pIdTemporada", "pIdUsu", "pInConfirmH2H", "pInConfirmFUT", "pInConfirmPRO", "pInConfirmWC", "pNmTeamFUT", "pNmTeamPRO", "pDDD", "pMobile" }; paramValue = new string[] { model.renewalModel.seasonID.ToString(), model.renewalModel.userID.ToString(), confirmH2H.ToString(), confirmFUT.ToString(), confirmPRO.ToString(), confirmWC.ToString(), model.renewalModel.teamNameFUT, model.renewalModel.teamNamePRO, model.renewalModel.ddd, model.renewalModel.mobile }; db.executePROCNonResult("spControlConfirmacaoTemporada", paramName, paramValue); model.returnMessage = "GenerateRenewalSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult SigninUser(UserLoginModel user) { if (user.actionUser == "Signin") { db.openConnection(); var objFunctions = new Commons.functions(); Boolean validPasswordLogin = false; UserDetailsModel userDetails = new UserDetailsModel(); DataTable dt = null; DataTable dt2 = null; string passwordBase64 = string.Empty; try { paramName = new string[] { "dsLogin" }; paramValue = new string[] { user.psnID }; dt = db.executePROC("spGetUsuarioByLogin", paramName, paramValue); if (dt.Rows.Count > 0) { if (user.password != string.Empty) { byte[] byt = System.Text.Encoding.UTF8.GetBytes(user.password); passwordBase64 = Convert.ToBase64String(byt); } SetDetailsUser(dt, userDetails); if (!string.IsNullOrEmpty(userDetails.currentTeam)) { paramName = new string[] { "idTime" }; paramValue = new string[] { userDetails.currentTeam }; dt2 = db.executePROC("spGetTime", paramName, paramValue); userDetails.currentTeam = dt2.Rows[0]["NM_TIME"].ToString(); } paramName = new string[] { "idUsu" }; paramValue = new string[] { Convert.ToString(userDetails.id) }; dt2 = db.executePROC("spGetTitlesWonForUser", paramName, paramValue); userDetails.totalTitlesWon = Convert.ToInt16(dt2.Rows[0]["TOTAL_TITLESWON"].ToString()); userDetails.totalVices = Convert.ToInt16(dt2.Rows[0]["TOTAL_VICES"].ToString()); if (userDetails.password.ToString() != userDetails.password20.ToString() && userDetails.password20.ToString() == String.Empty) { validPasswordLogin = objFunctions.validateOldEncryptionPassword(userDetails.password.ToString(), user.password, Convert.ToInt16(userDetails.id.ToString())); if (validPasswordLogin) { paramName = new string[] { "pIdUsuario", "pPassWDBase64" }; paramValue = new string[] { Convert.ToString(userDetails.id), passwordBase64 }; db.executePROCNonResult("spUpdadePassWDUsuario", paramName, paramValue); paramName = new string[] { "pIdUsuario" }; paramValue = new string[] { Convert.ToString(userDetails.id) }; db.executePROCNonResult("spUpdateUltimoAcesso", paramName, paramValue); userDetails.lastAccess = DateTime.Now; } } else { paramName = new string[] { "pIdUsuario", "pPassWDBase64" }; paramValue = new string[] { Convert.ToString(userDetails.id), passwordBase64 }; dt = db.executePROC("spValidatePasswdOfUsuario", paramName, paramValue); var rowVal = dt.Rows[0]; if (rowVal["COD_VALIDATION"].ToString() == "0") { validPasswordLogin = true; } else if (rowVal["COD_VALIDATION"].ToString() == "1") { validPasswordLogin = false; } else if (rowVal["COD_VALIDATION"].ToString() == "2") { validPasswordLogin = false; } } if (validPasswordLogin == true) { userDetails.returnMessage = "loginSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = userDetails.id }, userDetails)); } else { user = new UserLoginModel(); user.returnMessage = "loginFailed"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } } else { user = new UserLoginModel(); user.returnMessage = "UserNotFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } } catch (Exception ex) { user = new UserLoginModel(); user.returnMessage = "errorSigninUser_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } finally { db.closeConnection(); objFunctions = null; userDetails = null; dt = null; dt2 = null; } } else if (user.actionUser == "Register") { db.openConnection(); var objFunctions = new Commons.functions(); DataTable dt = null; string passwordBase64 = string.Empty; try { paramName = new string[] { "pdsPsn", "pNmUsuario", "pDsEmail" }; paramValue = new string[] { user.psnID, user.name, user.email }; dt = db.executePROC("spValidateRegistrationOfUsuarioNewUsuario", paramName, paramValue); var rowValRegister = dt.Rows[0]; if (rowValRegister["COD_VALIDATION"].ToString() == "0") { byte[] byt = System.Text.Encoding.UTF8.GetBytes(user.password); passwordBase64 = Convert.ToBase64String(byt); paramName = new string[] { "pNmUsuario", "pDsSenhaBase64", "pDsEmail", "pPsnId", "pInAtivo", "pDsFicouSabendo", "pDsQual", "pNmTime", "pDtNasc", "pDsEstado", "pInReceberAlerta", "pInReceberSit", "pInDesejaPartic", "pInModerador", "pDsPsnCadastro", "pIdUsuarioOperacao", "pPsnUsuarioOperacao", "pDsPaginaOperacao" }; string receiveWarningEachRound = Convert.ToBoolean(user.inEmailWarning) ? "1" : "0"; string receiveTeamTable = Convert.ToBoolean(user.inEmailTeamTable) ? "1" : "0"; string wishParticipate = Convert.ToBoolean(user.inParticipate) ? "1" : "0"; string userActive = Convert.ToBoolean(user.userActive) ? "1" : "0"; string userModerator = Convert.ToBoolean(user.userModerator) ? "1" : "0"; paramValue = new string[] { user.name, passwordBase64, user.email, user.psnID, userActive, user.howfindus, user.whathowfindus, user.team, user.birthday.ToString("dd/MM/yyyy") + ";[DATE-TYPE]", user.state, receiveWarningEachRound, receiveTeamTable, wishParticipate, userModerator, user.psnID, null, "NULL", "UserController.Register" }; dt = db.executePROC("spAddUsuario", paramName, paramValue); user.id = Convert.ToInt16(dt.Rows[0]["ID_USUARIO"].ToString()); user.returnMessage = "registerSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = user.id }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "1") { user.returnMessage = "PsnFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "2") { user.returnMessage = "NameFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "3") { user.returnMessage = "EmailFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else { user = new UserLoginModel(); user.returnMessage = "ValidationNotFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } } catch (Exception ex) { user = new UserLoginModel(); user.returnMessage = "errorRegisterUser_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } finally { db.closeConnection(); objFunctions = null; dt = null; } } else if (user.actionUser == "Update") { db.openConnection(); var objFunctions = new Commons.functions(); DataTable dt = null; string passwordBase64 = string.Empty; try { paramName = new string[] { "pIdUsuario", "pdsPsn", "pNmUsuario", "pDsEmail" }; paramValue = new string[] { Convert.ToString(user.id), user.psnID, user.name, user.email }; dt = db.executePROC("spValidateRegistrationOfUsuarioOldUsuario", paramName, paramValue); var rowValRegister = dt.Rows[0]; if (rowValRegister["COD_VALIDATION"].ToString() == "0") { paramName = new string[] { "pIdUsuario", "pNmUsuario", "pDsEmail", "pPsnId", "pInAtivo", "pDsFicouSabendo", "pDsQual", "pNmTime", "pDtNasc", "pDsEstado", "pInReceberAlerta", "pInReceberSit", "pInDesejaPartic", "pInModerador", "pDsPsnCadastro", "pIdUsuarioOperacao", "pPsnUsuarioOperacao", "pDsPaginaOperacao" }; string receiveWarningEachRound = Convert.ToBoolean(user.inEmailWarning) ? "1" : "0"; string receiveTeamTable = Convert.ToBoolean(user.inEmailTeamTable) ? "1" : "0"; string wishParticipate = Convert.ToBoolean(user.inParticipate) ? "1" : "0"; string userActive = Convert.ToBoolean(user.userActive) ? "1" : "0"; string userModerator = Convert.ToBoolean(user.userModerator) ? "1" : "0"; paramValue = new string[] { Convert.ToString(user.id), user.name, user.email, user.psnID, userActive, user.howfindus, user.whathowfindus, user.team, user.birthday.ToString("dd/MM/yyyy") + ";[DATE-TYPE]", user.state, receiveWarningEachRound, receiveTeamTable, wishParticipate, userModerator, user.psnRegister, Convert.ToString(user.idUserOperation), user.psnOperation, "UserController.Update" }; dt = db.executePROC("spUpdadeUsuario", paramName, paramValue); user.returnMessage = "updateSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = user.id }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "1") { user.returnMessage = "PsnFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "2") { user.returnMessage = "NameFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (rowValRegister["COD_VALIDATION"].ToString() == "3") { user.returnMessage = "EmailFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else { user = new UserLoginModel(); user.returnMessage = "ValidationNotFound"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } } catch (Exception ex) { user = new UserLoginModel(); user.returnMessage = "errorUpdateUser_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } finally { db.closeConnection(); objFunctions = null; dt = null; } } else if (user.actionUser == "ChangePassword") { db.openConnection(); var objFunctions = new Commons.functions(); UserDetailsModel userDetails = new UserDetailsModel(); string passwordBase64 = string.Empty; DataTable dt = null; try { if (user.current_password == string.Empty || user.password == string.Empty || user.confirm_password == string.Empty) { user = new UserLoginModel(); user.returnMessage = "emptyPasswordFields"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (user.password != user.confirm_password) { user = new UserLoginModel(); user.returnMessage = "newPasswordFieldsDifferent"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else if (user.current_password == user.password && user.password == user.confirm_password) { user = new UserLoginModel(); user.returnMessage = "newPasswordEqual"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } else { byte[] byt = System.Text.Encoding.UTF8.GetBytes(user.current_password); passwordBase64 = Convert.ToBase64String(byt); paramName = new string[] { "pIdUsuario", "pPassWDBase64" }; paramValue = new string[] { Convert.ToString(user.id), passwordBase64 }; dt = db.executePROC("spValidatePasswdOfUsuario", paramName, paramValue); var rowVal = dt.Rows[0]; if (rowVal["COD_VALIDATION"].ToString() == "0") { byte[] byt2 = System.Text.Encoding.UTF8.GetBytes(user.password); passwordBase64 = Convert.ToBase64String(byt2); paramName = new string[] { "pIdUsuario", "pPassWDBase64" }; paramValue = new string[] { Convert.ToString(user.id), passwordBase64 }; db.executePROCNonResult("spUpdadePassWDUsuario", paramName, paramValue); user.returnMessage = "changedSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = user.id }, user)); } else { user = new UserLoginModel(); user.returnMessage = "loginFailed"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } } } catch (Exception ex) { user = new UserLoginModel(); user.returnMessage = "errorChangePassword_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } finally { db.closeConnection(); objFunctions = null; userDetails = null; dt = null; } } else if (user.actionUser == "RankingSupporters") { db.openConnection(); DataTable dt = null; List <SupportesTeamModel> oList = new List <SupportesTeamModel>(); SupportesTeamModel supporters = new SupportesTeamModel(); RankingSupportersModel ranking = new RankingSupportersModel(); try { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetDetailsRankingSupporters", paramName, paramValue); ranking.dtUpdateFormated = dt.Rows[0]["DT_CADASTRO_FORMATADA"].ToString(); ranking.totalUser = Convert.ToInt16(dt.Rows[0]["TOTAL_USUARIO"].ToString()); paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetListRankingSupporters", paramName, paramValue); var rowVal = dt.Rows[0]; for (var i = 0; i < dt.Rows.Count; i++) { supporters = new SupportesTeamModel(); supporters.teamName = dt.Rows[i]["NM_TIME"].ToString(); supporters.total = Convert.ToInt16(dt.Rows[i]["TOTAL"].ToString()); oList.Add(supporters); } ranking.listSupportesTeam = oList; ranking.returnMessage = "rankingSuccessfully"; return(CreatedAtRoute("DefaultApi", new { }, ranking)); } catch (Exception ex) { user = new UserLoginModel(); user.returnMessage = "errorRankingSupporters_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, user)); } finally { db.closeConnection(); oList = null; supporters = null; ranking = null; dt = null; } } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } }
public IHttpActionResult postRequest(ScorerDetails model) { ScorerViewModel mainModel = new ScorerViewModel(); CurrentSeasonSummaryViewModel mainViewModel = new CurrentSeasonSummaryViewModel(); db.openConnection(); DataTable dt = null; try { if (model.actionUser == "save") { if (model.id > 0) { paramName = new string[] { "pIdGoleador", "pIdTime", "pNmGoleador", "pNmCompleto", "pDsLink", "pDsPais", "pIdSofifa", "pIdUsu" }; paramValue = new string[] { Convert.ToString(model.id), Convert.ToString(model.teamID), model.nickname, model.name, model.link, model.country, model.sofifaTeamID, Convert.ToString(model.userID) }; dt = db.executePROC("spUpdateGoleador", paramName, paramValue); } else { paramName = new string[] { "pIdGoleador", "pIdTime", "pNmGoleador", "pNmCompleto", "pDsLink", "pDsPais", "pIdSofifa", "pTipo", "pIdUsu" }; paramValue = new string[] { "0", Convert.ToString(model.teamID), model.nickname, model.name, model.link, model.country, model.sofifaTeamID, model.scorerType, Convert.ToString(model.userID) }; dt = db.executePROC("spAddGoleador", paramName, paramValue); } model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getListOfScorerByTeam") { paramName = new string[] { "pIdTime" }; paramValue = new string[] { Convert.ToString(model.teamID) }; dt = db.executePROC("spGetAllGoleadorByTime", paramName, paramValue); mainModel.listOfScorer = setUpListDetailsScorers(dt); mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else if (model.actionUser == "getListOfScorerByChampionship") { mainViewModel.listOfScorers = GlobalFunctions.getListScorers(String.Empty, db, 0, false, model.id); mainViewModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainViewModel)); } else if (model.actionUser == "getListOfScorerByMatchTeam") { paramName = new string[] { "pIdJogo", "pIdTime" }; paramValue = new string[] { Convert.ToString(model.id), Convert.ToString(model.teamID) }; dt = db.executePROC("spGetGoleadorGolsOfTime", paramName, paramValue); mainModel.listOfScorer = setUpListDetailsScorers(dt); mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; mainModel = null; mainViewModel = null; } }
public IHttpActionResult ranking(SummaryViewModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser == "summary") { try { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetSummaryRanking", paramName, paramValue); model.totGoalsH2H = Convert.ToInt32(dt.Rows[0]["totalGoalsH2H"].ToString()); model.totGoalsFUT = Convert.ToInt32(dt.Rows[0]["totalGoalsFUT"].ToString()); model.totGoalsPRO = Convert.ToInt32(dt.Rows[0]["totalGoalsPRO"].ToString()); model.seasonNameH2H = dt.Rows[0]["seasonNameH2H"].ToString(); model.seasonNameFUT = dt.Rows[0]["seasonNameFUT"].ToString(); model.seasonNamePRO = dt.Rows[0]["seasonNamePRO"].ToString(); model.listOfScorersH2H = GlobalFunctions.getListScorers("H2H", db); model.listOfScorersPRO = GlobalFunctions.getListScorers("PRO", db); model.returnMessage = "RankingSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } catch (Exception ex) { model = new SummaryViewModel(); model.listOfScorersH2H = new List <listScorers>(); model.listOfScorersPRO = new List <listScorers>(); model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { } } else if (model.actionUser == "rankingGeneral") { RankingViewModel rankingModel = new RankingViewModel(); listRanking ranking; List <listRanking> listOfRanking = new List <listRanking>(); int halfStars = 0; int fullStars = 0; double generalUse = 0; int totalMaxStars = 5; try { paramName = new string[] { "pTotalRecords", "pTypeMode" }; paramValue = new string[] { Convert.ToString(model.totalRecordsRanking), model.typeMode }; dt = db.executePROC("spGetAllGeneralRanking", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { ranking = new listRanking(); ranking.userID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); ranking.psnID = dt.Rows[i]["PSN_ID"].ToString(); ranking.userName = dt.Rows[i]["NM_USUARIO"].ToString(); ranking.state = dt.Rows[i]["DS_ESTADO"].ToString(); ranking.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString()); ranking.totalSeason = Convert.ToInt32(dt.Rows[i]["PT_TOTAL_TEMPORADA"].ToString()); ranking.totalPreviousSeason = Convert.ToInt32(dt.Rows[i]["PT_TOTAL_TEMPORADA_ANTERIOR"].ToString()); ranking.totalLeague = Convert.ToInt32(dt.Rows[i]["PT_LIGAS"].ToString()); ranking.totalCup = Convert.ToInt32(dt.Rows[i]["PT_COPAS"].ToString()); ranking.position = Convert.ToInt32(dt.Rows[i]["IN_POSICAO_ATUAL"].ToString()); ranking.totalHalfStars = 0; ranking.totalStars = 0; ranking.totalEmptyStars = 0; if (String.IsNullOrEmpty(dt.Rows[i]["PC_APROVEITAMENTO_GERAL"].ToString())) { ranking.totalEmptyStars = totalMaxStars; } else { generalUse = Convert.ToDouble(dt.Rows[i]["PC_APROVEITAMENTO_GERAL"].ToString()); if (generalUse <= 0) { fullStars = 0; halfStars = 0; } else if (generalUse > 0 && generalUse < 10) { fullStars = 1; halfStars = 0; } else if (generalUse >= 10 && generalUse < 20) { fullStars = 1; halfStars = 1; } else if (generalUse >= 20 && generalUse < 30) { fullStars = 2; halfStars = 0; } else if (generalUse >= 30 && generalUse < 40) { fullStars = 2; halfStars = 1; } else if (generalUse >= 40 && generalUse < 50) { fullStars = 3; halfStars = 0; } else if (generalUse >= 50 && generalUse < 60) { fullStars = 3; halfStars = 1; } else if (generalUse >= 60 && generalUse < 70) { fullStars = 4; halfStars = 0; } else if (generalUse >= 70 && generalUse < 75) { fullStars = 4; halfStars = 1; } else if (generalUse >= 75 && generalUse <= 100) { fullStars = 5; halfStars = 0; } for (var j = 1; j <= totalMaxStars; j++) { if (fullStars >= j) { ranking.totalStars += 1; } else if (fullStars < j && halfStars == 1) { halfStars = 0; ranking.totalHalfStars += 1; } else if (fullStars < j && halfStars == 0) { ranking.totalEmptyStars += 1; } } } listOfRanking.Add(ranking); } rankingModel.listOfRanking = listOfRanking; rankingModel.returnMessage = "RankingSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } catch (Exception ex) { rankingModel = new RankingViewModel(); rankingModel.listOfRanking = new List <listRanking>(); rankingModel.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } finally { rankingModel = null; ranking = null; listOfRanking = null; } } else if (model.actionUser == "rankingCurrent") { RankingViewModel rankingModel = new RankingViewModel(); listRanking ranking; List <listRanking> listOfRanking = new List <listRanking>(); try { paramName = new string[] { "pTypeMode" }; paramValue = new string[] { model.typeMode }; dt = db.executePROC("spGetAllRankingCurrent", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { ranking = new listRanking(); ranking.userID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); ranking.psnID = dt.Rows[i]["PSN_ID"].ToString(); ranking.userName = dt.Rows[i]["NM_USUARIO"].ToString(); ranking.teamName = dt.Rows[i]["NM_TIME"].ToString(); ranking.state = dt.Rows[i]["DS_ESTADO"].ToString(); ranking.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString()); listOfRanking.Add(ranking); } rankingModel.listOfRanking = listOfRanking; rankingModel.returnMessage = "RankingSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } catch (Exception ex) { rankingModel = new RankingViewModel(); rankingModel.listOfRanking = new List <listRanking>(); rankingModel.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } finally { rankingModel = null; ranking = null; listOfRanking = null; } } else if (model.actionUser == "rankingByDivision") { RankingViewModel rankingModel = new RankingViewModel(); listRanking ranking; List <listRanking> listOfRanking = new List <listRanking>(); try { paramName = new string[] { "pSiglaCamp", "pTypeMode" }; paramValue = new string[] { model.typeChampionship, model.typeMode }; dt = db.executePROC("spGetRankingByDivision", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { ranking = new listRanking(); ranking.userID = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString()); ranking.psnID = dt.Rows[i]["PSN_ID"].ToString(); ranking.userName = dt.Rows[i]["NM_USUARIO"].ToString(); ranking.teamName = dt.Rows[i]["NM_TIME"].ToString(); ranking.state = dt.Rows[i]["DS_ESTADO"].ToString(); ranking.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString()); ranking.inAccessCurrentSeason = dt.Rows[i]["IN_ACESSO_TEMP_ATUAL"].ToString(); ranking.inRelegatePreviousSeason = dt.Rows[i]["IN_REBAIXADO_TEMP_ANTERIOR"].ToString(); listOfRanking.Add(ranking); } rankingModel.typeMode = model.typeMode; rankingModel.typeChampionship = model.typeChampionship; rankingModel.listOfRanking = listOfRanking; rankingModel.returnMessage = "RankingSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } catch (Exception ex) { rankingModel = new RankingViewModel(); rankingModel.listOfRanking = new List <listRanking>(); rankingModel.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, rankingModel)); } finally { rankingModel = null; ranking = null; listOfRanking = null; } } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model = new SummaryViewModel(); model.listOfScorersH2H = new List <listScorers>(); model.listOfScorersPRO = new List <listScorers>(); model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult postUser(DrawViewModel model) { db.openConnection(); DataTable dt = null; try { if (model.actionUser.ToLower() == "draw_automatic_user_team") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spAutomaticDrawOfTimes", paramName, paramValue); if (dt.Rows[0]["msgRetornoSorteioAutomaticoTimes"].ToString() == String.Empty) { model.returnMessage = "ModeratorSuccessfully"; } else { model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoTimes"].ToString(); } return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "cancel_draw_user_team") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spCancelDrawOfTimes", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "assume_draw_user_team") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spAssumeDrawOfTimesByDrawLeague", paramName, paramValue); if (dt.Rows[0]["msgRetornoSorteioAssumirTimesLiga"].ToString() == String.Empty) { model.returnMessage = "ModeratorSuccessfully"; } else { model.returnMessage = dt.Rows[0]["msgRetornoSorteioAssumirTimesLiga"].ToString(); } return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "draw_automatic_match_table") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spAutomaticDrawOfTables", paramName, paramValue); if (dt.Rows[0]["msgRetornoSorteioAutomaticoTabelas"].ToString() == String.Empty) { model.returnMessage = "ModeratorSuccessfully"; } else { model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoTabelas"].ToString(); } return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "cancel_draw_match_table") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spCancelDrawOfJogos", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "draw_automatic_group_table") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spAutomaticDrawOfGroupForPots", paramName, paramValue); if (dt.Rows[0]["msgRetornoSorteioAutomaticoGruposPorPotes"].ToString() == String.Empty) { model.returnMessage = "ModeratorSuccessfully"; } else { model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoGruposPorPotes"].ToString(); } return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "cancel_draw_group_table") { paramName = new string[] { "pIdCamp" }; paramValue = new string[] { Convert.ToString(model.championshipID) }; dt = db.executePROC("spCancelDrawOfGrupos", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
public IHttpActionResult ChampionshipMatchTable(ChampionshipMatchTableDetailsModel model) { ChampionshipMatchTableListViewModel mainModel = new ChampionshipMatchTableListViewModel(); ChampionshipMatchTableClashesHistoryTotalswModel modelHistory = new ChampionshipMatchTableClashesHistoryTotalswModel(); ChampionshipMatchTableClashesHistoryTotalsByTeamswModel modelHistoryTeams = new ChampionshipMatchTableClashesHistoryTotalsByTeamswModel(); ChampionshipMatchTableDetailsModel modelDetails = new ChampionshipMatchTableDetailsModel(); db.openConnection(); DataTable dt = null; try { if (model.actionUser.ToLower() == "save_simple_result") { paramName = new string[] { "pIdJogo", "pIdCamp", "pGoalsTimeHome", "pGoalsTimeAway", "pIdUsuAcao", "pPsnIdUsuAcao" }; paramValue = new string[] { Convert.ToString(model.matchID), Convert.ToString(model.championshipID), Convert.ToString(model.totalGoalsHome), Convert.ToString(model.totalGoalsAway), Convert.ToString(model.userIDAction), model.psnIDAction }; dt = db.executePROC("spSaveSimpleResultTabelaJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "decree_result") { paramName = new string[] { "pIdJogo", "pIdCamp", "pGoalsTimeHome", "pGoalsTimeAway", "pIdUsuAcao", "pPsnIdUsuAcao", "pMessage", "pSgTpListaNegra" }; paramValue = new string[] { Convert.ToString(model.matchID), Convert.ToString(model.championshipID), Convert.ToString(model.totalGoalsHome), Convert.ToString(model.totalGoalsAway), Convert.ToString(model.userIDAction), model.psnIDAction, model.messageBlackList, model.typeBlackList }; dt = db.executePROC("spDecreeSimpleResultTabelaJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "delete_result_launched") { paramName = new string[] { "pIdJogo", "pIdUsuAcao", "pPsnIdUsuAcao" }; paramValue = new string[] { Convert.ToString(model.matchID), Convert.ToString(model.userIDAction), model.psnIDAction }; dt = db.executePROC("spDeleteResultTabelaJogo", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser.ToLower() == "show_historic_each_team") { List <ChampionshipMatchTableDetailsModel> listOfModel = new List <ChampionshipMatchTableDetailsModel>(); paramName = new string[] { "pIdCamp", "pIdTimeCasa", "pIdVisitante", "pTotalRegistroCada" }; paramValue = new string[] { model.championshipID.ToString(), model.teamHomeID.ToString(), model.teamAwayID.ToString(), model.totalRecordsOfHistoric.ToString() }; dt = db.executePROC("spGetAllTabelaJogoAllHistoricoByTimes", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new ChampionshipMatchTableDetailsModel(); modelDetails.championshipName = dt.Rows[i]["NM_CAMPEONATO"].ToString(); modelDetails.stageID = Convert.ToInt16(dt.Rows[i]["ID_FASE"].ToString()); modelDetails.stageName = dt.Rows[i]["NM_FASE"].ToString(); modelDetails.startDate = Convert.ToDateTime(dt.Rows[i]["DT_TABELA_INICIO_JOGO"].ToString()); modelDetails.endDate = Convert.ToDateTime(dt.Rows[i]["DT_TABELA_FIM_JOGO"].ToString()); modelDetails.teamHomeID = Convert.ToInt16(dt.Rows[i]["ID_TIME_CASA"].ToString()); modelDetails.totalGoalsHome = dt.Rows[i]["QT_GOLS_TIME_CASA"].ToString(); modelDetails.teamAwayID = Convert.ToInt16(dt.Rows[i]["ID_TIME_VISITANTE"].ToString()); modelDetails.totalGoalsAway = dt.Rows[i]["QT_GOLS_TIME_VISITANTE"].ToString(); modelDetails.round = Convert.ToInt16(dt.Rows[i]["IN_NUMERO_RODADA"].ToString()); modelDetails.teamNameHome = dt.Rows[i]["1T"].ToString(); modelDetails.teamTypeHome = dt.Rows[i]["DT1"].ToString(); modelDetails.psnIDHome = dt.Rows[i]["PSN1"].ToString(); modelDetails.teamNameAway = dt.Rows[i]["2T"].ToString(); modelDetails.teamTypeAway = dt.Rows[i]["DT2"].ToString(); modelDetails.psnIDAway = dt.Rows[i]["PSN2"].ToString(); listOfModel.Add(modelDetails); } if (listOfModel != null) { mainModel.listOfMatch = listOfModel; } else { mainModel.listOfMatch = new List <ChampionshipMatchTableDetailsModel>(); } listOfModel = null; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else if (model.actionUser.ToLower() == "get_clashes_by_team") { List <ChampionshipMatchTableClashesByTeamModel> listOfModel = new List <ChampionshipMatchTableClashesByTeamModel>(); ChampionshipMatchTableClashesByTeamModel modelClashDetails = new ChampionshipMatchTableClashesByTeamModel(); int _teamID = 0; paramName = new string[] { "pIdCamp", "pIdUsu" }; paramValue = new string[] { model.championshipID.ToString(), model.userIDAction.ToString() }; dt = db.executePROC("spGetDetailsMatchesByTimeFromCampeonato", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { if (_teamID != Convert.ToInt32(dt.Rows[i]["ID_TIME"].ToString())) { if (_teamID > 0) { listOfModel.Add(modelClashDetails); } modelClashDetails = new ChampionshipMatchTableClashesByTeamModel(); modelClashDetails.userID = model.userIDAction; modelClashDetails.championshipID = model.championshipID; modelClashDetails.teamID = Convert.ToInt32(dt.Rows[i]["ID_TIME"].ToString()); modelClashDetails.teamName = dt.Rows[i]["NM_TIME"].ToString(); modelClashDetails.nextMatchID = Convert.ToInt32(dt.Rows[i]["ID_TABELA_JOGO_NEXT_MATCH"].ToString()); _teamID = modelClashDetails.teamID; } //modelClashDetails = new ChampionshipMatchTableClashesByTeamModel(); if (dt.Rows[i]["ID_ROUND"].ToString() == "0") { modelClashDetails.nextMatchTeamID = Convert.ToInt32(dt.Rows[i]["ID_TIME_NEXT_MATCH"].ToString()); modelClashDetails.nextMatchTeamName = dt.Rows[i]["NM_TIME_NEXT_MATCH"].ToString(); modelClashDetails.descriptionNextMatch = dt.Rows[i]["DS_MATCTH_1"].ToString(); } else if (dt.Rows[i]["ID_ROUND"].ToString() == "1") { modelClashDetails.descriptionPreviousMatch1_1 = dt.Rows[i]["DS_MATCTH_1"].ToString(); modelClashDetails.descriptionPreviousMatch1_2 = dt.Rows[i]["DS_MATCTH_2"].ToString(); modelClashDetails.descriptionPreviousMatch1_3 = dt.Rows[i]["DS_MATCTH_3"].ToString(); modelClashDetails.descriptionPreviousMatch1_4 = dt.Rows[i]["DS_MATCTH_4"].ToString(); modelClashDetails.statusPreviousMatch1 = dt.Rows[i]["STATUS_MATCTH"].ToString(); modelClashDetails.prevMatchID1 = Convert.ToInt32(dt.Rows[i]["ID_TABELA_JOGO_PREV_MATCH"].ToString()); } else if (dt.Rows[i]["ID_ROUND"].ToString() == "2") { modelClashDetails.descriptionPreviousMatch2_1 = dt.Rows[i]["DS_MATCTH_1"].ToString(); modelClashDetails.descriptionPreviousMatch2_2 = dt.Rows[i]["DS_MATCTH_2"].ToString(); modelClashDetails.descriptionPreviousMatch2_3 = dt.Rows[i]["DS_MATCTH_3"].ToString(); modelClashDetails.descriptionPreviousMatch2_4 = dt.Rows[i]["DS_MATCTH_4"].ToString(); modelClashDetails.statusPreviousMatch2 = dt.Rows[i]["STATUS_MATCTH"].ToString(); modelClashDetails.prevMatchID2 = Convert.ToInt32(dt.Rows[i]["ID_TABELA_JOGO_PREV_MATCH"].ToString()); } else if (dt.Rows[i]["ID_ROUND"].ToString() == "3") { modelClashDetails.descriptionPreviousMatch3_1 = dt.Rows[i]["DS_MATCTH_1"].ToString(); modelClashDetails.descriptionPreviousMatch3_2 = dt.Rows[i]["DS_MATCTH_2"].ToString(); modelClashDetails.descriptionPreviousMatch3_3 = dt.Rows[i]["DS_MATCTH_3"].ToString(); modelClashDetails.descriptionPreviousMatch3_4 = dt.Rows[i]["DS_MATCTH_4"].ToString(); modelClashDetails.statusPreviousMatch3 = dt.Rows[i]["STATUS_MATCTH"].ToString(); modelClashDetails.prevMatchID3 = Convert.ToInt32(dt.Rows[i]["ID_TABELA_JOGO_PREV_MATCH"].ToString()); } //listOfModel.Add(modelClashDetails); } if (dt.Rows.Count > 0) { listOfModel.Add(modelClashDetails); } if (listOfModel != null) { mainModel.listOfClashes = listOfModel; } else { mainModel.listOfClashes = new List <ChampionshipMatchTableClashesByTeamModel>(); } listOfModel = null; modelClashDetails = null; mainModel.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel)); } else if (model.actionUser.ToLower() == "clashes_historic_by_coaches") { paramName = new string[] { "pType", "pIdUsuLogged", "pPsnIDSearch" }; paramValue = new string[] { model.modeType, model.userIDAction.ToString(), model.psnIDSearch }; dt = db.executePROC("spGetTotalsClashesHistory", paramName, paramValue); if (dt.Rows.Count > 0) { if (dt.Rows[0]["errorID"].ToString() == "0") { modelHistory.userIDLogged = model.userIDAction; modelHistory.psnIDLogged = model.psnIDAction; modelHistory.userIDSearch = Convert.ToInt32(dt.Rows[0]["idUsuSearch"].ToString()); modelHistory.psnIDSearch = model.psnIDSearch; modelHistory.totalWinUsuLogged = Convert.ToInt16(dt.Rows[0]["totalWinUsuLogged"].ToString()); modelHistory.totalWinUsuSearch = Convert.ToInt16(dt.Rows[0]["totalWinUsuSearch"].ToString()); modelHistory.totalDraw = Convert.ToInt16(dt.Rows[0]["totalDraw"].ToString()); modelHistory.totalLossUsuLogged = Convert.ToInt16(dt.Rows[0]["totalLossUsuLogged"].ToString()); modelHistory.totalLossUsuSearch = Convert.ToInt16(dt.Rows[0]["totalLossUsuSearch"].ToString()); modelHistory.totalGoalsUsuLogged = Convert.ToInt16(dt.Rows[0]["totalGoalsUsuLogged"].ToString()); modelHistory.totalGoalsUsuSearch = Convert.ToInt16(dt.Rows[0]["totalGoalsUsuSearch"].ToString()); modelHistory.returnMessage = "ModeratorSuccessfully"; modelHistory.listOfMatchDraw = new List <ChampionshipMatchTableDetailsModel>(); modelHistory.listOfMatchWinUsuLogged = new List <ChampionshipMatchTableDetailsModel>(); modelHistory.listOfMatchWinUsuSearch = new List <ChampionshipMatchTableDetailsModel>(); paramName = new string[] { "pType", "pIdUsuLogged", "pIdUsuSearch" }; paramValue = new string[] { model.modeType, modelHistory.userIDLogged.ToString(), modelHistory.userIDSearch.ToString() }; dt = db.executePROC("spGetAllClashesHistory", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = GlobalFunctions.setDetailsChampionshipMatchTable(dt.Rows[i]); if (modelDetails.totalGoalsHome == modelDetails.totalGoalsAway) { modelHistory.listOfMatchDraw.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) > Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.userHomeID == modelHistory.userIDLogged) { modelHistory.listOfMatchWinUsuLogged.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) > Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.userHomeID == modelHistory.userIDSearch) { modelHistory.listOfMatchWinUsuSearch.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) < Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.userAwayID == modelHistory.userIDLogged) { modelHistory.listOfMatchWinUsuLogged.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) < Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.userAwayID == modelHistory.userIDSearch) { modelHistory.listOfMatchWinUsuSearch.Add(modelDetails); } } } else { modelHistory.returnMessage = "PsnIDSearchNotFound"; } } return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelHistory)); } else if (model.actionUser.ToLower() == "clashes_historic_by_teams") { paramName = new string[] { "pType", "pIdTimeHome", "pIdTimeAway" }; paramValue = new string[] { model.modeType, model.teamHomeID.ToString(), model.teamAwayID.ToString() }; dt = db.executePROC("spGetTotalsClashesHistoryByTimes", paramName, paramValue); if (dt.Rows.Count > 0) { modelHistoryTeams.teamIDHome = model.teamHomeID; modelHistoryTeams.teamIDAway = model.teamAwayID; modelHistoryTeams.teamNameHome = dt.Rows[0]["nmTimeHome"].ToString(); modelHistoryTeams.teamNameAway = dt.Rows[0]["nmTimeAway"].ToString(); modelHistoryTeams.totalDraw = Convert.ToInt16(dt.Rows[0]["totalDraw"].ToString()); modelHistoryTeams.totalWinTeamHome = Convert.ToInt16(dt.Rows[0]["totalWinUsuLogged"].ToString()); modelHistoryTeams.totalWinTeamAway = Convert.ToInt16(dt.Rows[0]["totalWinUsuSearch"].ToString()); modelHistoryTeams.totalLossTeamHome = Convert.ToInt16(dt.Rows[0]["totalLossUsuLogged"].ToString()); modelHistoryTeams.totalLossTeamAway = Convert.ToInt16(dt.Rows[0]["totalLossUsuSearch"].ToString()); modelHistoryTeams.totalGoalsTeamHome = Convert.ToInt16(dt.Rows[0]["totalGoalsUsuLogged"].ToString()); modelHistoryTeams.totalGoalsTeamAway = Convert.ToInt16(dt.Rows[0]["totalGoalsUsuSearch"].ToString()); modelHistoryTeams.returnMessage = "ModeratorSuccessfully"; modelHistoryTeams.listOfMatchDraw = new List <ChampionshipMatchTableDetailsModel>(); modelHistoryTeams.listOfMatchWinTeamHome = new List <ChampionshipMatchTableDetailsModel>(); modelHistoryTeams.listOfMatchWinTeamAway = new List <ChampionshipMatchTableDetailsModel>(); paramName = new string[] { "pType", "pIdTimeHome", "pIdTimeAway" }; paramValue = new string[] { model.modeType, model.teamHomeID.ToString(), model.teamAwayID.ToString() }; dt = db.executePROC("spGetAllClashesHistoryByTeams", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = GlobalFunctions.setDetailsChampionshipMatchTable(dt.Rows[i]); if (modelDetails.totalGoalsHome == modelDetails.totalGoalsAway) { modelHistoryTeams.listOfMatchDraw.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) > Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.teamHomeID == modelHistoryTeams.teamIDHome) { modelHistoryTeams.listOfMatchWinTeamHome.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) > Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.teamHomeID == modelHistoryTeams.teamIDAway) { modelHistoryTeams.listOfMatchWinTeamAway.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) < Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.teamAwayID == modelHistoryTeams.teamIDHome) { modelHistoryTeams.listOfMatchWinTeamHome.Add(modelDetails); } else if (Convert.ToInt16(modelDetails.totalGoalsHome) < Convert.ToInt16(modelDetails.totalGoalsAway) && modelDetails.teamAwayID == modelHistoryTeams.teamIDAway) { modelHistoryTeams.listOfMatchWinTeamAway.Add(modelDetails); } } } return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelHistoryTeams)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "errorPostChampionshipMatchTable_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; mainModel = null; modelDetails = null; modelHistory = null; modelHistoryTeams = 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 blackList(BlackListViewModel model) { db.openConnection(); DataTable dt = null; Boolean bActionUser = false; try { if (model.actionUser == "summaryList") { paramName = new string[] { "pIdTemp" }; paramValue = new string[] { Convert.ToString(model.seasonID) }; dt = db.executePROC("spGetListaNegraSummaryByTemporada", paramName, paramValue); SetBlackListSummarySeason(dt, model); bActionUser = true; } else if (model.actionUser == "detailsList") { paramName = new string[] { "pIdTemp", "pIdUsu" }; paramValue = new string[] { Convert.ToString(model.seasonID), Convert.ToString(model.userID) }; dt = db.executePROC("spGetListaNegraDetalheByTemporadaEUsuario", paramName, paramValue); SetBlackListDetailsSeason(dt, model); bActionUser = true; } else if (model.actionUser == "delete_by_match") { paramName = new string[] { "pIdJogo" }; paramValue = new string[] { model.matchID.ToString() }; dt = db.executePROC("spRemoveListaNegraByJogo", paramName, paramValue); if (dt.Rows.Count > 0) { model.messageBlackList = dt.Rows[0]["DSC_COMENTARIO_RETIRADA_LISTA_NEGRA"].ToString(); } bActionUser = true; } else if (model.actionUser == "add_by_match") { paramName = new string[] { "pIdTemp", "pIdCamp", "pIdUsu", "pIdJogo", "pSgTpListaNegra" }; paramValue = new string[] { model.seasonID.ToString(), model.championshipID.ToString(), model.userID.ToString(), model.matchID.ToString(), model.messageBlackList }; dt = db.executePROC("spAddListaNegra", paramName, paramValue); bActionUser = true; } else if (model.actionUser == "get_by_match_user") { paramName = new string[] { "pIdUsu", "pIdJogo" }; paramValue = new string[] { model.userID.ToString(), model.matchID.ToString() }; dt = db.executePROC("spGetListaNegraDetalheByJogo", paramName, paramValue); if (dt.Rows.Count == 0) { model.valueBlackList = 0; model.messageBlackList = String.Empty; } else if (Convert.ToInt16(dt.Rows[0]["IN_ADVERTENCIAS"].ToString()) == 1) { model.valueBlackList = Convert.ToInt16(ConfigurationManager.AppSettings["black.list.warning"].ToString()); model.messageBlackList = "Advertência<br>(" + dt.Rows[0]["PT_NEGATIVO"].ToString() + " ponto negativo)"; } else if (Convert.ToInt16(dt.Rows[0]["IN_OMISSAO_PARCIAL"].ToString()) == 1) { model.valueBlackList = Convert.ToInt16(ConfigurationManager.AppSettings["black.list.partial.omission"].ToString()); model.messageBlackList = "Omissão Parcial<br>(" + dt.Rows[0]["PT_NEGATIVO"].ToString() + " pontos negativos)"; } else if (Convert.ToInt16(dt.Rows[0]["IN_ANTIDESPORTIVA"].ToString()) == 1) { model.valueBlackList = Convert.ToInt16(ConfigurationManager.AppSettings["black.list.unsportsmanlike"].ToString()); model.messageBlackList = "Atitude Antidesportiva<br>(" + dt.Rows[0]["PT_NEGATIVO"].ToString() + " pontos negativos)"; } else if (Convert.ToInt16(dt.Rows[0]["IN_OMISSAO_TOTAL"].ToString()) == 1) { model.valueBlackList = Convert.ToInt16(ConfigurationManager.AppSettings["black.list.total.omission"].ToString()); model.messageBlackList = "Omissão Total<br>(" + dt.Rows[0]["PT_NEGATIVO"].ToString() + " pontos negativos)"; } bActionUser = true; } if (bActionUser) { model.returnMessage = "BlackListSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model = new BlackListViewModel(); model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); dt = null; } }
private List <AcceptingDetails> getAllAccepting(connectionMySQL db) { AcceptingDetails modelDetails = new AcceptingDetails(); List <AcceptingDetails> listOfModel = new List <AcceptingDetails>(); DataTable dt = null; try { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetAllConfirmacaoTemporadaNoFilterCRUD", paramName, paramValue); for (var i = 0; i < dt.Rows.Count; i++) { modelDetails = new AcceptingDetails(); modelDetails.seasonID = Convert.ToInt16(dt.Rows[i]["ID_TEMPORADA"].ToString()); modelDetails.userID = Convert.ToUInt16(dt.Rows[i]["ID_USUARIO"].ToString()); modelDetails.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString()); modelDetails.ordering = dt.Rows[i]["IN_ORDENACAO"].ToString(); modelDetails.primaryKey = Convert.ToString(modelDetails.seasonID) + ";" + Convert.ToString(modelDetails.userID) + ";" + Convert.ToString(modelDetails.championshipID); modelDetails.confirmation = dt.Rows[i]["IN_CONFIRMACAO"].ToString(); if (string.IsNullOrEmpty(dt.Rows[i]["IN_CONFIRMACAO"].ToString())) { modelDetails.confirmationDescription = "Ainda não confirmou"; } else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 9) { modelDetails.confirmationDescription = "Participação recusada pela Moderação"; } else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 0) { modelDetails.confirmationDescription = "Não deseja Participar"; } else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1) { modelDetails.confirmationDescription = "Confirmou Participação"; } modelDetails.totalBlackList = 0; if (!string.IsNullOrEmpty(dt.Rows[i]["PT_LSTNEGRA"].ToString())) { modelDetails.totalBlackList = Convert.ToInt16(dt.Rows[i]["PT_LSTNEGRA"].ToString()); } modelDetails.statusID = dt.Rows[i]["DS_STATUS"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[i]["IN_CONFIRMACAO"].ToString())) { if (modelDetails.statusID == "AP" && Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 0) { modelDetails.statusDescription = "DT - DESISTIU"; } else if (modelDetails.statusID == "AP" && Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1 && modelDetails.totalBlackList >= 16) { modelDetails.statusDescription = "EA - EM ANÁLISE"; } else if (modelDetails.statusID == "AP" && Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1) { modelDetails.statusDescription = "AP - APROVADO"; } else if (modelDetails.statusID == "AP") { modelDetails.statusDescription = "AG - AGUARDANDO"; } else if (modelDetails.statusID == "EA") { modelDetails.statusDescription = "EA - EM ANÁLISE"; } else if (modelDetails.statusID == "NA") { modelDetails.statusDescription = "NA - NÃO ACEITO"; } } modelDetails.teamName = dt.Rows[i]["NM_TIME"].ToString(); modelDetails.userName = dt.Rows[i]["NM_USUARIO"].ToString(); modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString(); modelDetails.DateconfirmationFormatted = dt.Rows[i]["DT_CONFIRMACAO_FORMATADA"].ToString(); listOfModel.Add(modelDetails); } return(listOfModel); } catch (Exception ex) { return(listOfModel); } finally { modelDetails = null; listOfModel = null; dt = null; } }
public IHttpActionResult getPost(GenerateNewSeasonDetailsModel model) { db.openConnection(GlobalVariables.DATABASE_NAME_STAGING); StandardGenerateNewSeasonChampionshipLeagueDetailsModel modelLeague = null; StandardGenerateNewSeasonChampionshipCupDetailsModel modelCup = null; GenerateNewSeasonGenerateModel modelGenerate = new GenerateNewSeasonGenerateModel();; DataTable dt = null; int i, j = 0; string[] allChampionshipsSelected = { }; Boolean VARIABLE_FALSE = false; Boolean VARIABLE_TRUE = true; try { if (model.actionUser == "getSeasonDetails") { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spGetAllSeasonDetailsNewTemporada", paramName, paramValue); model.seasonID = Convert.ToInt16(dt.Rows[0]["ID_TEMPORADA"].ToString()); model.seasonName = dt.Rows[0]["NM_TEMPORADA"].ToString(); model.userID = Convert.ToInt16(dt.Rows[0]["ID_USUARIO"].ToString()); model.userName = dt.Rows[0]["NM_USUARIO"].ToString(); model.psnID = dt.Rows[0]["PSN_ID"].ToString(); model.drawDate = Convert.ToDateTime(dt.Rows[0]["DATA_SORTEIO"].ToString()); model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getAllChampionshipsActiveDetails") { paramName = new string[] { "pTpModalidade" }; paramValue = new string[] { model.modeType }; dt = db.executePROC("spGetAllChampionshipTypesNewTemporadaByMode", paramName, paramValue); model.listChampionshipLeagueDetails = new List <StandardGenerateNewSeasonChampionshipLeagueDetailsModel>(); model.listChampionshipCupDetails = new List <StandardGenerateNewSeasonChampionshipCupDetailsModel>(); model.listOfTeams = new List <GenerateNewSeasonStandardDetailsModel>(); for (i = 0; i < dt.Rows.Count; i++) { if (GlobalVariables.GENERATE_NEWSEASON_CHAMPIONSHIP_ALLSERIES.IndexOf(dt.Rows[i]["SG_CAMPEONATO"].ToString()) > -1) { model.listChampionshipLeagueDetails.Add(getDetailsChampionshipLeague(model.modeType, dt.Rows[i]["SG_CAMPEONATO"].ToString())); } else { model.listChampionshipCupDetails.Add(getDetailsChampionshipCup(model.modeType, dt.Rows[i]["SG_CAMPEONATO"].ToString())); } } getAllTeamToTheMainModel(ref model); model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "saveChampionshipsLeagueDetails") { paramName = new string[] { "pIdTemporada", "pNmTemporada", "pIdUsu", "pNmUsu", "pPsnID", "pDtSorteio" }; paramValue = new string[] { model.seasonID.ToString(), model.seasonName, model.userID.ToString(), model.userName, model.psnID, model.drawDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]" }; db.executePROCNonResult("spAddUpdateSeasonGenerateNewSeason", paramName, paramValue); for (i = 0; i < model.listChampionshipLeagueDetails.Count; i++) { modelLeague = model.listChampionshipLeagueDetails[i]; string active = Convert.ToBoolean(modelLeague.hasChampionship) ? "1" : "0"; string byGroup = Convert.ToBoolean(modelLeague.championship_ByGroup) ? "1" : "0"; string byGroupPots = Convert.ToBoolean(modelLeague.championship_byGroupPots) ? "1" : "0"; string doubleRound = Convert.ToBoolean(modelLeague.championship_DoubleRound) ? "1" : "0"; paramName = new string[] { "pTpModalidade", "pSgCampeonato", "pDtInicio", "pQtTimes", "pQtDiasFase0", "pQtDiasPlayoff", "pQtTimesRebaixados", "pInAtivo", "pInPorGrupo", "pQtGrupos", "pInPorPotes", "pInDoubleRound" }; paramValue = new string[] { modelLeague.modeType, modelLeague.championshipType, modelLeague.startDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]", modelLeague.totalTeams.ToString(), modelLeague.totalDaysToPlayStage0.ToString(), modelLeague.totalDaysToPlayPlayoff.ToString(), modelLeague.totalRelegate.ToString(), active, byGroup, modelLeague.totalGroups.ToString(), byGroupPots, doubleRound }; db.executePROCNonResult("spUpdateChampionshipLeagueGenerateNewSeason", paramName, paramValue); } model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "saveChampionshipsCupDetails") { for (i = 0; i < model.listChampionshipCupDetails.Count; i++) { modelCup = model.listChampionshipCupDetails[i]; string active = Convert.ToBoolean(modelCup.hasChampionship) ? "1" : "0"; string byGroup = Convert.ToBoolean(modelCup.championship_ByGroup) ? "1" : "0"; string byGroupPots = Convert.ToBoolean(modelCup.championship_byGroupPots) ? "1" : "0"; string destiny = Convert.ToBoolean(modelCup.hasChampionshipDestiny) ? "1" : "0"; string source = Convert.ToBoolean(modelCup.hasChampionshipSource) ? "1" : "0"; string justSerieA = Convert.ToBoolean(modelCup.hasJust_SerieA) ? "1" : "0"; string justSerieB = Convert.ToBoolean(modelCup.hasJust_SerieB) ? "1" : "0"; string justSerieC = Convert.ToBoolean(modelCup.hasJust_SerieC) ? "1" : "0"; string serieA_B = Convert.ToBoolean(modelCup.has_SerieA_B) ? "1" : "0"; string serieA_B_C = Convert.ToBoolean(modelCup.has_SerieA_B_C) ? "1" : "0"; string serieA_B_C_D = Convert.ToBoolean(modelCup.has_SerieA_B_C_D) ? "1" : "0"; string nationalTeam = Convert.ToBoolean(modelCup.has_NationalTeams) ? "1" : "0"; paramName = new string[] { "pTpModalidade", "pSgCampeonato", "pDtInicio", "pQtTimes", "pQtDiasFase0", "pQtDiasPlayoff", "pInAtivo", "pInPorGrupo", "pQtGrupos", "pInPorPotes", "pInDestino", "pInOrigem", "pInSerieA", "pInSerieB", "pInSerieC", "pInSerieA_B", "pInSerieA_B_C", "pInSerieA_B_C_D", "pInSelecao" }; paramValue = new string[] { modelCup.modeType, modelCup.championshipType, modelCup.startDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]", modelCup.totalTeams.ToString(), modelCup.totalDaysToPlayStage0.ToString(), modelCup.totalDaysToPlayPlayoff.ToString(), active, byGroup, modelCup.totalGroups.ToString(), byGroupPots, destiny, source, justSerieA, justSerieB, justSerieC, serieA_B, serieA_B_C, serieA_B_C_D, nationalTeam }; db.executePROCNonResult("spUpdateChampionshipCupGenerateNewSeason", paramName, paramValue); } model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "addTeam") { paramName = new string[] { "pTpModalidade", "pSgCampeonato", "pIdStandard", "pIdItem", "pIdNumPote" }; paramValue = new string[] { model.modeType, model.championshipType, GlobalVariables.GENERATE_NEWSEASON_ITEM_TYPE_TEAM.ToString(), model.itemID.ToString(), model.poteNumber.ToString() }; db.executePROCNonResult("spAddTeamGenerateNewSeason", paramName, paramValue); getAllTeamToTheMainModel(ref model); model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "delTeam") { paramName = new string[] { "pTpModalidade", "pSgCampeonato", "pIdStandard", "pIdItem", "pNmItem" }; paramValue = new string[] { model.modeType, model.championshipType, GlobalVariables.GENERATE_NEWSEASON_ITEM_TYPE_TEAM.ToString(), model.itemID.ToString(), model.itemName }; db.executePROCNonResult("spDeleteTeamGenerateNewSeason", paramName, paramValue); getAllTeamToTheMainModel(ref model); model.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "validate") { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spValidGenerationNewSeason", paramName, paramValue); modelGenerate.DatabasesLookTheSame = false; modelGenerate.NewSeasonIsGenerated = false; modelGenerate.hasEuroCup = false; modelGenerate.hasEuropeLeague = false; modelGenerate.hasSerieB_FUT = false; modelGenerate.hasSerieB_PRO = false; modelGenerate.hasSerieD_H2H = false; modelGenerate.hasWorldCup = false; if (dt.Rows[0]["databasesLookTheSame"].ToString() == "1") { modelGenerate.DatabasesLookTheSame = true; } if (dt.Rows[0]["generateNewSeasonIsDone"].ToString() == "1") { modelGenerate.NewSeasonIsGenerated = true; } if (dt.Rows[0]["hasWorldCup"].ToString() == "1") { modelGenerate.hasWorldCup = true; } if (dt.Rows[0]["hasEuroCup"].ToString() == "1") { modelGenerate.hasEuroCup = true; } if (dt.Rows[0]["hasSerieD_H2H"].ToString() == "1") { modelGenerate.hasSerieD_H2H = true; } if (dt.Rows[0]["hasSerieB_FUT"].ToString() == "1") { modelGenerate.hasSerieB_FUT = true; } if (dt.Rows[0]["hasSerieB_PRO"].ToString() == "1") { modelGenerate.hasSerieB_PRO = true; } if (dt.Rows[0]["hasEuroLeague"].ToString() == "1") { modelGenerate.hasEuropeLeague = true; } modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "prepare-database-bkp") { paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spPrepareDatabaseBKPToNegerateNewSeason", paramName, paramValue); modelGenerate.DatabasesLookTheSame = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "prepare-generate") { modelGenerate = model.newSeasonModel; paramName = new string[] { }; paramValue = new string[] { }; dt = db.executePROC("spInitializeProxTemporada", paramName, paramValue); modelGenerate.currentSeasonID = Convert.ToInt16(dt.Rows[0]["PreviousTemporadaID"].ToString()); modelGenerate.preparationBkpDatabaseIsDone = true; //Today (23/07/19) we don't keep more the match comments modelGenerate.preparationCommentDatabaseIsDone = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-calculate-season-h2h") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp" }; paramValue = new string[] { modelGenerate.currentSeasonID.ToString() }; dt = db.executePROC("spCalculateEndOfTemporadaH2H", paramName, paramValue); modelGenerate.seasonID = Convert.ToInt16(dt.Rows[0]["NewTemporadaID"].ToString()); modelGenerate.seasonName = dt.Rows[0]["NewTemporadaName"].ToString(); modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-calculate-season-fut") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pIdNewTemp" }; paramValue = new string[] { modelGenerate.currentSeasonID.ToString(), modelGenerate.seasonID.ToString() }; db.executePROCNonResult("spCalculateEndOfTemporadaFUT", paramName, paramValue); modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-calculate-season-pro") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pIdNewTemp" }; paramValue = new string[] { modelGenerate.currentSeasonID.ToString(), modelGenerate.seasonID.ToString() }; db.executePROCNonResult("spCalculateEndOfTemporadaPRO", paramName, paramValue); modelGenerate.calculateEndOfSeasonIsDone = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-championships-league-h2h") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "SERIE_A", "DIV1", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieAID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieAID_H2H > 0) { modelGenerate.serieAIsGenerated_H2H = true; } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "SERIE_B", "DIV2", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieBID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieBID_H2H > 0) { modelGenerate.serieBIsGenerated_H2H = true; } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "SERIE_C", "DIV3", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieCID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieCID_H2H > 0) { modelGenerate.serieCIsGenerated_H2H = true; } modelGenerate.serieDID_H2H = 0; if (modelGenerate.hasSerieD_H2H) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "SERIE_D", "DIV4", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieDID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieDID_H2H > 0) { modelGenerate.serieDIsGenerated_H2H = true; } } paramName = new string[] { "pIdTemp", "pIdSerieA", "pIdSerieB", "pIdSerieC", "pIdSerieD", "pQtLimitMaxLstNegra", "pCodAcessoTapetao", "pCodAcesso", "pCodAcessoRelegated", "pCodAcessoInvited" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), modelGenerate.serieAID_H2H.ToString(), modelGenerate.serieBID_H2H.ToString(), modelGenerate.serieCID_H2H.ToString(), modelGenerate.serieDID_H2H.ToString(), ConfigurationManager.AppSettings["renewal.total.limit.blackList"].ToString(), ConfigurationManager.AppSettings["access.current.season.access.direct"].ToString(), ConfigurationManager.AppSettings["access.current.season.access"].ToString(), ConfigurationManager.AppSettings["access.current.season.access"].ToString(), ConfigurationManager.AppSettings["access.current.season.invite"].ToString() }; dt = db.executePROC("spRellocationLigasH2H", paramName, paramValue); modelGenerate.rellocationOfSeries_H2H = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-championships-cup-h2h") { modelGenerate = model.newSeasonModel; modelGenerate.worldCupID_H2H = 0; if (modelGenerate.hasWorldCup) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "WORLDCP", "CPDM", VARIABLE_TRUE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.worldCupID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.worldCupID_H2H > 0) { modelGenerate.worldCupIsGenerated = true; } } modelGenerate.euroCupID_H2H = 0; if (modelGenerate.hasEuroCup) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "EUROCUP", "ERCP", VARIABLE_TRUE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.euroCupID_H2H = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.euroCupID_H2H > 0) { modelGenerate.euroCupIsGenerated = true; } } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "CHAMPLG", "CPGL", VARIABLE_TRUE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.championsLeagueID = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.championsLeagueID > 0) { modelGenerate.championsLeagueIsGenerated = true; } modelGenerate.europeLeagueID = 0; if (modelGenerate.hasEuropeLeague) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "EUROPLG", "CPSA", VARIABLE_TRUE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.europeLeagueID = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.europeLeagueID > 0) { modelGenerate.europeLeagueIsGenerated = true; } } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "H2H", "UEFACUP", "CPGL", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.uefaCupID = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.uefaCupID > 0) { modelGenerate.uefaCupIsGenerated = true; } modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-championships-fut") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "FUT", "SERIE_A", "FUT1", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieAID_FUT = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieAID_FUT > 0) { modelGenerate.serieAIsGenerated_FUT = true; } modelGenerate.serieBID_FUT = 0; if (modelGenerate.hasSerieB_FUT) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "FUT", "SERIE_B", "FUT2", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieBID_FUT = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieBID_FUT > 0) { modelGenerate.serieBIsGenerated_FUT = true; } } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "FUT", "FUT-CUP", "CFUT", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.futCupID = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.futCupID > 0) { modelGenerate.futCupIsGenerated = true; } modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-championships-pro") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "PRO", "SERIE_A", "PRO1", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieAID_PRO = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieAID_PRO > 0) { modelGenerate.serieAIsGenerated_PRO = true; } modelGenerate.serieBID_PRO = 0; if (modelGenerate.hasSerieB_PRO) { paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "PRO", "SERIE_B", "PRO2", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.serieBID_PRO = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.serieBID_PRO > 0) { modelGenerate.serieBIsGenerated_PRO = true; } } paramName = new string[] { "pIdTemp", "pTpModalidade", "pSgCampeonato", "pTpCamp", "pByGroup" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), "PRO", "PRO-CUP", "CPRO", VARIABLE_FALSE.ToString() + ";[BOOLEAN-TYPE]" }; dt = db.executePROC("spAddNewChampionship", paramName, paramValue); modelGenerate.proCupID = Convert.ToInt16(dt.Rows[0]["idCampNew"].ToString()); if (modelGenerate.proCupID > 0) { modelGenerate.proCupIsGenerated = true; } paramName = new string[] { "pIdTemp", "pIdCamp" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), modelGenerate.proCupID.ToString() }; dt = db.executePROC("spSubscriptionPlayersForPROCLUB", paramName, paramValue); modelGenerate.validationSquadOfProClubIsDone = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else if (model.actionUser == "generate-maintenance") { modelGenerate = model.newSeasonModel; paramName = new string[] { "pIdTemp", "pIdSerieA", "pIdSerieB", "pIdSerieC", "pIdSerieD", "pIdFutA", "pIdFutB", "pIdProA", "pIdProB" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), modelGenerate.serieAID_H2H.ToString(), modelGenerate.serieBID_H2H.ToString(), modelGenerate.serieCID_H2H.ToString(), modelGenerate.serieDID_H2H.ToString(), modelGenerate.serieAID_FUT.ToString(), modelGenerate.serieBID_FUT.ToString(), modelGenerate.serieAID_PRO.ToString(), modelGenerate.serieBID_PRO.ToString() }; dt = db.executePROC("spMaintenanceBancoAndManagers", paramName, paramValue); modelGenerate.maintenanceOfBenchIsDone = true; paramName = new string[] { "pIdTemp" }; paramValue = new string[] { modelGenerate.seasonID.ToString() }; dt = db.executePROC("spGenerateClashesNewTemporada", paramName, paramValue); modelGenerate.tableOfClashesIsDone = true; paramName = new string[] { "pIdTemp", "pIdSerieA" }; paramValue = new string[] { modelGenerate.seasonID.ToString(), modelGenerate.serieAID_H2H.ToString() }; dt = db.executePROC("spDeleteAllTablesForNewTemporada", paramName, paramValue); modelGenerate.purgingOfSystemTablesIsDone = true; modelGenerate.NewSeasonIsGenerated = true; modelGenerate.returnMessage = "GenerateNewSeasonSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { modelGenerate.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelGenerate)); } finally { db.closeConnection(); dt = null; modelLeague = null; modelCup = null; modelGenerate = null; } }
public IHttpActionResult postAccepting(AcceptingNewSeasonViewModel model) { if (String.IsNullOrEmpty(model.dataBaseName)) { model.dataBaseName = GlobalVariables.DATABASE_NAME_ONLINE; } db.openConnection(model.dataBaseName); var objFunctions = new Commons.functions(); AcceptingNewSeasonViewModel mainModel = new AcceptingNewSeasonViewModel(); AcceptingDetails modelDetails = new AcceptingDetails(); DataTable dt = null; try { if (model.actionUser == "save") { if (String.IsNullOrEmpty(model.confirmation)) { model.confirmation = null; } if (String.IsNullOrEmpty(model.teamName)) { model.teamName = null; } paramName = new string[] { "pIdTemporada", "pIdCampeonato", "pIdUsu", "pInConfirm", "pInOrdernacao", "pNmTimeFUT" }; paramValue = new string[] { Convert.ToString(model.seasonID), Convert.ToString(model.championshipID), Convert.ToString(model.userID), model.confirmation, model.ordering, model.teamName }; dt = db.executePROC("spAddUpdateConfirmacaoTemporada", paramName, paramValue); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getAllAccepting-staging") { model.listOfAccepting = getAllAccepting(db); model.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } else if (model.actionUser == "getAccepting-staging") { modelDetails = GetAccepting(db, model.seasonID, model.userID, model.championshipID); modelDetails.returnMessage = "ModeratorSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, modelDetails)); } else { return(StatusCode(HttpStatusCode.NotAcceptable)); } } catch (Exception ex) { model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); mainModel = null; dt = null; modelDetails = null; } }