Exemplo n.º 1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, propertyValues: new
                        {
                            Email = model.Email,
                            IsBlocked = (model.IsBlocked = true)
                        });
                    var service = new NotificationService();
                    service.RegisterUser(model.Email, model.UserName);
                    ViewBag.Message = Resources.UIStrings.AfterRegisterString;
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }