Example #1
0
 public OperationResult<RegisterUserViewModel> GetRegisterViewModel()
 {
     var result = new RegisterUserViewModel();
     result.ChallengeType = this.securityChallengeProvider.GetChallengeType();
     result.SecurityChallengeText = this.securityChallengeProvider.GetChallengeInput();
     return new OperationResult<RegisterUserViewModel>(result);
 }
Example #2
0
        public ActionResult Index(RegisterUserViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var result = this.registerLogic.RegisterUser(model);
                if (result.Success)
                {
                    return this.RedirectToAction("Profile", "Register", new { id = result.Data });
                }
                result.Errors.ForEach(x => ModelState.AddModelError(string.Empty, x));
            }

            return this.View("Index", model);
        }
        public static RegisterUserViewModel CreateValid()
        {
            var result = new RegisterUserViewModel
                             {
                                 ChallengeType = ChallengeType.CharactersOnly,
                                 DisplayName = "ruvm-test-display-name",
                                 Email = "ruvm-test-email",
                                 Username = "******",
                                 Password = "******",
                                 PasswordConfirmation = "tvm-test-password",
                                 SecurityChallengeText = "12a",
                                 SecurityResult = "a",
                             };

            return result;
        }
Example #4
0
        public OperationResult<long> RegisterUser(RegisterUserViewModel viewModel)
        {
            var securityResult = this.securityChallengeProvider.IsChallengeValid(
                viewModel.SecurityChallengeText,
                viewModel.SecurityResult,
                viewModel.ChallengeType);

            if (!securityResult)
            {
                return new OperationResult<long>(-1, false, "--- security challenge failed ---");
            }

            var rm = Mapper.Map<RegisterUser>(viewModel);
            rm.RegisterDateTime = this.dateTimeAdapter.Now;
            var result = this.registerService.RegisterUser(rm);
            return new OperationResult<long>(result);
        }
Example #5
0
 public JsonResult<OperationResult<long>> Post(RegisterUserViewModel model)
 {
     JsonResult<OperationResult<long>> result;
     var js = new JsonSerializerSettings();
     if (ModelState.IsValid)
     {
         var registerResult = this.registerLogic.RegisterUser(model);
         result = new JsonResult<OperationResult<long>>(registerResult, js, Encoding.Default, this);
     }
     else
     {
         var errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
         var faultyResult = new OperationResult<long>(-1, false, errors.ToList());
         result = new JsonResult<OperationResult<long>>(faultyResult, js, Encoding.Default, this);
     }
     return result;
 }