Example #1
0
        private void ConfirmChangePhoneNumber()
        {
            IsWorking = true;
            StateService.PhoneCode = new TLString(Code);

            MTProtoService.ChangePhoneAsync(
                StateService.PhoneNumber, StateService.PhoneCodeHash, StateService.PhoneCode,
                auth => BeginOnUIThread(() =>
            {
                TLUtils.IsLogEnabled = false;
                TLUtils.LogItems.Clear();

                TimeCounterString = string.Empty;
                HelpVisibility    = Visibility.Collapsed;
                _callTimer.Stop();


                _isProcessing = false;
                auth.NotifyOfPropertyChange(() => auth.Phone);
                NavigationService.RemoveBackEntry();
                NavigationService.GoBack();
                IsWorking = false;
            }),
                error => BeginOnUIThread(() =>
            {
                _lastError = error;
                IsWorking  = false;
                if (error.TypeEquals(ErrorType.PHONE_NUMBER_UNOCCUPIED))
                {
                    _callTimer.Stop();
                    StateService.SentCode             = _sentCode;
                    StateService.ClearNavigationStack = true;
                    NavigationService.UriFor <SignUpViewModel>().Navigate();
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_INVALID))
                {
                    MessageBox.Show(AppResources.PhoneCodeInvalidString, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_EMPTY))
                {
                    MessageBox.Show(AppResources.PhoneCodeEmpty, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_EXPIRED))
                {
                    MessageBox.Show(AppResources.PhoneCodeExpiredString, AppResources.Error, MessageBoxButton.OK);
                    OnBackKeyPress();
                    NavigationService.GoBack();
                }
                else if (error.CodeEquals(ErrorCode.FLOOD))
                {
                    MessageBox.Show(AppResources.FloodWaitString + Environment.NewLine + "(" + error.Message + ")", AppResources.Error, MessageBoxButton.OK);
                }
                else
                {
#if DEBUG
                    MessageBox.Show(error.ToString());
#endif
                }
            }));
        }