Esempio n. 1
0
 public ActionResult Editar_Noticia(AddNoticiasViewModel model)
 {
     ViewData["Nombre"]   = AccesoController.nombre;
     ViewData["Apellido"] = AccesoController.apellido;
     try
     {
         if (ModelState.IsValid)
         {
             using (SII_Entities db = new SII_Entities())
             {
                 var obj_Noticias = db.Tbl_NoticiasPDF.Find(model.id_Noticias);
                 obj_Noticias.id_Noticia        = model.id_Noticias;
                 obj_Noticias.titulo_Noticia    = model.titulo;
                 obj_Noticias.subtitulo_Noticia = model.subtitulo;
                 obj_Noticias.contenido_Noticia = model.texto;
                 db.Entry(obj_Noticias).State   = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 TempData["msg"] = "Modificado";
                 ViewBag.Msg     = TempData["msg"];
             }
             return(Redirect("/ReportPDFNoticias/ShowNoticias"));
         }
         return(View(model));
     }
     catch (Exception)
     {
         return(Redirect("/Error/InaccessiblePage"));
     }
 }
Esempio n. 2
0
        public ActionResult PDFNoticias(AddNoticiasViewModel model)
        {
            ViewData["Nombre"]   = AccesoController.nombre;
            ViewData["Apellido"] = AccesoController.apellido;
            try
            {
                if (ModelState.IsValid)
                {
                    using (SII_Entities db = new SII_Entities())
                    {
                        var obj_Noticia = new Tbl_NoticiasPDF();
                        obj_Noticia.titulo_Noticia    = model.titulo;
                        obj_Noticia.fecha_Creacion_N  = DateTime.Now;
                        obj_Noticia.subtitulo_Noticia = model.subtitulo;
                        obj_Noticia.contenido_Noticia = model.texto;
                        obj_Noticia.estado            = 1;
                        db.Tbl_NoticiasPDF.Add(obj_Noticia);
                        db.SaveChanges();

                        TempData["msg"] = "Agregado";
                        ViewBag.Msg     = TempData["msg"];
                    }
                    return(Redirect("/ReportPDFNoticias/ShowNoticias"));
                }
                return(View(model));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        public ActionResult Editar_Noticia(int?IdNoticia)
        {
            try
            {
                ViewData["Nombre"]   = AccesoController.nombre;
                ViewData["Apellido"] = AccesoController.apellido;

                AddNoticiasViewModel model = new AddNoticiasViewModel();
                using (SII_Entities db = new SII_Entities())
                {
                    var obj_Noticias = db.Tbl_NoticiasPDF.Find(IdNoticia);
                    model.id_Noticias    = obj_Noticias.id_Noticia;
                    model.fecha_Creacion = obj_Noticias.fecha_Creacion_N;
                    model.titulo         = obj_Noticias.titulo_Noticia;
                    model.subtitulo      = obj_Noticias.subtitulo_Noticia;
                    model.texto          = obj_Noticias.contenido_Noticia;
                }
                return(View(model));
            }
            catch (Exception)
            {
                return(Redirect("/Error/InaccessiblePage"));
            }
        }