Exemplo n.º 1
0
        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 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 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 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 IHttpActionResult subscribe(SubscribeBench model)
        {
            db.openConnection();

            try
            {
                if (model.checkH2H)
                {
                    paramName  = new string[] { "pIdUsu", "pNmTime", "pTpBanco" };
                    paramValue = new string[] { Convert.ToString(model.id), "", "H2H" };
                    db.executePROCNonResult("spAddBancoReserva", paramName, paramValue);
                }

                if (model.checkFUT)
                {
                    paramName  = new string[] { "pIdUsu", "pNmTime", "pTpBanco" };
                    paramValue = new string[] { Convert.ToString(model.id), model.teamNameFUT, "FUT" };
                    db.executePROCNonResult("spAddBancoReserva", paramName, paramValue);
                }

                if (model.checkPRO)
                {
                    paramName  = new string[] { "pIdUsu", "pNmTime", "pTpBanco" };
                    paramValue = new string[] { Convert.ToString(model.id), model.teamNamePRO, "PRO" };
                    db.executePROCNonResult("spAddBancoReserva", paramName, paramValue);

                    if (!String.IsNullOrWhiteSpace(model.mobile))
                    {
                        paramName  = new string[] { "pIdUsuario", "pDDD", "pMobile" };
                        paramValue = new string[] { Convert.ToString(model.id), model.ddd, model.mobile };
                        db.executePROCNonResult("spUpdateMobile", paramName, paramValue);
                    }
                }

                model.returnMessage = "subscribeBenchSuccessfully";
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            catch (Exception ex)
            {
                model = new SubscribeBench();
                model.returnMessage = "error_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
            }
        }
Exemplo n.º 8
0
        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;
            }
        }
Exemplo n.º 9
0
        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;
            }
        }
Exemplo n.º 10
0
        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;
            }
        }
Exemplo n.º 11
0
        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;
            }
        }
Exemplo n.º 12
0
        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;
            }
        }
Exemplo n.º 13
0
        public IHttpActionResult postBench(BenchModesViewModel model)
        {
            db.openConnection();
            var objFunctions = new Commons.functions();
            BenchDetailsModel        benchPlayersModel = new BenchDetailsModel();
            BenchModesViewModel      listBenchPlayers  = new BenchModesViewModel();
            List <BenchDetailsModel> listOfBench       = new List <BenchDetailsModel>();
            DataTable dt = null;

            try
            {
                if (model.actionUser == "listMainPage")
                {
                    string[] typeOfBench = { "H2H", "FUT", "PRO" };

                    for (int i = 0; i < typeOfBench.Length; i++)
                    {
                        paramName  = new string[] { "pTpBancoReserva" };
                        paramValue = new string[] { typeOfBench[i] };
                        dt         = db.executePROC("spGetAllBancoReservaByTipo", paramName, paramValue);

                        if (dt.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                benchPlayersModel           = new BenchDetailsModel();
                                benchPlayersModel.id        = Convert.ToInt16(dt.Rows[j]["ID_BANCO_RESERVA"]);
                                benchPlayersModel.userID    = Convert.ToInt16(dt.Rows[j]["ID_USUARIO"]);
                                benchPlayersModel.name      = dt.Rows[j]["NM_USUARIO"].ToString();
                                benchPlayersModel.psnID     = dt.Rows[j]["PSN_ID"].ToString();
                                benchPlayersModel.state     = dt.Rows[j]["DS_ESTADO"].ToString();
                                benchPlayersModel.team      = dt.Rows[j]["NM_TIME_FUT"].ToString();
                                benchPlayersModel.typeBench = typeOfBench[i];
                                listOfBench.Add(benchPlayersModel);
                            }
                        }
                    }

                    listBenchPlayers.listOfBench   = listOfBench;
                    listBenchPlayers.returnMessage = "getBenchSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, listBenchPlayers));
                }
                else if (model.actionUser == "dellCrud")
                {
                    BenchDetailsModel oDetails = model.listOfBench[0];

                    paramName  = new string[] { "pIdBancoReserva" };
                    paramValue = new string[] { Convert.ToString(oDetails.id) };
                    dt         = db.executePROC("spUpdateToEndBancoReservaById", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser == "moveCrud")
                {
                    BenchDetailsModel oDetails = model.listOfBench[0];

                    paramName  = new string[] { "pIdBancoReserva" };
                    paramValue = new string[] { Convert.ToString(oDetails.id) };
                    dt         = db.executePROC("spAddBancoReservaToEndOfQueue", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser == "addCrud")
                {
                    BenchDetailsModel oDetails = model.listOfBench[0];

                    paramName  = new string[] { "pIdUsu", "pNmTime", "pTpBanco" };
                    paramValue = new string[] { Convert.ToString(oDetails.userID), oDetails.team, oDetails.typeBench };
                    dt         = db.executePROC("spAddBancoReserva", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                listBenchPlayers = new BenchModesViewModel();
                listBenchPlayers.returnMessage = "error_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, listBenchPlayers));
            }
            finally
            {
                db.closeConnection();
                benchPlayersModel = null;
                listBenchPlayers  = null;
                listOfBench       = null;
                dt = null;
            }
        }
Exemplo n.º 14
0
        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;
            }
        }
Exemplo n.º 15
0
        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;
            }
        }
Exemplo n.º 16
0
        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 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 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;
            }
        }
