/// <summary>
        /// Հաճախորդի գրանցում քարտով կամ ընթացիկ հաշվով
        /// </summary>
        /// <returns></returns>
        public CustomerRegistrationProcessResult RegistrateByBankProductInformation()
        {
            var result   = new CustomerRegistrationProcessResult();
            var customer = new PhysicalCustomer();

            if (!String.IsNullOrEmpty(this.RegParams.ProductValue))
            {
                if (this.RegParams.ProductType == RegistrationProductType.AccountNumber)
                {
                    try
                    {
                        customer.customerNumber = _xbService.GetAccountCustomerNumber(this.RegParams.ProductValue);
                    }
                    catch
                    {
                        //Քանի որ չգտնելու դեպքում xbs-ից throw է արվում exception
                        customer.customerNumber = 0;
                    }
                }
                else if (this.RegParams.ProductType == RegistrationProductType.CardNumber)
                {
                    customer.customerNumber = _xbService.GetCardCustomerNumber(this.RegParams.ProductValue);
                }


                if (customer.customerNumber == default(ulong))
                {
                    customer = null;
                }
                else
                {
                    customer = _acbaOperationService.GetCustomer(customer.customerNumber);
                }
            }
            else
            {
                customer = null;
            }

            if (customer == null)
            {
                result.RegistrationResult = RegistrationResult.NotFoundClient;
                result.ResultDescription  = "Մուտքագրվել են սխալ տվյալներ: Խնդրում ենք կրկին մուտքագրել:";
                return(result);
            }
            result = RegistratePhysicalCustomer(customer);
            return(result);
        }
        /// <summary>
        /// Հաճախորդի գրանցում անձնական տվյալներով
        /// Նույնականացնում է ֆիզիկական անձին անձնական տվյալների հիման վրա։
        /// Եթե Նորք/Էկենգից վերադարձված հաճախորդը առկա չէ բանկի բազայում, ապա գրանցում է։
        /// </summary>
        /// <returns></returns>
        public CustomerRegistrationProcessResult RegistrateByPersonalInformation()
        {
            var result = new CustomerRegistrationProcessResult();
            PhysicalCustomer             physicalCustomer     = null;
            CustomerIdentificationResult identificationResult = null;

            if (!String.IsNullOrEmpty(this.RegParams.DocumentValue))
            {
                var notIdentifiedCustomer = new PhysicalCustomer()
                {
                    person = new Person()
                    {
                        documentList = new List <CustomerDocument>()
                    }
                };
                notIdentifiedCustomer.person.documentList.Add(new CustomerDocument()
                {
                    documentGroup = new KeyValue()
                    {
                        key = 1
                    }, documentType = new KeyValue()
                    {
                        key = (short)this.RegParams.DocumentType
                    }, documentNumber = this.RegParams.DocumentValue
                });

                try
                {
                    identificationResult = _acbaOperationService.IdentifyCustomer(notIdentifiedCustomer);
                }
                catch
                {
                    result.RegistrationResult = RegistrationResult.NotFoundClient;
                    result.ResultDescription  = "Գրանցումը հնարավոր չէ կատարել:  Փորձեք մի փոքր ուշ կամ կապ հաստատեք Բանկի հետ:";
                    return(result);
                }
                physicalCustomer = _acbaOperationService.GetCustomer(identificationResult.CustomerNumber);
            }

            result = RegistratePhysicalCustomer(physicalCustomer);

            return(result);
        }
        private CustomerRegistrationProcessResult RegistratePhysicalCustomer(PhysicalCustomer customer)
        {
            var result = new CustomerRegistrationProcessResult();

            if (customer != null && customer.customerNumber != default(ulong))
            {
                if (!_acbaOperationService.CheckCustomerUpdateExpired(customer.customerNumber) || customer.quality.key != 1)
                {
                    this.CustomerData.CustomerNumber  = customer.customerNumber;
                    this.CustomerData.CustomerQuality = customer.quality.key;

                    bool hasCustomerOnlineBanking = _xbService.HasCustomerOnlineBanking(customer.customerNumber);

                    if (!hasCustomerOnlineBanking)
                    {
                        string name    = Utilities.Utils.ConvertAnsiToUnicode(customer.person.fullName.firstName);
                        string surname = Utilities.Utils.ConvertAnsiToUnicode(customer.person.fullName.lastName);

                        if (customer.quality.key == 1 && customer.customerType.key == 6)
                        {
                            CustomerEmail customerEmail = customer.person.emailList.Find(email => email.emailType.key == 5 && email.priority.key == 1 && email.quality.key == 1);
                            CustomerPhone customerPhone = customer.person.PhoneList.Find(phone => phone.phoneType.key == 1 && phone.phone.countryCode == "+374" && phone.priority.key == 1);

                            if (customerEmail != null && customerPhone != null)
                            {
                                string phoneNumber  = customerPhone.phone.countryCode + customerPhone.phone.areaCode + customerPhone.phone.phoneNumber;
                                string emailAddress = customerEmail.email.emailAddress;


                                result.RegistrationResponseData = new Dictionary <string, string>()
                                {
                                    { "phoneNumber", phoneNumber.Substring(0, 6) + new StringBuilder(4).Insert(0, "*", 4).ToString() + phoneNumber.Substring(10, 2) },
                                    { "email", emailAddress.Substring(0, 3) + new String('#', emailAddress.Length - 6) + emailAddress.Substring(emailAddress.Length - 3, 3) },
                                    { "nameSurname", name.Substring(0, 2) + new String('#', name.Length - 2) + " " + surname.Substring(0, 2) + new String('#', surname.Length - 2) },
                                    { "customerNumber", customer.customerNumber.ToString() }
                                };

                                result.RegistrationResult = RegistrationResult.ClientWithCustomerQuality;
                                //result.ResultDescription = "Բանկում գրանցված տվյալները հաճախորդին երևում են ոչ լիարժեք ---> sharunakvum e grancume";

                                //remove the + from +374xxyyyyyy
                                this.CustomerData.PhoneNumber = phoneNumber.Remove(0, 1);
                                this.CustomerData.Email       = emailAddress;
                            }
                            else
                            {
                                result.RegistrationResult = RegistrationResult.ClientHavingCustomerQualityWithInsufficientData;
                                result.ResultDescription  = "Հարգելի հաճախորդ, Ձեր օնլայն գրանցումը հնարավոր չէ շարունակել: Խնդրում ենք մոտենալ ցանկացած մասնաճյուղ:";
                            }
                        }
                        else
                        {
                            result.RegistrationResult       = RegistrationResult.ClientWithNonCustomerQuality;
                            result.RegistrationResponseData = new Dictionary <string, string>()
                            {
                                { "nameSurname", name.Substring(0, 2) + new String('#', name.Length - 2) + " " + surname.Substring(0, 2) + new String('#', surname.Length - 2) },
                                { "customerNumber", customer.customerNumber.ToString() }
                            };
                            //result.ResultDescription = "Ցանկացած այլ կարգավիճակ ունեցող հաճախորդ (օր` դիմորդ, ելք կատարող անձ և այլն) կուղղորվի դեպի ոչ հաճախորդ սցենարով և կունենա նոր հաճախորդ համար:";
                        }

                        string registrationToken = this.RegistrateByIdentificationResult(result.RegistrationResult);

                        if (!String.IsNullOrEmpty(registrationToken))
                        {
                            result.RegistrationResponseData.Add("RegistrationToken", registrationToken);
                        }
                    }
                    else
                    {
                        result.RegistrationResult = RegistrationResult.ExistingOnlineUser;
                        result.ResultDescription  = "Դուք արդեն հանդիսանում եք «ACBA Digital» օգտատեր:";
                    }
                }
                else
                {
                    result.RegistrationResult = RegistrationResult.UpdateExpired;
                    result.ResultDescription  = "Հարգելի հաճախորդ, Ձեր օնլայն գրանցումը հնարավոր չէ շարունակել: Խնդրում ենք մոտենալ ցանկացած մասնաճյուղ:";
                }
            }
            return(result);
        }