public async Task <IActionResult> DeleteConfirmed(int id) { if (id < 0) { return(BadRequest()); } _repository.DeletePurchase(id); await _repository.Save(); return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int id) { try { _purchaseRepo.DeletePurchase(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)); } }