Esempio n. 1
0
 public static int EliminarNoticia(int idNoticia)
 {
     try
     {
         NoticiaBLL.Delete(idNoticia);
         return(idNoticia);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
        // 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));
        }