public ActionResult Create([Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email,客戶分類")] 客戶資料 客戶資料) { if (ModelState.IsValid) { customerRepository.Add(客戶資料); customerRepository.UnitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(客戶資料)); }
public ActionResult Create(CustomerEditViewModel vm) { if (ModelState.IsValid) { //密碼加密 string salt = Guid.NewGuid().ToString(); byte[] pwdAndSalt = Encoding.UTF8.GetBytes(vm.Customer.Password + salt); byte[] hashBytes = new SHA256Managed().ComputeHash(pwdAndSalt); string hash = Convert.ToBase64String(hashBytes); vm.Customer.Password = hash; 客戶資料 newData = vm.Customer; CustomerRepo.Add(newData); CustomerRepo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(vm)); }