public ActionResult Edit(int id) { var data = ContactRepo.Find(id); if (data == null) { throw new InvalidOperationException("操作錯誤"); } return(View(data)); }
public ActionResult Details(int id) { if (id == 0) { throw new ArgumentException("參數錯誤"); } var data = ContactRepo.Find(id); if (data == null) { throw new InvalidOperationException("操作錯誤"); } return(View(data)); }
public ActionResult Delete(int id) { var data = ContactRepo.Find(id); var DelMsg = "客戶聯絡人不存在。"; if (data != null) { try { ContactRepo.Delete(data); ContactRepo.UnitOfWork.Commit(); DelMsg = "客戶聯絡人刪除成功。"; } catch (Exception ex) { DelMsg = "客戶聯絡人刪除失敗。錯誤訊息: " + ex.Message; } } TempData["DelMsg"] = DelMsg; return(RedirectToAction("Index")); }
public ActionResult Create() { ViewBag.Company = CompanyRepo.CompanyNameList(0); return(View("Edit", ContactRepo.Find(0))); }