Example #1
0
        public bool UpdateCriterioPontos(BolaoNet.Model.Boloes.BolaoCriterioPontos entry)
        {
            int    errorNumber      = 0;
            string errorDescription = null;

            bool result = _daoBase.UpdateCriterioPontos(
                _currentLogin, entry, out errorNumber, out errorDescription);

            if (errorNumber != 0 || !string.IsNullOrEmpty(errorDescription))
            {
                return(false);
            }

            return(result);
        }
        public static Framework.DataServices.Model.EntityBaseData ConvertToCriteriosPontosObject(DataRow row)
        {
            string nomeBolao  = "";
            int    criterioID = 0;

            if (row.Table.Columns.Contains("NomeBolao") && !Convert.IsDBNull(row["NomeBolao"]))
            {
                nomeBolao = Convert.ToString(row["NomeBolao"]);
            }
            if (row.Table.Columns.Contains("CriterioID") && !Convert.IsDBNull(row["CriterioID"]))
            {
                criterioID = Convert.ToInt32(row["CriterioID"]);
            }

            Model.Boloes.BolaoCriterioPontos entry = new BolaoNet.Model.Boloes.BolaoCriterioPontos(nomeBolao, (Model.Boloes.BolaoCriterioPontos.CriteriosID)criterioID);
            entry.LoadDataRow(row);


            if (row.Table.Columns.Contains("Pontos") && !Convert.IsDBNull(row["Pontos"]))
            {
                entry.Pontos = Convert.ToInt32(row["Pontos"]);
            }
            if (row.Table.Columns.Contains("Descricao") && !Convert.IsDBNull(row["Descricao"]))
            {
                entry.Descricao = Convert.ToString(row["Descricao"]);
            }

            if (row.Table.Columns.Contains("NomeTime") && !Convert.IsDBNull(row["NomeTime"]))
            {
                entry.Time = new BolaoNet.Model.DadosBasicos.Time(Convert.ToString(row["NomeTime"]));
            }
            if (row.Table.Columns.Contains("MultiploTime") && !Convert.IsDBNull(row["MultiploTime"]))
            {
                entry.MultiploTime = Convert.ToInt32(row["MultiploTime"]);
            }

            return(entry);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Business.Campeonatos.Support.Jogo jogo = new BolaoNet.Business.Campeonatos.Support.Jogo(base.UserName);

                //Se estiver passando o id do jogo
                if (Request.QueryString["IDJogo"] != null)
                {
                    long idJogo = Convert.ToInt64(Request.QueryString["IDJogo"].ToString());

                    jogo.Campeonato = CurrentCampeonato;
                    jogo.IDJogo     = idJogo;
                    jogo.Load();


                    this.ctlJogoDetail.Jogo = jogo;
                }//endif passando id do jogo



                Business.Boloes.Support.Bolao business = new BolaoNet.Business.Boloes.Support.Bolao(base.UserName, CurrentBolao.Nome);


                #region Buscando os pontos dos jogos
                List <Model.Boloes.BolaoCriterioPontos> listCriteriosPontos = new List <Model.Boloes.BolaoCriterioPontos>();

                IList <Framework.DataServices.Model.EntityBaseData> auxlist = business.LoadCriteriosPontos(null);

                for (int c = 0; c < 20; c++)
                {
                    Model.Boloes.BolaoCriterioPontos criteriosPontos = new BolaoNet.Model.Boloes.BolaoCriterioPontos();
                    criteriosPontos.Bolao      = new BolaoNet.Model.Boloes.Bolao(CurrentBolao.Nome);
                    criteriosPontos.CriterioID = (Model.Boloes.BolaoCriterioPontos.CriteriosID)(c + 1);
                    listCriteriosPontos.Add(criteriosPontos);
                }


                foreach (Model.Boloes.BolaoCriterioPontos pontos in auxlist)
                {
                    if (pontos.Pontos != 0)
                    {
                        listCriteriosPontos[(int)pontos.CriterioID - 1].Pontos = pontos.Pontos;
                    }
                }

                Criterios = listCriteriosPontos;
                #endregion

                #region Buscando os pontos dos times

                List <Model.Boloes.BolaoCriterioPontosTimes> listCriteriosPontosTimes = new List <BolaoNet.Model.Boloes.BolaoCriterioPontosTimes>();

                auxlist = business.LoadCriteriosPontosTimes(null);

                foreach (Model.Boloes.BolaoCriterioPontosTimes times in auxlist)
                {
                    listCriteriosPontosTimes.Add(times);
                }

                CriteriosTimes = listCriteriosPontosTimes;

                #endregion

                #region Buscando a classificação do campeonato
                IList <Model.Boloes.BolaoMembros> listClassificacao = business.LoadClassificacao(0);


                #endregion

                #region Buscando as apostas do Usuários
                List <Model.Boloes.Simulation.JogoUsuarioPosicao> listJogosPos = new List <BolaoNet.Model.Boloes.Simulation.JogoUsuarioPosicao>();

                Business.Boloes.Support.JogoUsuario businessJogos = new BolaoNet.Business.Boloes.Support.JogoUsuario(base.UserName);
                businessJogos.Bolao = CurrentBolao;

                //Model.Campeonatos.Jogo jogo = new BolaoNet.Model.Campeonatos.Jogo(380);
                //jogo.Campeonato = CurrentCampeonato;

                auxlist = businessJogos.LoadApostasByJogo(CurrentBolao, jogo, null);

                foreach (Model.Boloes.JogoUsuario aposta in auxlist)
                {
                    Model.Boloes.Simulation.JogoUsuarioPosicao apostaPosicao = new Model.Boloes.Simulation.JogoUsuarioPosicao();
                    apostaPosicao.CopyAposta(aposta);


                    for (int c = listClassificacao.Count - 1; c >= 0; c--)
                    {
                        if (string.Compare(apostaPosicao.UserName, listClassificacao[c].UserName, true) == 0)
                        {
                            apostaPosicao.TotalPontos = listClassificacao[c].TotalPontos;
                            apostaPosicao.LastPontos  = listClassificacao[c].TotalPontos;

                            apostaPosicao.Posicao     = listClassificacao[c].Posicao;
                            apostaPosicao.LastPosicao = listClassificacao[c].Posicao;


                            apostaPosicao.LastApostaPontos = apostaPosicao.ApostaPontos.Pontos;

                            listClassificacao.RemoveAt(c);

                            break;
                        }
                    }


                    listJogosPos.Add(apostaPosicao);
                }

                JogoUsuarios = listJogosPos;

                #endregion


                this.grdJogosUsuarios.DataSource = OrderPontos(listJogosPos);
                this.grdJogosUsuarios.DataBind();
            }
        }