//[AcceptVerbs(HttpVerbs.Post)] //public ActionResult Commodity_Destroy([DataSourceRequest] DataSourceRequest request, // CommodityViewModel commodityViewModel) //{ // if (commodityViewModel != null) // { // _commodityService.DeleteById(commodityViewModel.CommodityID); // } // return Json(ModelState.ToDataSourceResult()); //} public ActionResult Commodity_Destroy(int id) { var commodity = _commodityService.FindById(id); try { _commodityService.DeleteCommodity(commodity); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError("Errors", @"Unable to delete commodity"); } return(RedirectToAction("Index")); }
//[AcceptVerbs(HttpVerbs.Post)] //public ActionResult Commodity_Destroy([DataSourceRequest] DataSourceRequest request, // CommodityViewModel commodityViewModel) //{ // if (commodityViewModel != null) // { // _commodityService.DeleteById(commodityViewModel.CommodityID); // } // return Json(ModelState.ToDataSourceResult()); //} public ActionResult Commodity_Destroy(int id) { var commodity = _commodityService.FindById(id); try { _commodityService.DeleteCommodity(commodity); TempData["error"] = "Commodity is Deleted!"; return(RedirectToAction("Index")); } catch (Exception e) { TempData["error"] = "Unable to delete commodity. This commodity is being used by the system."; } return(RedirectToAction("Index")); }
public void Delete(string id) { _commodityService.DeleteCommodity(id); }
public bool DeleteCommodity([FromServices]ICommodityService CommodityService,[FromBody]long id) { return CommodityService.DeleteCommodity(id); }