示例#1
0
 public ActionResult RegisterForm(RegisterFormViewModel viewModel)
 {
     if (membershipManagementService.Validate(viewModel))
     {
         // todo: register
         membershipManagementService.Register(viewModel);
         return View("EditorTemplates/RegisterResult");
     }
     return View(viewModel);
 }
        private bool ValidateRegister(RegisterFormViewModel registerViewModel)
        {
            if (string.IsNullOrEmpty(registerViewModel.Register.Email))
            {

            }
            if (string.IsNullOrEmpty(registerViewModel.Register.Password))
            {

            }
            if(!registerViewModel.Register.Password.Equals(registerViewModel.Register.ConfirmPassword))
            {

            }
            return !errors.Any();
        }
 /// <summary>
 /// Validates the specified register view model.
 /// </summary>
 /// <param name="registerViewModel">The register view model.</param>
 /// <returns>
 ///    <c>true</c> if Register and Profile valid; otherwise, <c>false</c>.
 /// </returns>
 public bool Validate(RegisterFormViewModel registerViewModel)
 {
     bool isValid = ValidateRegister(registerViewModel);
     if (isValid)
     {
         isValid = ValidateProfile(registerViewModel);
     }
     registerViewModel.Errors = errors;
     return isValid;
 }
        private bool ValidateProfile(RegisterFormViewModel registerViewModel)
        {
            if (registerViewModel.Profile == null)
            {
                registerViewModel.Profile = new ProfileViewModel();
                return false;
            }
            if (string.IsNullOrEmpty(registerViewModel.Profile.FirstName))
            {

            }
            if (string.IsNullOrEmpty(registerViewModel.Profile.LastName))
            {

            }
            if (registerViewModel.Register.AccountType == AccountTypeEnum.Student)
            {
                if (registerViewModel.Profile.Group == null)
                {

                }
                else
                {
                    //todo: additional group checks, if need
                }
            }
            return !errors.Any();
        }
        /// <summary>
        /// Registers the user.
        /// </summary>
        /// <param name="registerViewModel">The register view model.</param>
        /// <returns>
        ///   <c>true</c> if user successful registered; otherwise, <c>false</c>.
        /// </returns>
        public bool Register(RegisterFormViewModel registerViewModel)
        {
            if (Validate(registerViewModel))
            {
                var user = RegisterUser(registerViewModel.Register);
                CreateProfile(registerViewModel.Profile, user);

                eUniversityUow.Commit();
                return true;
            }
            return false;
        }