Пример #1
0
 public ActionResult Delete(int id)
 {
     try
     {
         _itemsRepo.DeleteItem(id);
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = "Error in deletion" + "\n" + e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult DeleteItem(int id)
        {
            var itemModelFromRepo = _repository.GetItemById(id);

            if (itemModelFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeleteItem(itemModelFromRepo);
            _repository.SaveChanges();
            return(NoContent());
        }