// GET: AssetType/Delete/5 public ActionResult Delete(int id) { var assetType = AssetTypeManager.GetAssetTypeById(id); var assetTypeModel = new AssetTypeModel { Id = assetType.Id, Name = assetType.Name }; return(View(assetTypeModel)); }
// GET: Asset/Delete/5 public ActionResult Delete(int id) { var asset = AssetManager.Find(id); var assetModel = new AssetModel { Id = asset.Id, TagNumber = asset.TagNumber, Manufacturer = asset.Manufacturer, AssetTypeId = asset.AssetTypeId, AssetTypeName = AssetTypeManager.GetAssetTypeById(asset.AssetTypeId).Name, Description = asset.Description, Model = asset.Model, SerialNumber = asset.SerialNumber }; return(View(assetModel)); }
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")); } }
// GET: AssetTypes/Edit/5 public ActionResult Edit(int id) { var assetType = AssetTypeManager.GetAssetTypeById(id); return(View(assetType)); }