コード例 #1
0
        private void Authorise()
        {
            Pin pin;

            try
            {
                pin = Pin.CreateFrom(OneTimePin);
            }
            catch (Exception e)
            {
                base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);
                return;
            }

            base.ShowHeaderLoader();
            OneTimePinTextBoxIsEnabled = false;

            Action authorise = async() =>
            {
                try
                {
                    cancellationTokenSource = new CancellationTokenSource();

                    user = await DrumbleApi.Authorise(cancellationTokenSource.Token, user, email, pin);

                    if (user.IsBumbleRegistered)
                    {
                        base.HideHeaderLoader();
                        OneTimePinTextBoxIsEnabled = true;

                        AuthoriseMessage.Send(user, Messages.Enums.AuthoriseMessageReason.Authorised);

                        NavigationService.GoBack();
                    }
                    else
                    {
                        // TODO error display something went wrong... but what?
                    }
                }
                catch (Exception e)
                {
                    base.HideHeaderLoader();
                    OneTimePinTextBoxIsEnabled = true;

                    base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);
                }
            };

            DispatcherHelper.CheckBeginInvokeOnUI(authorise);
        }