public ActionResult Login(string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;

            if (returnUrl != null)
            {
                string[] url = returnUrl.Split('/');

                for (int i = 0; i < url.Length; i++)
                {
                    if (url[i].ToLower() == "ref")
                    {
                        CustomerBiz cb = new CustomerBiz();
                        Customer customer = cb.GetCustomer(url[i + 1].ToLower());

                        ViewBag.id = customer.id;
                        ViewBag.logo = customer.logo;
                        ViewBag.nombre = customer.nombre;
                        break;
                    }
                }
            }
            else
            {
                CustomerBiz cb = new CustomerBiz();
                Customer customer = cb.GetCustomer("orkidea");

                ViewBag.id = customer.id;
                ViewBag.logo = customer.logo;
                ViewBag.nombre = customer.nombre;
            }

            return View();
        }
예제 #2
0
        private void FindWinners(int idGame, string rootPath)
        {
            List<Prediction> lsPollas = PredictionCRUD.GetPredictionList(idGame);
            Score score = ScoreCRUD.GetScoreByKey(idGame);

            #region Calculo de puntaje
            foreach (Prediction item in lsPollas)
            {
                int puntaje = 0;

                if (item.team1Score.Equals(score.team1Score))
                    puntaje += 30;
                if (item.team2Score.Equals(score.team2Score))
                    puntaje += 30;

                //----
                if (item.saqueInicial.Equals(score.saqueInicial))
                    puntaje += 40;

                //----
                if (item.primerTiroEsquina.Equals(score.primerTiroEsquina))
                    puntaje += 40;

                //----
                if (item.primeraTarjetaAmarilla.Equals(score.primeraTarjetaAmarilla))
                    puntaje += 40;

                //----
                if (item.primerCambio.Equals(score.primerCambio))
                    puntaje += 40;

                //----
                if (item.ganadorPrimerTiempo.Equals(score.ganadorPrimerTiempo))
                    puntaje += 40;

                //----
                if (item.anotacionesPrimerTiempo.Equals(score.anotacionesPrimerTiempo))
                    puntaje += 40;

                //----
                if (item.anotacionesSegundoTiempo.Equals(score.anotacionesSegundoTiempo))
                    puntaje += 40;

                //----
                if (item.tarjetaRoja.Equals(score.tarjetaRoja))
                    puntaje += 40;

                //----
                if (item.ambosAnotan.Equals(score.ambosAnotan))
                    puntaje += 40;

                //----
                if (item.penalty.Equals(score.penalty))
                    puntaje += 40;

                //----
                if (item.equipoCobraPrimerTiroLibre.Equals(score.equipoCobraPrimerTiroLibre))
                    puntaje += 40;

                item.puntaje = puntaje;

                PredictionCRUD.SavePrediction(item);
            }
            #endregion

            CustomerBiz cb = new CustomerBiz();
            List<Customer> customers = cb.GetCustomerList();

            foreach (Customer item in customers)
            {
                List<Prediction> lsPollasGanadoras = new List<Prediction>();
                int numGanadores = item.ganadoresPartido;

                if (numGanadores >= lsPollas.Where(x => x.idGame.Equals(idGame) && x.idCustomer == item.id).Count())
                    lsPollasGanadoras.AddRange(lsPollas.Where(x => x.idGame.Equals(idGame) && x.idCustomer == item.id).OrderByDescending(x => x.puntaje).Take(numGanadores).ToList());
                else
                    lsPollasGanadoras.AddRange(lsPollas.Where(x => x.idGame.Equals(idGame) && x.idCustomer == item.id).OrderByDescending(x => x.puntaje).ToList());

                StringBuilder ganadores = new StringBuilder();

                foreach (Prediction item2 in lsPollasGanadoras)
                {
                    ganadores.AppendLine(string.Format("- {0} puntaje: {1}", item2.userMailAddress, item2.puntaje));
                }

                SendMail(item, idGame, ganadores.ToString(), rootPath);
            }
        }