示例#1
0
        public tblNoticia RetrieveNoticiaByID(int id)
        {
            tblNoticia Result = null;

            using (var r = new Repository <tblNoticia>())
            {
                Result = r.Retrieve(p => p.idNoticias == id);
            }

            return(Result);
        }
        // GET: Noticias/Edit/5
        public ActionResult Edit(int id)
        {
            var        NotBLL = new NoticiaBLL();
            tblNoticia objNot = NotBLL.RetrieveNoticiaByID(id);

            var             nivelBLL   = new NivelBLL();
            List <tblNivel> listaNivel = nivelBLL.RetrieveAll();

            ViewBag.idNivel = new SelectList(listaNivel, "idNivel", "nivelNombre", objNot.idNivel);

            return(View(objNot));
        }
        // GET: Noticias/Delete/5
        public ActionResult DeleteNoticias(int id)
        {
            var          notBLL  = new NoticiaBLL();
            wmJsonResult objJson = new wmJsonResult();

            try
            {
                tblNoticia noticia = notBLL.RetrieveNoticiaByID(id);

                if (noticia != null)
                {
                    var             lvlBLL     = new NivelBLL();
                    List <tblNivel> listaNivel = lvlBLL.RetrieveNoticiasNivelByID(id);

                    if (listaNivel.Count() >= 0)
                    {
                        //significa que tiene eventos....
                    }

                    bool banderita = notBLL.Delete(id);

                    if (banderita == true)
                    {
                        objJson.bandera = true;
                        objJson.mensaje = "La noticia se eliminó correctamente";
                    }
                    else
                    {
                        objJson.bandera = false;
                        objJson.mensaje = "La noticia NO se eliminó correctamente";
                    }
                }
                else
                {
                    objJson.bandera = false;
                    objJson.mensaje = "La noticia  no se encontró";
                }
            }
            catch
            {
                objJson.bandera = false;
                objJson.mensaje = "Ocurrio una excepcion al eliminar el registro";
            }

            return(Json(objJson, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public bool Delete(int id)
        {
            bool       Result = false;
            tblNoticia obj    = RetrieveNoticiaByID(id);

            if (obj != null)
            {
                using (var r = new Repository <tblNoticia>())
                {
                    Result = r.Delete(obj);
                }
            }
            else
            {
                throw (new Exception("El colaborador seleccionado no se pudo eliminar."));
            }

            return(Result);
        }
        public ActionResult Edit(tblNoticia Noticias)
        {
            var          NotBLL = new NoticiaBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    NotBLL.Update(Noticias);
                    Result = RedirectToAction("Noticias");
                }
            }
            catch
            {
                return(View());
            }

            return(Result);
        }
示例#6
0
        public bool Update(tblNoticia t)
        {
            bool Result = false;

            using (var r = new Repository <tblNoticia>())
            {
                tblNoticia ba = r.Retrieve(p => p.noticiasTitulo == t.noticiasTitulo &&
                                           p.noticiasTexto == t.noticiasTexto &&
                                           p.idNoticias == t.idNoticias &&
                                           p.idNivel == t.idNivel);

                if (ba == null)
                {
                    Result = r.Update(t);
                }
                else
                {
                    throw (new Exception("No se pudo actualizar la noticia seleccionada."));
                }
            }
            return(Result);
        }
        public ActionResult Create(tblNoticia Noticias)
        {
            var          NotBLL = new NoticiaBLL();
            ActionResult Result = null;

            try
            {
                if (ModelState.IsValid)
                {
                    NotBLL.Create(Noticias);
                    Result = RedirectToAction("Noticias");
                }
                else
                {
                    Result = RedirectToAction("Noticias");
                }
            }
            catch
            {
                Result = RedirectToAction("Noticias");
            }
            return(Result);
        }
示例#8
0
        public tblNoticia Create(tblNoticia t)
        {
            tblNoticia Result = null;

            using (var r = new Repository <tblNoticia>())
            {
                tblNoticia ba = r.Retrieve(p => p.noticiasTitulo == t.noticiasTitulo &&
                                           p.noticiasTexto == t.noticiasTexto &&
                                           p.idNivel == t.idNivel &&
                                           p.idNoticias != t.idNoticias);


                if (ba == null)
                {
                    Result = r.Create(t);
                }
                else
                {
                    throw (new Exception("La noticia ya existe."));
                }
            }
            return(Result);
        }