Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            var delCommodity    = _commodityService.FindById(id);
            var countOfChildren = _commodityService.GetAllSubCommodities().Count(p => p.ParentID == id);

            if (delCommodity != null &&
                (countOfChildren == 0) &&
                delCommodity.ReceiveDetails.Count == 0 &&
                delCommodity.DispatchDetails.Count == 0 &&
                delCommodity.DispatchAllocations.Count == 0 &&
                delCommodity.GiftCertificateDetails.Count == 0)
            {
                _commodityService.DeleteById(id);
                return(RedirectToAction("Index"));
            }

            ViewBag.ERROR_MSG = "This Commodity is being referenced, so it can't be deleted";
            ViewBag.ERROR     = true;
            return(View("Delete", delCommodity)); //this.Delete(id);
        }