Example #1
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                DisplayWarningMessage("Looks like, the ID is missing in your request");
                return(RedirectToAction("List"));
            }

            try
            {
                if (subCategoryService.IsReservedEntry(id.Value))
                {
                    DisplayWarningMessage("Hey, why do you want to delete a Reserved Sub-Category. Please check with the system administrator.");
                    return(RedirectToAction("List"));
                }

                if (subCategoryService.CanBeDeleted(id.Value) == false)
                {
                    DisplayWarningMessage("There are some dependencies with this Sub-Category. So, you can't delete this for now.");
                    return(RedirectToAction("List"));
                }

                subCategoryService.DeleteSubCategory(new DropDownSubCategoryDto {
                    SubCategoryID = id.Value
                });
                DisplaySuccessMessage("Sub-Category has been deleted successfully");
            }
            catch (Exception exp)
            {
                DisplayDeleteErrorMessage(exp);
            }
            return(RedirectToAction("List"));
        }