public ActionResult Register(DoctorView newDoctor) { bool anyUser = _repository.GetDoctors().Any(p => string.Compare(p.Email, newDoctor.Email) == 0); if (anyUser) { ModelState.AddModelError("Email", "Пользователь с таким email уже зарегистрирован"); } if (ModelState.IsValid) { var currentDoctor = (Doctor)_mapper.Map(newDoctor, typeof(DoctorView), typeof(Doctor)); currentDoctor.Password = PasswordHasher.GetHashPassword(currentDoctor.Password); this.SaveClient(currentDoctor); if (!SendEmail(currentDoctor)) { ModelState.AddModelError("Email", "Введите корректный емейл"); DeleteDoctor(currentDoctor.ID); return View(newDoctor); } return RedirectToAction("Confirm", "Doctor"); } return View(newDoctor); }
public ActionResult Register() { DoctorView newDoctor = new DoctorView(); return View(newDoctor); }