Ejemplo n.º 1
0
        public ActionResult Register(RegistrationViewModel registrationData)
        {
            try
            {
                var userAccount = Membership.CreateUser(registrationData.UserName,
                    registrationData.Password,registrationData.EmailAddress);

                var membership = new Models.Membership();
                membership.UserName = userAccount.UserName;
                membership.IsConfirmed = false;

                _membershipRepository.InsertOrUpdate(membership);
                _membershipRepository.Save();

                return RedirectToAction("Index", "Home");
            }
            catch(MembershipCreateUserException ex)
            {
                this.ModelState.AddModelError(String.Empty,ex.Message);
                return View();
            }
            catch
            {
                this.ModelState.AddModelError(String.Empty,"A general error ocurred while trying to create your account. Please try again.");
                return View();
            }
        }
Ejemplo n.º 2
0
        public static ValidationResult ValidatePassword(RegistrationViewModel viewModel,ValidationContext context)
        {
            if(!viewModel.Password.Equals(viewModel.PasswordConfirmation))
            {
                return new ValidationResult(null,new string [] { "Password" });
            }

            return ValidationResult.Success;
        }