Exemplo n.º 1
0
        public async Task <PhoneNumberAvailabilty> CheckPhoneNumberAvailabiltyAsync(string phoneNumber, CancellationToken cancellationToken) =>
        await Task.Run(async() => {
            PhoneNumberAvailabilty phoneNumberAvailabilty = null;

            string url = string.Format(BaseSingleton <GlobalSetting> .Instance.RestEndpoints.IdentityEndpoints.CheckPhoneNumberEndPoint, phoneNumber);

            try {
                phoneNumberAvailabilty = await _requestProvider.GetAsync <PhoneNumberAvailabilty>(url);
            }
            catch (ConnectivityException ex) {
                throw ex;
            }
            catch (HttpRequestExceptionEx ex) {
                throw ex;
            }
            catch (Exception ex) {
                Debug.WriteLine($"ERROR:{ex.Message}");
                Debugger.Break();
            }

            return(phoneNumberAvailabilty);
        }, cancellationToken);
Exemplo n.º 2
0
        protected async override void OnStepCommand()
        {
            if (ValidateForm())
            {
                Guid busyKey = Guid.NewGuid();
                SetBusy(busyKey, true);

                try {
                    ResetCancellationTokenSource(ref _checkPhoneNumberCancellationTokenSource);
                    CancellationTokenSource cancellationTokenSource = _checkPhoneNumberCancellationTokenSource;

                    PhoneNumberAvailabilty phoneNumberAvailabilty = await _identityService.CheckPhoneNumberAvailabiltyAsync(MainInput.Value, cancellationTokenSource.Token);

                    if (phoneNumberAvailabilty != null)
                    {
                        if (phoneNumberAvailabilty.IsRequestSuccess)
                        {
                            await NavigationService.NavigateToAsync <NameRegisterStepViewModel>(new RegistrationCollectedInputsArgs()
                            {
                                PhoneNumber = MainInput.Value
                            });
                        }
                        else
                        {
                            ServerError = phoneNumberAvailabilty.Message;
                        }
                    }
                }
                catch (Exception ex) {
                    ServerError = ex.Message;

                    Debug.WriteLine($"ERROR:{ex.Message}");
                    Debugger.Break();
                }
                SetBusy(busyKey, false);
            }
        }