/// <summary>
        /// Մինչ օնլայն բանկինգի գրանցման ստուգումներ
        /// </summary>
        /// <returns></returns>
        internal RegistrationActionResult ValidateAcbaOnlineCreating(RegistrationCustomerData customerData)
        {
            var resultValidation = new RegistrationActionResult
            {
                ResultCode = CustomerRegistration.ResultCode.Normal
            };

            if (!customerData.IsPhoneVerified)
            {
                resultValidation.ResultCode  = CustomerRegistration.ResultCode.ValidationError;
                resultValidation.Description = "Not verified phone";
                return(resultValidation);
            }

            if (!String.IsNullOrEmpty(customerData.UserName) && !String.IsNullOrEmpty(customerData.Password))
            {
                if (!(customerData.UserName.All(c => Char.IsLetterOrDigit(c)) &&
                      customerData.UserName.Length > 3 &&
                      customerData.Password.Length > 7 &&
                      customerData.Password.All(c => Char.IsLetterOrDigit(c)) &&
                      customerData.Password.Any(char.IsUpper) &&
                      customerData.Password.Any(char.IsNumber) &&
                      customerData.Password.Any(char.IsDigit)
                      ))
                {
                    resultValidation.ResultCode  = CustomerRegistration.ResultCode.ValidationError;
                    resultValidation.Description = "Login pass error";
                    return(resultValidation);
                }
            }
            else
            {
                resultValidation.ResultCode  = CustomerRegistration.ResultCode.ValidationError;
                resultValidation.Description = "UserName or password is empty";
                return(resultValidation);
            }

            if (String.IsNullOrEmpty(customerData.Email))
            {
                resultValidation.ResultCode  = CustomerRegistration.ResultCode.ValidationError;
                resultValidation.Description = "Email does not exist";
                return(resultValidation);
            }

            if (customerData.CustomerQuality != 1)
            {
                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                Match match = regex.Match(customerData.Email);
                if (!match.Success)
                {
                    resultValidation.ResultCode  = CustomerRegistration.ResultCode.ValidationError;
                    resultValidation.Description = "Email regexp error";
                    return(resultValidation);
                }
            }

            return(resultValidation);
        }
        /// <summary>
        /// Գեներացնում է օնլայն բանկինգ
        /// </summary>
        /// <param name="customerData"></param>
        /// <returns></returns>
        public RegistrationActionResult GenerateAcbaOnline(RegistrationCustomerData customerData)
        {
            var result       = new RegistrationActionResult();
            var actionResult = _xbManagementService.GenerateAcbaOnline(customerData.UserName, customerData.Password, customerData.CustomerNumber, customerData.PhoneNumber, customerData.CustomerQuality, customerData.Email);

            StringBuilder stringBuilder = new StringBuilder();

            if (actionResult?.Errors != null)
            {
                foreach (var item in actionResult.Errors)
                {
                    if (actionResult.Errors.Count() == 1)
                    {
                        stringBuilder = stringBuilder.Append(item.Description);
                    }
                    else
                    {
                        stringBuilder = stringBuilder.AppendLine(item.Description);
                    }
                }
                result.Description = stringBuilder.ToString();
            }
            if (actionResult.ResultCode == ResultCode.Normal)
            {
                result.ResultCode = CustomerRegistration.ResultCode.Normal;
            }
            else if (actionResult.ResultCode == ResultCode.ValidationError)
            {
                result.ResultCode = CustomerRegistration.ResultCode.ValidationError;
            }
            else
            {
                result.ResultCode = CustomerRegistration.ResultCode.Failed;
            }
            return(result);
        }
        public RegistrationActionResult ContinueRegistrationProcess(RegistrationCustomerData externalRegData, RegistrationProcessSteps step)
        {
            var result = new RegistrationActionResult();

            result.ResultCode = CustomerRegistration.ResultCode.Failed;
            this.CustomerData = _cache.Get <string, RegistrationCustomerData>("RegistrationCustomerData_" + externalRegData.RegistrationToken);
            if (this.CustomerData != null)
            {
                _cache.UpdateExpiration("RegistrationCustomerData_" + externalRegData.RegistrationToken, 15);
                switch (step)
                {
                case RegistrationProcessSteps.SendSMSVerificationCodeByRegistrationToken:
                    if (this.CustomerData.CustomerQuality != 1 && externalRegData.PhoneNumber.Length == 8 && externalRegData.PhoneNumber.All(c => Char.IsDigit(c)))
                    {
                        this.CustomerData.PhoneNumber = "374" + externalRegData.PhoneNumber;
                    }

                    this.CustomerData.VerificationCode = this.SendVerificationCode(this.CustomerData.PhoneNumber, 5, CustomerRegistrationVerificationSMSTypes.NumbersAndLetters);

                    result.ResultCode = ResultCode.Normal;
                    break;

                case RegistrationProcessSteps.CheckSMSVerificationCodeByRegistrationToken:
                    this.CustomerData.IsPhoneVerified = this.CustomerData.VerificationCode == externalRegData.VerificationCode;

                    if (this.CustomerData.NumberFailedVerificationCount < 3)
                    {
                        if (this.CustomerData.IsPhoneVerified)
                        {
                            this.CustomerData.VerificationCode = String.Empty;
                            if (CustomerData.CustomerQuality != 1)
                            {
                                result = this.AddPhoneForCustomer(this.CustomerData.PhoneNumber, this.CustomerData.CustomerNumber);
                            }
                            else
                            {
                                result.ResultCode = ResultCode.Normal;
                            }
                        }
                        else
                        {
                            result.Description = "Մուտքագրվել է սխալ մեկանգամյա գաղտնաբառ: Մուտքագրեք Բանկում գրանցված Ձեր հեռախոսահամարին ուղարկված մեկանգամյա գաղտնաբառը:";
                            this.CustomerData.NumberFailedVerificationCount++;
                        }
                    }
                    else
                    {
                        _cache.Remove("RegistrationCustomerData_" + externalRegData.RegistrationToken);
                        result.ResultCode  = ResultCode.ValidationError;
                        result.Description = "Դուք գերազանցել եք տվյալների սխալ մուտքագրման սահմանաչափը: Գործընթացը ավարտված է:";
                    }

                    break;

                case RegistrationProcessSteps.GenerateAcbaOnline:
                    this.CustomerData.UserName = externalRegData.UserName;
                    this.CustomerData.Password = externalRegData.Password;

                    if (this.CustomerData.CustomerQuality != 1)
                    {
                        this.CustomerData.Email = externalRegData.Email;
                    }

                    RegistrationActionResult validationResult = _onlineBankingRegistrationManager.ValidateAcbaOnlineCreating(this.CustomerData);
                    if (validationResult.ResultCode == ResultCode.Normal)
                    {
                        if (this.CustomerData.CustomerQuality != 1)
                        {
                            RegistrationActionResult saveEmailResult = this.AddEmailForCustomer(this.CustomerData.Email, this.CustomerData.CustomerNumber);

                            if (saveEmailResult.ResultCode == ResultCode.Normal)
                            {
                                result = _onlineBankingRegistrationManager.GenerateAcbaOnline(this.CustomerData);
                            }
                        }
                        else
                        {
                            result = _onlineBankingRegistrationManager.GenerateAcbaOnline(this.CustomerData);
                        }
                    }
                    else
                    {
                        result = validationResult;
                    }

                    break;
                }
            }
            else
            {
                result.Description = "Initilized customerdata is null";
            }
            return(result);
        }