Exemplo n.º 19
0
        public IHttpActionResult GetAllByChampionship(string id)
        {
            ChampionshipUserDetailsModel        modelDetails = new ChampionshipUserDetailsModel();
            ChampionshipUserListViewModel       mainModel    = new ChampionshipUserListViewModel();
            List <ChampionshipUserDetailsModel> listOfModel  = new List <ChampionshipUserDetailsModel>();
            DataTable dt = null;

            db.openConnection();


            try
            {
                if (id.All(char.IsDigit))
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { id };
                    dt         = db.executePROC("spGetAllUsuariosOfCampeonato", paramName, paramValue);

                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        modelDetails       = new ChampionshipUserDetailsModel();
                        modelDetails.id    = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                        modelDetails.name  = dt.Rows[i]["NM_USUARIO"].ToString();
                        modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString();
                        modelDetails.email = dt.Rows[i]["DS_EMAIL"].ToString();
                        listOfModel.Add(modelDetails);
                    }
                }
                else
                {
                    if (id.IndexOf("BCO") == -1 && id.IndexOf("|") == -1)
                    {
                        paramName  = new string[] { "pTipo" };
                        paramValue = new string[] { id };
                        dt         = db.executePROC("spGetAllUsuariosOfCampeonatoByTipo", paramName, paramValue);
                    }
                    else if (id.IndexOf("BCO") > -1 && id.IndexOf("|") == -1)
                    {
                        paramName  = new string[] { "pTpBancoReserva" };
                        paramValue = new string[] { id.Substring(4, 3) };
                        dt         = db.executePROC("spGetAllBancoReservaByTipo", paramName, paramValue);
                    }
                    else if (id.IndexOf("BCO") == -1 && id.IndexOf("|") > -1)
                    {
                        string[] arrayParam = id.Split(Convert.ToChar("|"));

                        paramName  = new string[] { "pIdCamp", "pTipo" };
                        paramValue = new string[] { arrayParam[0], arrayParam[1] };
                        dt         = db.executePROC("spGetAllCampeonatoUsuarioToExchange", paramName, paramValue);
                    }

                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        modelDetails       = new ChampionshipUserDetailsModel();
                        modelDetails.id    = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                        modelDetails.name  = dt.Rows[i]["NM_USUARIO"].ToString();
                        modelDetails.psnID = dt.Rows[i]["PSN_ID"].ToString();
                        modelDetails.email = dt.Rows[i]["DS_EMAIL"].ToString();
                        listOfModel.Add(modelDetails);
                    }
                }

                mainModel.listOfUser    = listOfModel;
                mainModel.returnMessage = "ModeratorSuccessfully";
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }

            catch (Exception ex)
            {
                mainModel               = new ChampionshipUserListViewModel();
                mainModel.listOfUser    = new List <ChampionshipUserDetailsModel>();
                mainModel.returnMessage = "errorGetAllChampionshipUser_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }
            finally
            {
                db.closeConnection();
                modelDetails = null;
                mainModel    = null;
                listOfModel  = null;
                dt           = null;
            }
        }
