public SignInViewModel(IEventAggregator aggregator)
        {
            this.aggregator = aggregator;

            aggregator.Subscribe(this);

            this.ProblemsSigningInCommand = new RelayCommand(() =>
            {
                aggregator.Publish(new ProblemsSigningIn(this.Login));
            });

            this.NavigateToImportCommand = new RelayCommand(() =>
            {
                aggregator.Publish(new NavigateTo(typeof(KeyManagementViewModel)));
            });

            this.SignInCommand = new RelayCommand(async() =>
            {
                this.ClearErrors();

                if (string.IsNullOrWhiteSpace(this.Login))
                {
                    this.AddErrorFor(nameof(this.Login), "Login should be a valid email");
                }


                if (this.HasErrors)
                {
                    return;
                }

                try
                {
                    this.IsBusy   = true;
                    var operation = new LoadAccountOperation(this.aggregator);
                    await operation.Initiate(this.Login, "");
                    this.aggregator.Publish(new ConfirmOperation(operation));
                }
                catch (VirgilPublicServicesException exception) when(exception.ErrorCode == 30202)
                {
                    this.AddErrorFor(nameof(this.Login), exception.Message);
                }
                catch (IdentityServiceException exception) when(exception.ErrorCode == 40200)
                {
                    this.AddErrorFor(nameof(this.Login), exception.Message);
                }
                catch (Exception exception)
                {
                    this.RaiseErrorMessage(exception.Message);
                }
                finally
                {
                    this.IsBusy = false;
                }
            });

            this.NavigateToCreateAccountCommand = new RelayCommand(() =>
            {
                aggregator.Publish(new NavigateTo(typeof(ICreateNewAccountModel)));
            });
        }
Beispiel #2
0
 public ConfirmOperation(LoadAccountOperation operation)
 {
     this.Operation = operation;
 }