Example #1
0
 private void SetViewBag(EGolPADs gol = null)
 {
     ApoioViewBag(gol);
     TimesViewBag(gol);
     PlacarViewBag(gol);
     BgColorViewBag(gol);
 }
Example #2
0
        private void Validacao(EGolPADs gol)
        {
            if (string.IsNullOrWhiteSpace(gol.Placar))
            {
                ModelState.AddModelError("Placar", "O Placar deve ser preenchido.");
            }

            if (string.IsNullOrWhiteSpace(gol.Jogador))
            {
                ModelState.AddModelError("Jogador", "O Jogador deve ser preenchido.");
            }
            else if (gol.Jogador.Length > 100)
            {
                ModelState.AddModelError("Jogador", "O Jogador não deve ter mais do que 100 caracteres.");
            }

            if (string.IsNullOrWhiteSpace(gol.HoraDoGol))
            {
                ModelState.AddModelError("HoraDoGol", "A Hora do Gol deve ser preenchida.");
            }
            else if (gol.HoraDoGol.Length > 30)
            {
                ModelState.AddModelError("HoraDoGol", "A Hora do Gol não deve ter mais do que 30 caracteres.");
            }

            if (string.IsNullOrWhiteSpace(gol.BgColor))
            {
                ModelState.AddModelError("BgColor", "O BgColor deve ser preenchido.");
            }
        }
Example #3
0
        public ActionResult Details(int id = 0)
        {
            EGolPADs gol = db.EGolPADs.Find(id);

            if (gol == null)
            {
                return(HttpNotFound());
            }
            return(View(gol));
        }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            EGolPADs gol = db.EGolPADs.Find(id);

            gol.Excluido        = true;
            db.Entry(gol).State = EntityState.Modified;

            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Exclusao, gol.Id);
            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult Edit(int id)
        {
            EGolPADs gol = db.EGolPADs.Find(id);

            if (gol == null)
            {
                return(HttpNotFound());
            }

            SetViewBag(gol);

            return(View(gol));
        }
Example #6
0
        private void ApoioViewBag(EGolPADs gol)
        {
            //Método usado para gerar a listbox de apoiadores na view.
            var apoiadores = db.ApoioPADs.Where(a => !a.Excluido).ToList();

            if (gol != null)
            {
                ViewBag.ApoioId = new SelectList(apoiadores, "id", "nome", gol.ApoioId);
            }
            else
            {
                ViewBag.ApoioId = new SelectList(apoiadores, "id", "nome");
            }
        }
Example #7
0
        public JsonResult SalvaBannerEGol(int id = 0, bool salvar = true)
        {
            EGolPADs gol = db.EGolPADs.Where(n => n.Id == id).FirstOrDefault();

            if (gol == null)
            {
                return(Json("erro", JsonRequestBehavior.AllowGet));
            }
            string body;

            body = System.IO.File.ReadAllText(LayoutsPath + "gol.html");
            body = body.Replace("##bgcolor##", gol.BgColor);
            body = body.Replace("##mandanteLogo##", URL + "Admin/Conteudo/timesPAD/" + gol.MandanteId + "/" + gol.TimesPADs.Logo);
            body = body.Replace("##mandanteNome##", gol.TimesPADs.Nome);
            body = body.Replace("##visitanteLogo##", URL + "Admin/Conteudo/timesPAD/" + gol.VisitanteId + "/" + gol.TimesPADs1.Logo);
            body = body.Replace("##visitanteNome##", gol.TimesPADs1.Nome);
            body = body.Replace("##placar##", gol.Placar);
            body = body.Replace("##jogador##", gol.Jogador);
            body = body.Replace("##horaGol##", gol.HoraDoGol);
            body = body.Replace("##hashtag##", gol.HashTag);
            if (gol.ApoioId != null)
            {
                body = body.Replace("##apoioLogo##", URL + "Admin/Conteudo/ApoioPAD/" + gol.ApoioId + "/" + gol.ApoioPADs.Logo);
                body = body.Replace("##apoioNome##", gol.ApoioPADs.Nome);
            }
            else
            {
                body = body.Replace("<div class='brand-apoio'>", "<div class='brand-apoio' style='display:none;'>");
            }

            body = body.Replace("##goleadorLogo##", URL + "Admin/Conteudo/timesPAD/" + (gol.GolMandante ? (gol.MandanteId + "/" + gol.TimesPADs.Logo) : (gol.VisitanteId + "/" + gol.TimesPADs1.Logo)));
            body = body.Replace("##goleadorNome##", gol.GolMandante ? gol.TimesPADs.Nome : gol.TimesPADs1.Nome);

            if (!salvar)
            {
                body = body.Replace("<link rel='stylesheet' href='Content/styles.css' />", "<link rel='stylesheet' href='" + URL + "Admin/BannersPad/conteudo/Content/styles.css' />");
                body = body.Replace("Content/images/", URL + "Admin/BannersPad/conteudo/Content/images/");
                return(Json(body, JsonRequestBehavior.AllowGet));
            }

            if (SalvaHTML(body))
            {
                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("erro", JsonRequestBehavior.AllowGet));
            }
        }
Example #8
0
        private void TimesViewBag(EGolPADs gol)
        {
            //Método usado para gerar as listbox de times na view.
            var times = db.TimesPADs.Where(a => !a.Excluido).ToList();

            if (gol != null)
            {
                ViewBag.VisitanteId = new SelectList(times, "id", "nome", gol.VisitanteId);
                ViewBag.MandanteId  = new SelectList(times, "id", "nome", gol.MandanteId);
            }
            else
            {
                ViewBag.VisitanteId = new SelectList(times, "id", "nome");
                ViewBag.MandanteId  = new SelectList(times, "id", "nome");
            }
        }
Example #9
0
 private void PlacarViewBag(EGolPADs gol)
 {
     if (gol == null)
     {
         return;
     }
     if (gol.Placar != null)
     {
         var pontos = gol.Placar.Split(new char[] { 'x' });
         ViewBag.GolsMandante  = pontos[0];
         ViewBag.GolsVisitante = pontos[1];
     }
     else
     {
         ViewBag.GolsMandante  = 0;
         ViewBag.GolsVisitante = 0;
     }
 }
Example #10
0
        private void BgColorViewBag(EGolPADs gol)
        {
            //Método usado para gerar a listbox de cores.
            var colorlist = new Dictionary <string, string>();

            colorlist.Add("black", "Preto");
            colorlist.Add("blue", "Azul");
            colorlist.Add("green", "Verde");

            if (gol != null)
            {
                ViewBag.BgColor = new SelectList(colorlist, "key", "value", gol.BgColor);
            }
            else
            {
                ViewBag.BgColor = new SelectList(colorlist, "key", "value");
            }
        }
Example #11
0
        public ActionResult Create(EGolPADs gol)
        {
            Validacao(gol);
            if (ModelState.IsValid)
            {
                gol.Excluido     = false;
                gol.DataCadastro = DateTime.Now;

                db.EGolPADs.Add(gol);
                db.SaveChanges();

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, gol.Id);
                return(RedirectToAction("Details", new { id = gol.Id }));
            }

            SetViewBag(gol);

            return(View(gol));
        }