예제 #1
0
 public JsonResult Delete(int id)
 {
     try
     {
         Dog    dog       = dogService.GetById(id);
         string photoPath = "";
         if (dog == null)
         {
             return(Json("Cat data not found!", JsonRequestBehavior.AllowGet));
         }
         else
         {
             photoPath = dog.PhotoPath;
             if (System.IO.File.Exists(Server.MapPath(photoPath)))
             {
                 System.IO.File.Delete(Server.MapPath(photoPath));
             }
             dogService.Delete(dog);
             return(Json("Dog data deleted successfully!", JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         return(Json("Something went wrong! " + e.Message, JsonRequestBehavior.AllowGet));
     }
 }
예제 #2
0
        public ActionResult Delete(int dogId)
        {
            Dog dogFromDatabase = dogService.GetById(dogId);

            if (dogFromDatabase == null)
            {
                return(NotFound());
            }
            dogService.Delete(dogFromDatabase);
            return(NoContent());
        }
예제 #3
0
        public IActionResult Delete(int id)
        {
            // users can delete their own account and admins can delete any account
            if (id != Account.Id && Account.Role != Role.Admin)
            {
                return(Unauthorized(new { message = "Unauthorized" }));
            }

            _dogService.Delete(id);
            return(Ok(new { message = "Account deleted successfully" }));
        }
 public string DeleteDog(string Dogname)
 {
     try {
         _dogService.Delete(Dogname);
         return("Deleted successfully");
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return("Dog not deleted");
     }
 }
        public IActionResult DeleteDog([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var deleted = _dogService.Delete(id);

            if (deleted == false)
            {
                return(NotFound());
            }

            return(Ok());
        }
예제 #6
0
 public IActionResult Delete(int id)
 {
     _dogService.Delete(id);
     return(Ok(new { message = "Account deleted successfully" }));
 }