예제 #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    if (model.IsBarista)
                    {
                        Roles.AddUserToRole(model.UserName, "Barista");
                        return RedirectToAction("Index", "Barista");
                    }
                    else
                    {
                        WebSecurity.Login(model.UserName, model.Password);
                        return RedirectToAction("Index", "Home");
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #2
0
        public ActionResult Register(string type)
        {
            RegisterModel model = new RegisterModel();

            if (type == "barista")
            {
                model.IsBarista = true;
            }

            return View(model);
        }