Example #1
0
        public async Task <JsonResult> SignUpAccountHolder(SignUpAccountHolderViewModel model)
        {
            var verificationCode = await _verificationCodeService.GetVerificationCode(int.Parse(model.VerificationCode), model.PhoneNumber);

            if (verificationCode == null)
            {
                throw new UserFriendlyException("Invalid verification code");
            }

            //Delete verificationCode.
            _verificationCodeService.ClearVerificationCode(verificationCode);

            var user = await _userSignUpManager.SignUpAsync(
                model.FirstName,
                model.LastName,
                model.Email,
                model.PhoneNumber,
                model.UserName,
                model.Password,
                true);

            var accountHolder = _accountHolderService.CreateAccountHolder(user.Id);

            //Check if InterestStatus is running and bootstrap Interest for accountholder.
            var interestStatus = await SettingManager.GetSettingValueAsync(AppSettingNames.InterestStatus);

            if (SavingsInterest.StatusTypes.Running.Equals(interestStatus))
            {
                await _savingsInterestManager.BootstrapNewSavingsInterestForAccountHolder(accountHolder.Id);
            }

            //Send a welcome text and email, with AccountHolder Identity.
            _notificationScheduler.ScheduleWelcomeMessage(user.PhoneNumber, user.EmailAddress, accountHolder.AccountIdentity);

            return(Json(new AjaxResponse {
                TargetUrl = "/SignUp/SuccessfulSignUp"
            }));
        }