public ActionResult Delete(AssetType assetType) { try { // call the AssetTypeManager to delete AssetTypeManager.Delete(assetType); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Delete(int id, AssetTypeModel assetTypeModel) { ViewBag.ErrorMessage = ""; var assetType = AssetTypeManager.GetAssetTypeById(id); if (AssetManager.GetAllByAssetType(id).Count != 0) { // cannot delete AssetType if this type has assets in database ViewBag.ErrorMessage = "Cannot Delete Type if it has assets being tracked"; return(View(assetTypeModel)); } else { // no assets of AssetType in database so it is safe to delete AssetTypeManager.Delete(id); return(RedirectToAction("Index", "AssetType")); } }