public ActionResult CustomerEdit(CustomerOnlyEditViewModel vm) { if (ModelState.IsValid) { CustomerRepo.UpdateCustomerOnlyData(vm); CustomerRepo.UnitOfWork.Commit(); return(RedirectToAction("CustomerEdit")); } return(View(vm)); }
public void UpdateCustomerOnlyData(CustomerOnlyEditViewModel vm) { var existData = this.All().Where(x => x.Id == vm.Id).FirstOrDefault(); if (existData == null) { throw new Exception("找不到此客戶"); } existData.電話 = vm.電話; existData.傳真 = vm.傳真; existData.地址 = vm.地址; existData.Email = vm.Email; }