public ActionResult Register(UserView userView) { if (userView.Captcha != (string)Session[CaptchaImage.CaptchaValueKey]) { ModelState.AddModelError("Captcha", "Текст с картинки введен неверно"); } var anyUser = Repository.Users.Any(p => string.Compare(p.Email, userView.Email) == 0); if (anyUser) { ModelState.AddModelError("Email", "Пользователь с таким email уже зарегистрирован"); } if (ModelState.IsValid) { var user = (User)ModelMapper.Map(userView, typeof(UserView), typeof(User)); Repository.CreateUser(user); return RedirectToAction("Index"); } return View(userView); }
public ActionResult Register() { var newUserView = new UserView(); return View(newUserView); }