Example #1
0
 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();
     }
 }
Example #2
0
        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();
            }
        }