Example #1
0
        public ActionResult Edit(RedesSociaisPADs noticia, HttpPostedFileBase fotoUpload, int cropX = 0, int cropY = 0, int cropWidth = 0, int cropHeight = 0)
        {
            Validacao(noticia);
            if (ModelState.IsValid)
            {
                noticia.DataCadastro = DateTime.Now;
                noticia.Excluido     = false;

                if (fotoUpload != null)
                {
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, noticia.Id));

                    if (cropWidth > 0 && cropHeight > 0)
                    {
                        noticia.Foto = "/Admin/Conteudo/RedesSociaisPAD/" + noticia.Id + "/" + Utils.SaveAndCropColunista(fotoUpload, fileOriginal, cropX, cropY, cropWidth, cropHeight);
                    }
                    else
                    {
                        noticia.Foto = "/Admin/Conteudo/RedesSociaisPAD/" + noticia.Id + "/" + Utils.SaveFileBase(fileOriginal, fotoUpload);
                    }
                }

                db.Entry(noticia).State = EntityState.Modified;
                db.SaveChanges();

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

            ApoioViewBag(noticia);

            return(View(noticia));
        }
Example #2
0
        public ActionResult Details(int id = 0)
        {
            RedesSociaisPADs noticia = db.RedesSociaisPADs.Find(id);

            if (noticia == null)
            {
                return(HttpNotFound());
            }
            return(View(noticia));
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            RedesSociaisPADs noticia = db.RedesSociaisPADs.Find(id);

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

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

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

            ApoioViewBag(noticia);

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

            if (noticia != null)
            {
                ViewBag.ApoioId = new SelectList(apoiadores, "id", "nome", noticia.ApoioId);
            }
            else
            {
                ViewBag.ApoioId = new SelectList(apoiadores, "id", "nome");
            }
        }
Example #6
0
        public JsonResult SalvaBannerRedesSociais(int id = 0, bool salvar = true)
        {
            RedesSociaisPADs post = db.RedesSociaisPADs.Where(n => n.Id == id).FirstOrDefault();

            if (post == null)
            {
                return(Json("erro", JsonRequestBehavior.AllowGet));
            }
            string body = System.IO.File.ReadAllText(LayoutsPath + "rede-social.html");

            if (!string.IsNullOrEmpty(post.Foto))
            {
                body = body.Replace("##foto##", post.Foto);
            }
            else
            {
                body = body.Replace("##foto##", "Content/images/bg-default.jpg");
            }
            body = body.Replace("##chamada##", post.Chamada);
            body = body.Replace("##tipoRede##", post.TipoRede == 1 ? "facebook" : "twitter");
            body = body.Replace("##nomeRede##", post.TipoRede == 1 ? "Facebook" : "Twitter");
            body = body.Replace("##hashtag##", post.Hashtag);
            if (post.ApoioId != null)
            {
                body = body.Replace("##apoioLogo##", URL + "Admin/Conteudo/ApoioPAD/" + post.ApoioId + "/" + post.ApoioPADs.Logo);
                body = body.Replace("##apoioNome##", post.ApoioPADs.Nome);
            }
            else
            {
                body = body.Replace("<div class='brand-apoio'>", "<div class='brand-apoio' style='display:none;'>");
            }

            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 #7
0
        public ActionResult Create(RedesSociaisPADs noticia)
        {
            Validacao(noticia);
            if (ModelState.IsValid)
            {
                noticia.Excluido     = false;
                noticia.DataCadastro = DateTime.Now;

                db.RedesSociaisPADs.Add(noticia);
                db.SaveChanges();

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

            ApoioViewBag(noticia);

            return(View(noticia));
        }
Example #8
0
        private void Validacao(RedesSociaisPADs rede)
        {
            if (string.IsNullOrWhiteSpace(rede.Chamada))
            {
                ModelState.AddModelError("Chamada", "A Chamada deve ser preenchida.");
            }
            else if (rede.Chamada.Length > 50)
            {
                ModelState.AddModelError("Chamada", "A Chamada não deve ter mais do que 50 caracteres.");
            }

            if (string.IsNullOrWhiteSpace(rede.Hashtag))
            {
                ModelState.AddModelError("Hashtag", "A Hashtag deve ser preenchida.");
            }
            else if (rede.Hashtag.Length > 30)
            {
                ModelState.AddModelError("Hashtag", "A Hashtag não deve ter mais do que 30 caracteres.");
            }
        }
Example #9
0
        public ActionResult Create(int id = 0)
        {
            if (id == 0)
            {
                return(HttpNotFound());
            }
            RedesSociais post = db.RedesSociais.Find(id);

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

            var noticia = new RedesSociaisPADs()
            {
                Chamada  = post.Texto,
                Foto     = post.Imagem,
                TipoRede = post.TipoRede
            };

            ApoioViewBag(null);

            return(View(noticia));
        }