Exemplo n.º 20
0
        public IHttpActionResult team(TeamDetailsModel model)
        {
            db.openConnection();
            DataTable dt           = null;
            var       objFunctions = new Commons.functions();

            try
            {
                if (model.actionUser.ToLower() == "dellcrud")
                {
                    paramName  = new string[] { "idTime" };
                    paramValue = new string[] { Convert.ToString(model.id) };
                    dt         = db.executePROC("spDeleteTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id > 0)
                {
                    paramName = new string[] { "pIdTime", "pNmTime", "pdsUrl", "pIdTipo", "pIdTimeSofifa", "pIdTecnico" };

                    paramValue = new string[] { Convert.ToString(model.id), model.name, model.teamSofifaURL,
                                                Convert.ToString(model.typeModeID), Convert.ToString(model.teamSofifaID),
                                                Convert.ToString(model.userID) };

                    dt = db.executePROC("spAddTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id == 0)
                {
                    paramName = new string[] { "pNmTime", "pdsUrl", "pIdTipo", "pIdTimeSofifa", "pIdTecnico" };

                    paramValue = new string[] { model.name, model.teamSofifaURL, Convert.ToString(model.typeModeID),
                                                Convert.ToString(model.teamSofifaID), Convert.ToString(model.userID) };


                    dt = db.executePROC("spAddTime", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "updateteamplayerslist")
                {
                    string getHtmlSofifaTeamPlayersList = objFunctions.getTeamSofifaHTML(model.teamSofifaURL);

                    processSofifaHTML(getHtmlSofifaTeamPlayersList, ref model);

                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model.returnMessage = "errorPostTeam_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
                dt           = null;
                objFunctions = null;
            }
        }
Exemplo n.º 21
0
        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));
            }
        }
Exemplo n.º 22
0
        public IHttpActionResult hallOfFame(HallOfFameSummaryViewModel model)
        {
            if (String.IsNullOrEmpty(model.dataBaseName))
            {
                model.dataBaseName = GlobalVariables.DATABASE_NAME_ONLINE;
            }
            db.openConnection(model.dataBaseName);
            DataTable dt            = null;
            string    returnMessage = String.Empty;

            try
            {
                if (model.actionUser == "summary")
                {
                    paramName  = new string[] {  };
                    paramValue = new string[] {  };
                    dt         = db.executePROC("spGetSummaryHallOfFame", paramName, paramValue);

                    model.psnIDSerieAH2H  = dt.Rows[0]["psnIDH2HChampion"].ToString();
                    model.teamIDSerieAH2H = dt.Rows[0]["teamNameH2HChampion"].ToString();

                    model.psnIDSerieAFUT  = dt.Rows[0]["psnIDFUTChampion"].ToString();
                    model.teamIDSerieAFUT = dt.Rows[0]["teamNameFUTChampion"].ToString();

                    model.psnIDSerieAPRO  = dt.Rows[0]["psnIDPROChampion"].ToString();
                    model.teamIDSerieAPRO = dt.Rows[0]["teamNamePROChampion"].ToString();

                    model.psnIDCDM  = dt.Rows[0]["psnIDCDMChampion"].ToString();
                    model.teamIDCDM = dt.Rows[0]["teamNameCDMChampion"].ToString();

                    model.psnIDUCL  = dt.Rows[0]["psnIDUCLChampion"].ToString();
                    model.teamIDUCL = dt.Rows[0]["teamNameUCLChampion"].ToString();

                    model.psnIDSCP  = dt.Rows[0]["psnIDSCPChampion"].ToString();
                    model.teamIDSCP = dt.Rows[0]["teamNameSCPChampion"].ToString();

                    model.returnMessage = "HallOfFameSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser == "championshipScoring")
                {
                    paramName  = new string[] { };
                    paramValue = new string[] { };
                    dt         = db.executePROC("spGetAllCampeonatosScoring", paramName, paramValue);

                    ChampionshipScoreViewModel   championshipScoring = new ChampionshipScoreViewModel();
                    ChampionshipTypeModel        championshipType    = new ChampionshipTypeModel();
                    List <ChampionshipTypeModel> listOfChampionship  = new List <ChampionshipTypeModel>();

                    try
                    {
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            championshipType = new ChampionshipTypeModel();
                            championshipType.championshipType      = dt.Rows[i]["SG_TIPO_CAMPEONATO"].ToString();
                            championshipType.scoreChampion         = Convert.ToInt16(dt.Rows[i]["PT_CAMPEAO"].ToString());
                            championshipType.scoreVice             = Convert.ToInt16(dt.Rows[i]["PT_VICECAMPEAO"].ToString());
                            championshipType.scoreSemi             = Convert.ToInt16(dt.Rows[i]["PT_SEMIS"].ToString());
                            championshipType.scoreQuarter          = Convert.ToInt16(dt.Rows[i]["PT_QUARTAS"].ToString());
                            championshipType.scoreRound16          = Convert.ToInt16(dt.Rows[i]["PT_OITAVAS"].ToString());
                            championshipType.scoreQualifyNextStage = Convert.ToInt16(dt.Rows[i]["PT_CLASSIF_FASE2"].ToString());
                            championshipType.scoreWins             = Convert.ToInt16(dt.Rows[i]["PT_VITORIAS_FASE1"].ToString());
                            championshipType.scoreDraws            = Convert.ToInt16(dt.Rows[i]["PT_EMPATES_FASE1"].ToString());
                            championshipType.score2ndStage         = Convert.ToInt16(dt.Rows[i]["PT_FASE2"].ToString());
                            listOfChampionship.Add(championshipType);
                        }

                        championshipScoring.listChampionshipScore = listOfChampionship;
                        championshipScoring.returnMessage         = "HallOfFameSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, championshipScoring));
                    }
                    catch (Exception ex)
                    {
                        championshipScoring = new ChampionshipScoreViewModel();
                        model.returnMessage = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, championshipScoring));
                    }
                    finally
                    {
                        championshipScoring = null;
                        championshipType    = null;
                        listOfChampionship  = null;
                    }
                }
                else if (model.actionUser == "blackList")
                {
                    paramName  = new string[] { };
                    paramValue = new string[] { };
                    dt         = db.executePROC("spGetAllListaNegra", paramName, paramValue);

                    GeneralBlackListViewModel    blackListModel       = new GeneralBlackListViewModel();
                    GeneralBlackListModel        listGeneralBlackList = new GeneralBlackListModel();
                    List <GeneralBlackListModel> listOfBlackList      = new List <GeneralBlackListModel>();

                    try
                    {
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            listGeneralBlackList          = new GeneralBlackListModel();
                            listGeneralBlackList.psnID    = dt.Rows[i]["PSN_ID"].ToString();
                            listGeneralBlackList.userName = dt.Rows[i]["NM_USUARIO"].ToString();
                            listGeneralBlackList.total    = Convert.ToInt16(dt.Rows[i]["TOTAL_GERAL"].ToString());
                            if (!String.IsNullOrEmpty(dt.Rows[i]["TOTAL_TEMP"].ToString()))
                            {
                                listGeneralBlackList.totalPreviousSeason = Convert.ToInt16(dt.Rows[i]["TOTAL_TEMP"].ToString());
                            }
                            else
                            {
                                listGeneralBlackList.totalPreviousSeason = 0;
                            }
                            listOfBlackList.Add(listGeneralBlackList);
                        }

                        blackListModel.listBlackList = listOfBlackList;
                        blackListModel.returnMessage = "HallOfFameSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, blackListModel));
                    }
                    catch (Exception ex)
                    {
                        blackListModel      = new GeneralBlackListViewModel();
                        model.returnMessage = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, blackListModel));
                    }
                    finally
                    {
                        blackListModel       = null;
                        listGeneralBlackList = null;
                        listOfBlackList      = null;
                    }
                }
                else if (model.actionUser == "renewal")
                {
                    RenewalChampionshipModel        renewalChampionship = new RenewalChampionshipModel();
                    RenewalViewModel                RenewalModel        = new RenewalViewModel();
                    List <RenewalChampionshipModel> listOfRenewal       = new List <RenewalChampionshipModel>();
                    int totAcceptedApproved = 0;
                    int totUnderAnalysis    = 0;

                    int blackListPoints = 0;

                    try
                    {
                        if (model.seasonID == 0)
                        {
                            paramName  = new string[] { "pMode" };
                            paramValue = new string[] { "" };
                            dt         = db.executePROC("spGetIDsTemporadaByMode", paramName, paramValue);

                            model.seasonID           = Convert.ToInt32(dt.Rows[0]["id_current_temporada"].ToString());
                            model.seasonName         = dt.Rows[0]["nm_current_temporada"].ToString();
                            model.previousSeasonID   = Convert.ToInt32(dt.Rows[0]["id_previous_temporada"].ToString());
                            model.previousSeasonName = dt.Rows[0]["nm_previous_temporada"].ToString();
                        }

                        paramName  = new string[] { "pIdTemporada", "pIdTemporadaAnt", "pIdsCampeonato" };
                        paramValue = new string[] { Convert.ToString(model.seasonID), Convert.ToString(model.previousSeasonID), model.championshipIDRenewal };

                        if (model.renewalMode == "H2H")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoH2H", paramName, paramValue);
                        }
                        else if (model.renewalMode == "FUT")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoFUT", paramName, paramValue);
                        }
                        else if (model.renewalMode == "PRO")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoPRO", paramName, paramValue);
                        }

                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            renewalChampionship                = new RenewalChampionshipModel();
                            renewalChampionship.psnID          = dt.Rows[i]["PSN_ID"].ToString();
                            renewalChampionship.userName       = dt.Rows[i]["NM_USUARIO"].ToString();
                            renewalChampionship.userID         = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                            renewalChampionship.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString());
                            renewalChampionship.teamName       = dt.Rows[i]["NM_TIME"].ToString();

                            if (String.IsNullOrEmpty(dt.Rows[i]["PT_LSTNEGRA"].ToString()))
                            {
                                blackListPoints = 0;
                            }
                            else
                            {
                                blackListPoints = Convert.ToInt32(dt.Rows[i]["PT_LSTNEGRA"].ToString());
                            }


                            if (String.IsNullOrEmpty(dt.Rows[i]["IN_CONFIRMACAO"].ToString()))
                            {
                                renewalChampionship.actionRenewal   = "Ainda não confirmou";
                                renewalChampionship.acceptedRenewal = "-1";
                                renewalChampionship.status          = "AGUARDANDO";
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1 && blackListPoints >= model.totalLimitBlackList)
                            {
                                renewalChampionship.actionRenewal   = "Confirmou, mas chegou ao limite de pontos na Lista Negra";
                                renewalChampionship.acceptedRenewal = "9";
                                renewalChampionship.status          = "NÃO ACEITO";
                                totUnderAnalysis += 1;
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1)
                            {
                                renewalChampionship.actionRenewal   = "Confirmou Participação";
                                renewalChampionship.acceptedRenewal = "1";
                                renewalChampionship.status          = "APROVADO";
                                totAcceptedApproved += 1;
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 0)
                            {
                                renewalChampionship.actionRenewal   = "Não deseja Participar";
                                renewalChampionship.acceptedRenewal = "0";
                                renewalChampionship.status          = "DESISTIU";
                            }

                            renewalChampionship.statusInitials = dt.Rows[i]["DS_STATUS"].ToString();


                            if (model.renewalMode == "PRO")
                            {
                                renewalChampionship.playersTotal = Convert.ToInt32(dt.Rows[i]["TOTAL_JOGADORES"].ToString());
                            }

                            renewalChampionship.blackListtotal = blackListPoints;

                            if (String.IsNullOrEmpty(dt.Rows[i]["PT_TOTAL"].ToString()))
                            {
                                renewalChampionship.total = 0;
                            }
                            else
                            {
                                renewalChampionship.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString());
                            }

                            if (String.IsNullOrEmpty(dt.Rows[i]["PT_TOTAL_ATUAL"].ToString()))
                            {
                                renewalChampionship.seasonCurrentTotal = 0;
                            }
                            else
                            {
                                renewalChampionship.seasonCurrentTotal = Convert.ToInt32(dt.Rows[i]["PT_TOTAL_ATUAL"].ToString());
                            }

                            renewalChampionship.grandTotal = renewalChampionship.total + renewalChampionship.seasonCurrentTotal;

                            listOfRenewal.Add(renewalChampionship);
                        }


                        //get all of the bench
                        paramName  = new string[] { "pIdTemporada", "pIdTemporadaAnt", "pIdsCampeonato" };
                        paramValue = new string[] { Convert.ToString(model.seasonID), Convert.ToString(model.previousSeasonID), model.championshipIDBenchRenewal };

                        if (model.renewalMode == "H2H")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoH2HBco", paramName, paramValue);
                        }
                        else if (model.renewalMode == "FUT")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoFUTBco", paramName, paramValue);
                        }
                        else if (model.renewalMode == "PRO")
                        {
                            dt = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoPROBco", paramName, paramValue);
                        }
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            renewalChampionship                = new RenewalChampionshipModel();
                            renewalChampionship.psnID          = dt.Rows[i]["PSN_ID"].ToString();
                            renewalChampionship.userName       = dt.Rows[i]["NM_USUARIO"].ToString();
                            renewalChampionship.userID         = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                            renewalChampionship.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString());
                            renewalChampionship.teamName       = dt.Rows[i]["NM_TIME"].ToString();

                            if (String.IsNullOrEmpty(dt.Rows[i]["PT_LSTNEGRA"].ToString()))
                            {
                                blackListPoints = 0;
                            }
                            else
                            {
                                blackListPoints = Convert.ToInt32(dt.Rows[i]["PT_LSTNEGRA"].ToString());
                            }


                            if (String.IsNullOrEmpty(dt.Rows[i]["IN_CONFIRMACAO"].ToString()))
                            {
                                renewalChampionship.actionRenewal   = "Ainda não confirmou";
                                renewalChampionship.acceptedRenewal = "-1";
                                renewalChampionship.status          = "AGUARDANDO";
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1 && blackListPoints >= model.totalLimitBlackList)
                            {
                                renewalChampionship.actionRenewal   = "Confirmou, mas chegou ao limite de pontos na Lista Negra";
                                renewalChampionship.acceptedRenewal = "9";
                                renewalChampionship.status          = "NÃO ACEITO";
                                totUnderAnalysis += 1;
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1)
                            {
                                renewalChampionship.actionRenewal   = "Confirmou Participação";
                                renewalChampionship.acceptedRenewal = "1";
                                renewalChampionship.status          = "APROVADO";
                                totAcceptedApproved += 1;
                            }
                            else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 0)
                            {
                                renewalChampionship.actionRenewal   = "Não deseja Participar";
                                renewalChampionship.acceptedRenewal = "0";
                                renewalChampionship.status          = "DESISTIU";
                            }

                            renewalChampionship.statusInitials = dt.Rows[i]["DS_STATUS"].ToString();


                            if (model.renewalMode == "PRO")
                            {
                                renewalChampionship.playersTotal = Convert.ToInt32(dt.Rows[i]["TOTAL_JOGADORES"].ToString());
                            }

                            renewalChampionship.blackListtotal = blackListPoints;
                            if (String.IsNullOrEmpty(dt.Rows[i]["PT_TOTAL"].ToString()))
                            {
                                renewalChampionship.total = 0;
                            }
                            else
                            {
                                renewalChampionship.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString());
                            }
                            renewalChampionship.seasonCurrentTotal = 0; // Convert.ToInt16(dt.Rows[i]["PT_TOTAL_ATUAL"].ToString());
                            renewalChampionship.grandTotal         = renewalChampionship.total + renewalChampionship.seasonCurrentTotal;

                            listOfRenewal.Add(renewalChampionship);
                        }


                        //get all of H2H world cup or ueaf euro
                        if (model.renewalMode == "H2H" && !String.IsNullOrEmpty(model.championshipIDRenewalWorldCupUefaEuro))
                        {
                            paramName  = new string[] { "pIdTemporada", "pIdTemporadaAnt", "pIdsCampeonato" };
                            paramValue = new string[] { Convert.ToString(model.seasonID), Convert.ToString(model.previousSeasonID), model.championshipIDRenewalWorldCupUefaEuro };
                            dt         = db.executePROC("spGetAllConfirmacaoTemporadaOfCampeonatoCDM", paramName, paramValue);

                            for (var i = 0; i < dt.Rows.Count; i++)
                            {
                                renewalChampionship                = new RenewalChampionshipModel();
                                renewalChampionship.psnID          = dt.Rows[i]["PSN_ID"].ToString();
                                renewalChampionship.userName       = dt.Rows[i]["NM_USUARIO"].ToString();
                                renewalChampionship.userID         = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                                renewalChampionship.championshipID = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString());
                                renewalChampionship.teamName       = String.Empty;

                                if (String.IsNullOrEmpty(dt.Rows[i]["PT_LSTNEGRA"].ToString()))
                                {
                                    blackListPoints = 0;
                                }
                                else
                                {
                                    blackListPoints = Convert.ToInt32(dt.Rows[i]["PT_LSTNEGRA"].ToString());
                                }


                                if (String.IsNullOrEmpty(dt.Rows[i]["IN_CONFIRMACAO"].ToString()))
                                {
                                    renewalChampionship.actionRenewal   = "Ainda não confirmou";
                                    renewalChampionship.acceptedRenewal = "-1";
                                    renewalChampionship.status          = "AGUARDANDO";
                                }
                                else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1 && blackListPoints >= model.totalLimitBanWorldCupUefaEuro)
                                {
                                    renewalChampionship.actionRenewal   = "Confirmou, mas chegou ao limite de pontos na Lista Negra para Copa do Mundo/Eurocopa";
                                    renewalChampionship.acceptedRenewal = "9";
                                    renewalChampionship.status          = "NÃO ACEITO";
                                }
                                else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 1)
                                {
                                    renewalChampionship.actionRenewal   = "Confirmou Participação";
                                    renewalChampionship.acceptedRenewal = "1";
                                    renewalChampionship.status          = "APROVADO";
                                }
                                else if (Convert.ToInt16(dt.Rows[i]["IN_CONFIRMACAO"].ToString()) == 0)
                                {
                                    renewalChampionship.actionRenewal   = "Não deseja Participar";
                                    renewalChampionship.acceptedRenewal = "0";
                                    renewalChampionship.status          = "DESISTIU";
                                }

                                renewalChampionship.statusInitials = dt.Rows[i]["DS_STATUS"].ToString();


                                renewalChampionship.blackListtotal = blackListPoints;

                                if (String.IsNullOrEmpty(dt.Rows[i]["PT_TOTAL"].ToString()))
                                {
                                    renewalChampionship.total = 0;
                                }
                                else
                                {
                                    renewalChampionship.total = Convert.ToInt32(dt.Rows[i]["PT_TOTAL"].ToString());
                                }

                                if (String.IsNullOrEmpty(dt.Rows[i]["PT_TOTAL_ATUAL"].ToString()))
                                {
                                    renewalChampionship.seasonCurrentTotal = 0;
                                }
                                else
                                {
                                    renewalChampionship.seasonCurrentTotal = Convert.ToInt32(dt.Rows[i]["PT_TOTAL_ATUAL"].ToString());
                                }

                                renewalChampionship.grandTotal = renewalChampionship.total + renewalChampionship.seasonCurrentTotal;

                                listOfRenewal.Add(renewalChampionship);
                            }
                        }

                        RenewalModel.renewalMode                           = model.renewalMode;
                        RenewalModel.seasonID                              = model.seasonID;
                        RenewalModel.seasonName                            = model.seasonName;
                        RenewalModel.previousSeasonID                      = model.previousSeasonID;
                        RenewalModel.previousSeasonName                    = model.previousSeasonName;
                        RenewalModel.championshipIDBenchRenewal            = model.championshipIDBenchRenewal;
                        RenewalModel.championshipIDRenewal                 = model.championshipIDRenewal;
                        RenewalModel.championshipIDRenewalWorldCupUefaEuro = model.championshipIDRenewalWorldCupUefaEuro;
                        RenewalModel.totalApprovedRenewal                  = totAcceptedApproved;
                        RenewalModel.totalUnderAnalysisRenewal             = totUnderAnalysis;
                        RenewalModel.listOfRenewal                         = listOfRenewal;
                        RenewalModel.returnMessage                         = "HallOfFameSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, RenewalModel));
                    }
                    catch (Exception ex)
                    {
                        RenewalModel        = new RenewalViewModel();
                        model.returnMessage = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, RenewalModel));
                    }
                    finally
                    {
                        renewalChampionship = null;
                        RenewalModel        = null;
                        listOfRenewal       = null;
                    }
                }
                else if (model.actionUser == "renewalSquad")
                {
                    RenewalPROCLUBSquadViewModel PROCLUBSquadModel = new RenewalPROCLUBSquadViewModel();
                    squadListModel        renewalSquad             = new squadListModel();
                    List <squadListModel> listOfSquad = new List <squadListModel>();

                    PROCLUBSquadModel.managerID = model.managerID;
                    PROCLUBSquadModel.seasonID  = model.seasonID;
                    PROCLUBSquadModel.clubName  = model.clubName;

                    try
                    {
                        paramName  = new string[] { "pIdUsuario" };
                        paramValue = new string[] { Convert.ToString(PROCLUBSquadModel.managerID) };
                        dt         = db.executePROC("spGetUsuarioById", paramName, paramValue);

                        PROCLUBSquadModel.psnID            = dt.Rows[0]["PSN_ID"].ToString();
                        PROCLUBSquadModel.mangerName       = dt.Rows[0]["NM_USUARIO"].ToString();
                        PROCLUBSquadModel.mobileNumber     = dt.Rows[0]["NO_CELULAR"].ToString();
                        PROCLUBSquadModel.codeMobileNumber = dt.Rows[0]["NO_DDD"].ToString();

                        PROCLUBSquadModel.listOfSquad   = GlobalFunctions.getListOfSquadPROCLUB(db, model.seasonID, model.managerID, out returnMessage);
                        PROCLUBSquadModel.returnMessage = "HallOfFameSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, PROCLUBSquadModel));
                    }
                    catch (Exception ex)
                    {
                        PROCLUBSquadModel   = new RenewalPROCLUBSquadViewModel();
                        model.returnMessage = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, PROCLUBSquadModel));
                    }
                    finally
                    {
                        PROCLUBSquadModel = null;
                        renewalSquad      = null;
                        listOfSquad       = null;
                    }
                }
                else if (model.actionUser.Substring(0, 11) == "achievement")
                {
                    paramName  = new string[] { };
                    paramValue = new string[] { };
                    if (model.actionUser.IndexOf("H2H") > 0)
                    {
                        dt = db.executePROC("spGetAchievementH2H", paramName, paramValue);
                    }
                    else if (model.actionUser.IndexOf("FUT") > 0)
                    {
                        dt = db.executePROC("spGetAchievementFUT", paramName, paramValue);
                    }
                    else if (model.actionUser.IndexOf("PRO") > 0)
                    {
                        dt = db.executePROC("spGetAchievementPRO", paramName, paramValue);
                    }

                    AchievementViewModel    GeneralAchievementModel = new AchievementViewModel();
                    AchievementModel        achievementModel        = new AchievementModel();
                    List <AchievementModel> listOfAchievement       = new List <AchievementModel>();

                    try
                    {
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            achievementModel = new AchievementModel();
                            achievementModel.championshipType = dt.Rows[i]["SG_TIPO_CAMPEONATO"].ToString();
                            achievementModel.inGroup          = Convert.ToBoolean(dt.Rows[i]["IN_CAMPEONATO_GRUPO"].ToString());
                            achievementModel.seasonName       = dt.Rows[i]["ID_TEMPORADA"].ToString() + "ª Temporada (" + dt.Rows[i]["IN_CONSOLE"].ToString() + ")";
                            achievementModel.userName         = dt.Rows[i]["NM_USUARIO"].ToString() + " (" + dt.Rows[i]["PSN_ID"].ToString() + ")";
                            achievementModel.teamName         = dt.Rows[i]["NM_TIME"].ToString() + "-" + dt.Rows[i]["DS_TIPO"].ToString();
                            listOfAchievement.Add(achievementModel);
                        }

                        GeneralAchievementModel.listOfAchievement = listOfAchievement;
                        GeneralAchievementModel.returnMessage     = "HallOfFameSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, GeneralAchievementModel));
                    }
                    catch (Exception ex)
                    {
                        GeneralAchievementModel = new AchievementViewModel();
                        model.returnMessage     = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, GeneralAchievementModel));
                    }
                    finally
                    {
                        GeneralAchievementModel = null;
                        listOfAchievement       = null;
                        achievementModel        = null;
                    }
                }

                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model = new HallOfFameSummaryViewModel();
                model.returnMessage = "error_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
                dt = 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 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;
            }
        }
