Exemple #1
0
 public JsonResult Delete(int id)
 {
     try
     {
         Cat    cat       = catService.GetById(id);
         string photoPath = "";
         if (cat == null)
         {
             return(Json("Cat data not found!", JsonRequestBehavior.AllowGet));
         }
         else
         {
             photoPath = cat.PhotoPath;
             if (System.IO.File.Exists(Server.MapPath(photoPath)))
             {
                 System.IO.File.Delete(Server.MapPath(photoPath));
             }
             catService.Delete(cat);
             return(Json("Cat data deleted successfully!", JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         return(Json("Something went wrong! " + e.Message, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #2
0
 public void Delete(int id)
 {
     _service.Delete(id);
 }