public ActionResult Register(User user) { UManager userManager = new UManager(); if (ModelState.IsValid) { try { userManager.CreateUser(user); return RedirectToAction("Login"); } catch (DbUpdateException ex) { ModelState.AddModelError("Error", ex.Message); return View(); } catch (UnknownErrorException ex) { ModelState.AddModelError("Error", ex.Message); return View(); } } else { return View(); } }
public ActionResult Login(User user) { UManager userManager = new UManager(); if (ModelState.IsValid) { try { userManager.Login(user.EmailAddress, user.Password); return RedirectToAction("index"); } catch (InvalidUserException ex) { ModelState.AddModelError("Error", ex.Message); return View(); } catch (UnknownErrorException ex) { ModelState.AddModelError("Error", ex.Message); return View(); } } else { return View(); } }