コード例 #1
0
        //[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"));
        }
コード例 #2
0
ファイル: CommodityController.cs プロジェクト: nathnael/cats
        //[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"));
        }
コード例 #3
0
 public void Delete(string id)
 {
     _commodityService.DeleteCommodity(id);
 }
コード例 #4
0
 public bool DeleteCommodity([FromServices]ICommodityService CommodityService,[FromBody]long id)
 {
     return CommodityService.DeleteCommodity(id);
 }