예제 #1
0
        public ActionResult Edit(int id)
        {
            var data = ContactRepo.Find(id);

            if (data == null)
            {
                throw new InvalidOperationException("操作錯誤");
            }
            return(View(data));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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"));
        }
예제 #4
0
 public ActionResult Create()
 {
     ViewBag.Company = CompanyRepo.CompanyNameList(0);
     return(View("Edit", ContactRepo.Find(0)));
 }