public ActionResult ProfileEdit() { FormsIdentity id = (FormsIdentity)User.Identity; var user = JsonConvert.DeserializeObject <UserModel>(id.Ticket.UserData); if (user == null) { return(this.HttpNotFound()); } var customer = customerRespository.Find(user.Id); if (customer == null) { return(RedirectToAction("Index", "Home")); } var profileViewModel = new ProfileViewModel() { Id = customer.Id, 帳號 = customer.帳號, 客戶名稱 = customer.客戶名稱, 統一編號 = customer.統一編號, Email = customer.Email, 電話 = customer.電話, 傳真 = customer.傳真, 地址 = customer.地址, 密碼 = "", 確認密碼 = "" }; return(View(profileViewModel)); }
// GET: 客戶資料/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } 客戶資料 客戶資料 = customerRepository.Find(id); if (客戶資料 == null) { return(HttpNotFound()); } return(View(客戶資料)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { I客戶資料Repository customeRepository = RepositoryHelper.Get客戶資料Repository(); var customer = customeRepository.Find(this.客戶Id); if (customer != null) { var isRepeat = customer.Email == this.Email || (from concat in customer.客戶聯絡人 where concat.Id != this.Id select concat.Email) .Any(mail => mail == this.Email); if (isRepeat) { yield return(new ValidationResult("Email 已經重複", new[] { nameof(Email) })); } } customeRepository.UnitOfWork.Context.Dispose(); }