Exemplo n.º 25
0
        public IHttpActionResult postUser(UserDetailsModel model)
        {
            UserDetailsModel        modelDetails = new UserDetailsModel();
            UserViewModel           mainModel    = new UserViewModel();
            List <UserDetailsModel> listOfModel  = new List <UserDetailsModel>();

            db.openConnection();
            DataTable dt = null;

            try
            {
                if (model.actionUser.ToLower() == "dellcrud")
                {
                    paramName  = new string[] { "pIdUsuario", "pIdUsuarioOperacao", "pPsnUsuarioOperacao", "pDsPaginaOperacao" };
                    paramValue = new string[] { Convert.ToString(model.id), Convert.ToString(model.idOperator), model.psnIDOperator, model.pageName };
                    dt         = db.executePROC("spDeleteUsuario", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id > 0)
                {
                    paramName  = new string[] { "pIdUsuario", "pdsPsn", "pNmUsuario", "pDsEmail" };
                    paramValue = new string[] { Convert.ToString(model.id), model.psnID, model.name, model.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(model.receiveWarningEachRound) ? "1" : "0";
                        string receiveTeamTable        = Convert.ToBoolean(model.receiveTeamTable) ? "1" : "0";
                        string wishParticipate         = Convert.ToBoolean(model.wishParticipate) ? "1" : "0";
                        string userActive    = Convert.ToBoolean(model.userActive) ? "1" : "0";
                        string userModerator = Convert.ToBoolean(model.userModerator) ? "1" : "0";

                        paramValue = new string[] { Convert.ToString(model.id), model.name, model.email, model.psnID, userActive,
                                                    model.howfindus, model.whatkindofmedia, model.team, model.birthday.ToString("dd/MM/yyyy") + ";[DATE-TYPE]",
                                                    model.state, receiveWarningEachRound, receiveTeamTable, wishParticipate,
                                                    userModerator, model.psnIDOperator, Convert.ToString(model.idOperator), model.psnIDOperator, "userController.Update" };


                        dt = db.executePROC("spUpdateUsuario", paramName, paramValue);

                        model.returnMessage = "ModeratorSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "1")
                    {
                        model.returnMessage = "PsnFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "2")
                    {
                        model.returnMessage = "NameFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "3")
                    {
                        model.returnMessage = "EmailFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else
                    {
                        model.returnMessage = "ValidationNotFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                }
                else if (model.actionUser.ToLower() == "save" && model.id == 0)
                {
                    paramName  = new string[] { "pdsPsn", "pNmUsuario", "pDsEmail" };
                    paramValue = new string[] { model.psnID, model.name, model.email };
                    dt         = db.executePROC("spValidateRegistrationOfUsuarioNewUsuario", paramName, paramValue);

                    var rowValRegister = dt.Rows[0];

                    if (rowValRegister["COD_VALIDATION"].ToString() == "0")
                    {
                        paramName = new string[] { "pNmUsuario", "pDsSenhaBase64", "pDsEmail", "pPsnId", "pInAtivo", "pDsFicouSabendo",
                                                   "pDsQual", "pNmTime", "pDtNasc", "pDsEstado", "pInReceberAlerta", "pInReceberSit",
                                                   "pInDesejaPartic", "pInModerador", "pDsPsnCadastro", "pIdUsuarioOperacao",
                                                   "pPsnUsuarioOperacao", "pDsPaginaOperacao" };

                        byte[] byt            = System.Text.Encoding.UTF8.GetBytes(model.password);
                        string passwordBase64 = Convert.ToBase64String(byt);

                        string receiveWarningEachRound = Convert.ToBoolean(model.receiveWarningEachRound) ? "1" : "0";
                        string receiveTeamTable        = Convert.ToBoolean(model.receiveTeamTable) ? "1" : "0";
                        string wishParticipate         = Convert.ToBoolean(model.wishParticipate) ? "1" : "0";
                        string userActive    = Convert.ToBoolean(model.userActive) ? "1" : "0";
                        string userModerator = Convert.ToBoolean(model.userModerator) ? "1" : "0";

                        paramValue = new string[] { model.name, passwordBase64, model.email, model.psnID, userActive,
                                                    model.howfindus, model.whatkindofmedia, model.team, model.birthday.ToString("dd/MM/yyyy") + ";[DATE-TYPE]",
                                                    model.state, receiveWarningEachRound, receiveTeamTable, wishParticipate,
                                                    userModerator, model.pageName, Convert.ToString(model.idOperator), model.psnIDOperator, "userController.Insert" };


                        dt = db.executePROC("spAddUsuario", paramName, paramValue);

                        model.returnMessage = "ModeratorSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "1")
                    {
                        model.returnMessage = "PsnFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "2")
                    {
                        model.returnMessage = "NameFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else if (rowValRegister["COD_VALIDATION"].ToString() == "3")
                    {
                        model.returnMessage = "EmailFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    else
                    {
                        model.returnMessage = "ValidationNotFound";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                }
                else if (model.actionUser.ToLower() == "getlistmoderator")
                {
                    paramName  = new string[] {  };
                    paramValue = new string[] {  };
                    dt         = db.executePROC("spGetAllActivateModeradores", paramName, paramValue);

                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        modelDetails               = new UserDetailsModel();
                        modelDetails.id            = Convert.ToInt16(dt.Rows[i]["ID_USUARIO"].ToString());
                        modelDetails.name          = dt.Rows[i]["NM_USUARIO"].ToString();
                        modelDetails.psnID         = dt.Rows[i]["PSN_ID"].ToString();
                        modelDetails.userActive    = Convert.ToBoolean(dt.Rows[i]["IN_USUARIO_ATIVO"].ToString());
                        modelDetails.userModerator = Convert.ToBoolean(dt.Rows[i]["IN_USUARIO_MODERADOR"].ToString());

                        listOfModel.Add(modelDetails);
                    }

                    mainModel.listOfUser    = listOfModel;
                    mainModel.returnMessage = "ModeratorSuccessfully";
                    return(Ok(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;
                modelDetails = null;
                mainModel    = null;
                listOfModel  = null;
            }
        }
        public IHttpActionResult ranking(SummaryViewModel model)
        {
            DataTable dt = null;

            try
            {
                if (model.actionUser == "summary")
                {
                    db.openConnection();
                    try
                    {
                        paramName  = new string[] { };
                        paramValue = new string[] { };
                        dt         = db.executePROC("spGetSummaryModeratorMenu", paramName, paramValue);

                        model.totalActiveCoaches  = Convert.ToInt16(dt.Rows[0]["totalActiveCoaches"].ToString());
                        model.totalSeasonCoaches  = Convert.ToInt16(dt.Rows[0]["totalSeasonCoaches"].ToString());
                        model.currentStageNameH2H = dt.Rows[0]["currentStageNameH2H"].ToString();

                        model.seasonNameH2H = dt.Rows[0]["seasonNameH2H"].ToString();
                        model.seasonNameFUT = dt.Rows[0]["seasonNameFUT"].ToString();
                        model.seasonNamePRO = dt.Rows[0]["seasonNamePRO"].ToString();

                        model.returnMessage = "ModeratorSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    catch (Exception ex)
                    {
                        model = new SummaryViewModel();
                        model.returnMessage = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                    }
                    finally
                    {
                    }
                }
                else if (model.actionUser == "spooler")
                {
                    db.openConnection("Connection.Database.Spooler");
                    SpoolerViewModel        SpoolerViewModel = new SpoolerViewModel();
                    List <SpoolerTypeModel> listProcessing   = new List <SpoolerTypeModel>();
                    List <SpoolerTypeModel> listWaiting      = new List <SpoolerTypeModel>();
                    List <SpoolerTypeModel> listFinished     = new List <SpoolerTypeModel>();
                    List <SpoolerTypeModel> listAdmin        = new List <SpoolerTypeModel>();

                    try
                    {
                        int    currentTime     = DateTime.Now.Hour;
                        int    currentDay      = DateTime.Now.Day;
                        int    currentMonth    = DateTime.Now.Month;
                        int    currentYear     = DateTime.Now.Year;
                        string nextProcessTime = String.Empty;

                        if (currentTime >= 22 && currentTime <= 23)
                        {
                            currentDay      = DateTime.Now.AddDays(1).Day;
                            currentMonth    = DateTime.Now.AddDays(1).Month;
                            currentYear     = DateTime.Now.AddDays(1).Year;
                            nextProcessTime = "04:00";
                        }
                        else if (currentTime >= 0 && currentTime < 4)
                        {
                            nextProcessTime = "04:00";
                        }
                        else if (currentTime >= 4 && currentTime < 6)
                        {
                            nextProcessTime = "06:00";
                        }
                        else if (currentTime >= 6 && currentTime < 8)
                        {
                            nextProcessTime = "08:00";
                        }
                        else if (currentTime >= 8 && currentTime < 10)
                        {
                            nextProcessTime = "10:00";
                        }
                        else if (currentTime >= 10 && currentTime < 12)
                        {
                            nextProcessTime = "12:00";
                        }
                        else if (currentTime >= 12 && currentTime < 14)
                        {
                            nextProcessTime = "14:00";
                        }
                        else if (currentTime >= 14 && currentTime < 16)
                        {
                            nextProcessTime = "16:00";
                        }
                        else if (currentTime >= 16 && currentTime < 18)
                        {
                            nextProcessTime = "18:00";
                        }
                        else if (currentTime >= 18 && currentTime < 20)
                        {
                            nextProcessTime = "20:00";
                        }
                        else if (currentTime >= 20 && currentTime < 22)
                        {
                            nextProcessTime = "22:00";
                        }


                        SpoolerViewModel.nextTimeProcessSpooler = currentDay.ToString("00") + "/" +
                                                                  currentMonth.ToString("00") + "/" +
                                                                  currentYear.ToString("0000") + " " +
                                                                  nextProcessTime + "h";


                        paramName      = new string[] { };
                        paramValue     = new string[] { };
                        dt             = db.executePROC("spGetAllSpoolerInProgress", paramName, paramValue);
                        listProcessing = subSetUpListReturnSpooler(dt);


                        dt          = db.executePROC("spGetAllSpoolerWaitingProcess", paramName, paramValue);
                        listWaiting = subSetUpListReturnSpooler(dt);

                        dt           = db.executePROC("spGetAllSpoolerFinished", paramName, paramValue);
                        listFinished = subSetUpListReturnSpooler(dt);

                        dt        = db.executePROC("spGetAllSpoolerAdmin", paramName, paramValue);
                        listAdmin = subSetUpListReturnSpooler(dt);

                        SpoolerViewModel.listSpoolerInProgress = listProcessing;
                        SpoolerViewModel.listSpoolerWaiting    = listWaiting;
                        SpoolerViewModel.listSpoolerFinished   = listFinished;
                        SpoolerViewModel.listSpoolerAdmin      = listAdmin;
                        SpoolerViewModel.returnMessage         = "ModeratorSuccessfully";
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, SpoolerViewModel));
                    }
                    catch (Exception ex)
                    {
                        SpoolerViewModel = new SpoolerViewModel();
                        SpoolerViewModel.listSpoolerInProgress = new List <SpoolerTypeModel>();
                        SpoolerViewModel.listSpoolerWaiting    = new List <SpoolerTypeModel>();
                        SpoolerViewModel.listSpoolerFinished   = new List <SpoolerTypeModel>();
                        SpoolerViewModel.listSpoolerAdmin      = new List <SpoolerTypeModel>();
                        SpoolerViewModel.returnMessage         = "error_" + ex.Message;
                        return(CreatedAtRoute("DefaultApi", new { id = 0 }, SpoolerViewModel));
                    }
                    finally
                    {
                        SpoolerViewModel = null;
                        listProcessing   = null;
                        listWaiting      = null;
                        listFinished     = null;
                        listAdmin        = null;
                    }
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model = new SummaryViewModel();
                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 blog(BlogDetailsModel model)
        {
            db.openConnection("Connection.Database.Blog");
            DataTable dt           = null;
            var       objFunctions = new Commons.functions();

            try
            {
                if (model.actionUser.ToLower() == "dellcrud")
                {
                    paramName  = new string[] { "pIdUser", "pIdBlog" };
                    paramValue = new string[] { Convert.ToString(model.userID), Convert.ToString(model.id) };
                    dt         = db.executePROC("spDeleteBlog", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id > 0)
                {
                    paramName = new string[] { "pIdUser", "pIdBlog", "pTitle", "pText" };

                    paramValue = new string[] { Convert.ToString(model.userID), Convert.ToString(model.id),
                                                model.title, model.text + "@[LONGTEXT-TYPE]" };

                    dt = db.executePROC("spUpdateBlog", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "save" && model.id == 0)
                {
                    paramName = new string[] { "pIdUser", "pTitle", "pDate", "pHour", "pText" };

                    paramValue = new string[] { Convert.ToString(model.userID), model.title,
                                                model.registerDate.ToString("dd/MM/yyyy") + ";[DATE-TYPE]", model.registerTime, model.text + "@[LONGTEXT-TYPE]" };


                    dt = db.executePROC("spAddBlog", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else if (model.actionUser.ToLower() == "sendWarningEmail")
                {
                    //coding
                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = model.id }, model));
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model.returnMessage = "errorPostBlog_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
                dt           = null;
                objFunctions = 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;
            }
        }
Exemplo n.º 30
0
        public IHttpActionResult GetAllForChampionship(int id)
        {
            ChampionshipTeamTableDetailsModel        modelDetails = new ChampionshipTeamTableDetailsModel();
            ChampionshipTeamTableListViewModel       mainModel    = new ChampionshipTeamTableListViewModel();
            List <ChampionshipTeamTableDetailsModel> listOfModel  = new List <ChampionshipTeamTableDetailsModel>();
            DataTable dt = null;

            db.openConnection();


            try
            {
                paramName  = new string[] { "pIdCamp" };
                paramValue = new string[] { Convert.ToString(id) };
                dt         = db.executePROC("spGetAllClassificacaoTimeOfCampeonato", paramName, paramValue);

                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    modelDetails = new ChampionshipTeamTableDetailsModel();
                    modelDetails.championshipID    = Convert.ToInt16(dt.Rows[i]["ID_CAMPEONATO"].ToString());
                    modelDetails.teamID            = Convert.ToInt16(dt.Rows[i]["ID_TIME"].ToString());
                    modelDetails.groupID           = Convert.ToInt16(dt.Rows[i]["ID_GRUPO"].ToString());
                    modelDetails.totalPoint        = Convert.ToInt16(dt.Rows[i]["QT_PONTOS_GANHOS"].ToString());
                    modelDetails.totalWon          = Convert.ToInt16(dt.Rows[i]["QT_VITORIAS"].ToString());
                    modelDetails.totalPlayed       = Convert.ToInt16(dt.Rows[i]["QT_JOGOS"].ToString());
                    modelDetails.totalDraw         = Convert.ToInt16(dt.Rows[i]["QT_EMPATES"].ToString());
                    modelDetails.totalLost         = Convert.ToInt16(dt.Rows[i]["QT_DERROTAS"].ToString());
                    modelDetails.totalGoalsFOR     = Convert.ToInt16(dt.Rows[i]["QT_GOLS_PRO"].ToString());
                    modelDetails.totalGoalsAGainst = Convert.ToInt16(dt.Rows[i]["QT_GOLS_CONTRA"].ToString());
                    if (!String.IsNullOrEmpty(dt.Rows[i]["IN_ORDENACAO_GRUPO"].ToString()))
                    {
                        modelDetails.orden = Convert.ToInt16(dt.Rows[i]["IN_ORDENACAO_GRUPO"].ToString());
                    }
                    if (dt.Rows[i]["DS_TIPO"].ToString().IndexOf("PRO") > -1 || dt.Rows[i]["DS_TIPO"].ToString().IndexOf("FUT") > -1)
                    {
                        modelDetails.teamName = GlobalFunctions.UppercaseFirstWords(dt.Rows[i]["NM_TIME"].ToString());
                    }
                    else
                    {
                        modelDetails.teamName = dt.Rows[i]["NM_TIME"].ToString();
                    }
                    modelDetails.teamType = dt.Rows[i]["DS_TIPO"].ToString();
                    modelDetails.teamURL  = dt.Rows[i]["DS_URL_TIME"].ToString();
                    modelDetails.userID   = Convert.ToInt32(dt.Rows[i]["ID_USUARIO"].ToString());
                    modelDetails.userName = dt.Rows[i]["NM_USUARIO"].ToString();
                    modelDetails.psnID    = dt.Rows[i]["PSN_ID"].ToString();
                    if (!String.IsNullOrEmpty(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString()))
                    {
                        modelDetails.deletedCurrentSeason = Convert.ToInt16(dt.Rows[i]["IN_TIME_EXCLUIDO_TEMP_ATUAL"].ToString());
                    }
                    if (!String.IsNullOrEmpty(dt.Rows[i]["PosicaoAnterior"].ToString()))
                    {
                        modelDetails.previousPosition = Convert.ToInt16(dt.Rows[i]["PosicaoAnterior"].ToString());
                    }
                    listOfModel.Add(modelDetails);
                }

                mainModel.listOfTeamTable = listOfModel;
                mainModel.returnMessage   = "ModeratorSuccessfully";
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }

            catch (Exception ex)
            {
                mainModel = new ChampionshipTeamTableListViewModel();
                mainModel.listOfTeamTable = new List <ChampionshipTeamTableDetailsModel>();
                mainModel.returnMessage   = "errorGetAllTeamTableForChampionship_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, mainModel));
            }
            finally
            {
                db.closeConnection();
                modelDetails = null;
                mainModel    = null;
                listOfModel  = null;
                dt           = null;
            }
        }