/// <summary>
        /// Converts the <see cref="RegisterIdentityModel"/> to an array of <inheritdoc cref="Property"/>.
        /// </summary>
        /// <param name="neuronService">The Neuron service to use for accessing the Bare Jid.</param>
        /// <returns>The <see cref="RegisterIdentityModel"/> as a list of properties.</returns>
        public Property[] ToProperties(INeuronService neuronService)
        {
            List <Property> properties = new List <Property>();
            string          s;

            if (!string.IsNullOrWhiteSpace(s = this.FirstName?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.FirstName, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.MiddleNames?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.MiddleName, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.LastNames?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.LastName, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.PersonalNumber?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.PersonalNumber, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.Address?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.Address, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.Address2?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.Address2, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.ZipCode?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.ZipCode, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.Area?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.Area, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.City?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.City, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.Region?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.Region, s));
            }

            if (!string.IsNullOrWhiteSpace(s = this.Country?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.Country, ISO_3166_1.ToCode(s)));
            }

            if (!string.IsNullOrWhiteSpace(s = this.DeviceId?.Trim()))
            {
                properties.Add(new Property(Constants.XmppProperties.DeviceId, s));
            }

            properties.Add(new Property(Constants.XmppProperties.JId, neuronService.BareJId));

            return(properties.ToArray());
        }
        private async Task Register()
        {
            if (!(await this.ValidateInput(true)))
            {
                return;
            }

            string countryCode           = ISO_3166_1.ToCode(this.SelectedCountry);
            string pnr                   = PersonalNumber.Trim();
            string pnrBeforeValidation   = pnr;
            bool?  personalNumberIsValid = PersonalNumberSchemes.IsValid(countryCode, ref pnr, out string personalNumberFormat);

            if (personalNumberIsValid.HasValue && !personalNumberIsValid.Value)
            {
                if (string.IsNullOrWhiteSpace(personalNumberFormat))
                {
                    await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.PersonalNumberDoesNotMatchCountry);
                }
                else
                {
                    await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.PersonalNumberDoesNotMatchCountry_ExpectedFormat + personalNumberFormat);
                }
                return;
            }
            if (pnr != pnrBeforeValidation)
            {
                this.PersonalNumber = pnr;
            }

            if (string.IsNullOrWhiteSpace(this.TagProfile.LegalJid))
            {
                await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.OperatorDoesNotSupportLegalIdentitiesAndSmartContracts);

                return;
            }

            if (string.IsNullOrWhiteSpace(this.TagProfile.RegistryJid))
            {
                await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.OperatorDoesNotSupportThingRegistries);

                return;
            }

            if (string.IsNullOrWhiteSpace(this.TagProfile.ProvisioningJid))
            {
                await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.OperatorDoesNotSupportProvisioningAndDecisionSupportForThings);

                return;
            }

            if (!this.NeuronService.IsOnline)
            {
                await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.NotConnectedToTheOperator);

                return;
            }

            SetIsBusy(RegisterCommand, TakePhotoCommand, PickPhotoCommand);

            try
            {
                RegisterIdentityModel     model  = CreateRegisterModel();
                LegalIdentityAttachment[] photos = { photo };
                (bool succeeded, LegalIdentity addedIdentity) = await this.networkService.TryRequest(() => this.NeuronService.Contracts.AddLegalIdentity(model, photos));

                if (succeeded)
                {
                    this.LegalIdentity = addedIdentity;
                    this.TagProfile.SetLegalIdentity(this.LegalIdentity);
                    UiDispatcher.BeginInvokeOnMainThread(() =>
                    {
                        SetIsDone(RegisterCommand, TakePhotoCommand, PickPhotoCommand);
                        OnStepCompleted(EventArgs.Empty);
                    });
                }
            }
            catch (Exception ex)
            {
                this.LogService.LogException(ex);
                await this.UiDispatcher.DisplayAlert(ex);
            }
            finally
            {
                BeginInvokeSetIsDone(RegisterCommand, TakePhotoCommand, PickPhotoCommand);
            }
        }