private void DoFindVote()
        {
            var findVoteVm = GetVm <FindVoteViewModel>();

            findVoteVm.SetResults(_questions, _answers);
            MainVm.ChangeView(EvotoView.FindVote);
        }
        public void DoBack()
        {
            MainVm.ChangeView(EvotoView.Results);
            var resultsVm = GetVm <ResultsViewModel>();

            resultsVm.ReInit();
        }
Example #3
0
        private void DoProceed()
        {
            var resultsVm = GetVm <ResultsViewModel>();

            resultsVm.SelectVote(_blockchain);
            MainVm.ChangeView(EvotoView.Results);
        }
Example #4
0
 private void DoContinue()
 {
     MainVm.ChangeView(EvotoView.ResetPassword);
     if (!string.IsNullOrWhiteSpace(Email))
     {
         var resetVm = ServiceLocator.Current.GetInstance <ResetPasswordViewModel>();
         resetVm.SetEmail(Email, false);
     }
 }
Example #5
0
 private void DoForgotPassword()
 {
     ErrorMessage = "";
     if (!string.IsNullOrWhiteSpace(Email))
     {
         var forgotPasswordVM = ServiceLocator.Current.GetInstance <ForgotPasswordViewModel>();
         forgotPasswordVM.SetEmail(Email);
     }
     MainVm.ChangeView(EvotoView.ForgotPassword);
 }
        private void DoVote()
        {
            if (!MultiChainVm.Connected)
            {
                throw new Exception("Not connected");
            }

            // Get userbar to temporarily disable logout
            var userBar = GetVm <UserBarViewModel>();

            // Reset vote progress
            VoteProgress = new VoteProgressViewModel();

            Ui(() =>
            {
                userBar.LogoutDisabled = true;
                Voting       = true;
                ErrorMessage = "";
            });

            Task.Run(async() =>
            {
                try
                {
                    var words = await MultiChainVm.Vote(Questions.ToList(), _currentDetails, VoteProgress.Progress);
                    Ui(() =>
                    {
                        Voting                 = false;
                        VoteProgress           = null;
                        userBar.LogoutDisabled = false;

                        var postVoteVm = GetVm <PostVoteViewModel>();
                        postVoteVm.Voted(_currentDetails, words);
                        MainVm.ChangeView(EvotoView.PostVote);
                    });
                }
                catch (CouldNotVoteException)
                {
                    Ui(() =>
                    {
                        Voting                 = false;
                        VoteProgress           = null;
                        userBar.LogoutDisabled = false;

                        ErrorMessage =
                            "An error occurred while voting. Please try again or contact a system administrator";
                    });
                }
            });
        }
Example #7
0
        private void DoProceed()
        {
            if (SelectedVote == null)
            {
                return;
            }

            Loading = true;

            Task.Run(async() =>
            {
                var showResults = true;
                if (SelectedVote.IsCurrent)
                {
                    // Contact the Registrar to see if we have voted on this vote yet
                    showResults = await _voteClient.HasVoted(SelectedVote.ChainString);
                }

                Ui(() =>
                {
                    Loading          = false;
                    ErrorMessage     = "";
                    ShowErrorMessage = false;
                });

                if (!showResults)
                {
                    MainVm.ChangeView(EvotoView.Vote);
                    var voteView = GetVm <VoteViewModel>();
                    voteView.SelectVote(SelectedVote.GetModel());
                }
                else
                {
                    if (!SelectedVote.Encrypted)
                    {
                        MainVm.ChangeView(EvotoView.Results);
                        var resultsVm = GetVm <ResultsViewModel>();
                        resultsVm.SelectVote(SelectedVote.GetModel());
                    }
                    else
                    {
                        Ui(() =>
                        {
                            ErrorMessage     = "This vote is encrypted and still active. Results cannot be viewed.";
                            ShowErrorMessage = true;
                        });
                    }
                }
            });
        }
 private void DoBack()
 {
     MainVm.ChangeView(EvotoView.Home);
 }
Example #9
0
 private void DoRegister()
 {
     ErrorMessage = "";
     MainVm.ChangeView(EvotoView.Register);
 }
Example #10
0
        private void DoSendEmail()
        {
            ForgotPasswordModel forgotPasswordModel;

            if (!IsFormValid(out forgotPasswordModel))
            {
                return;
            }

            Loading      = true;
            ErrorMessage = "";
            Task.Run(async() =>
            {
                try
                {
                    await _userClient.ForgotPassword(forgotPasswordModel);
                    var resetVm = ServiceLocator.Current.GetInstance <ResetPasswordViewModel>();
                    resetVm.SetEmail(Email);
                    MainVm.ChangeView(EvotoView.ResetPassword);

                    Ui(() =>
                    {
                        Email   = "";
                        Loading = false;
                    });
                }
                catch (TokenDelayException e)
                {
                    Ui(() =>
                    {
                        ErrorMessage =
                            $"Please wait {e.Message} before sending another email. Be sure to check your spam folder";
                        Loading = false;
                    });
                }
                catch (UnconfirmedEmailException)
                {
                    Ui(() =>
                    {
                        ErrorMessage = "This email has not been verified. Please contact an administrator.";
                        Loading      = false;
                    });
                }
                catch (BadRequestException e)
                {
                    Ui(() =>
                    {
                        ErrorMessage = e.Message;
                        Loading      = false;
                    });
                }
                catch (ApiException)
                {
                    Ui(() =>
                    {
                        ErrorMessage = "An Unknown Error Occurred";
                        Loading      = false;
                    });
                }
            });
        }
Example #11
0
 private void BackToLogin()
 {
     MainVm.ChangeView(EvotoView.Login);
 }
        private void DoRegister(object parameter)
        {
            RegisterModel registerModel;

            // Ensure form is valid
            if (!IsFormValid(parameter, out registerModel))
            {
                return;
            }

            registerModel.CustomFields = CustomFields.Select(cf => cf.GetModel()).ToList();

            Loading      = true;
            ErrorMessage = "";
            Task.Run(async() =>
            {
                try
                {
                    // Send registration info to API
                    await _userClient.Register(registerModel);

                    // Redirect to login page
                    MainVm.ChangeView(EvotoView.Login);
                    var loginVm = ServiceLocator.Current.GetInstance <LoginViewModel>();

                    Ui(() =>
                    {
                        Loading = false;
                        ResetForm(parameter);
                    });

                    // Autofill their email and ask them to verify it
                    loginVm.VerifyEmail(Email);
                }
                catch (RegisterDisabledException)
                {
                    _registerDisabled = true;
                    RaisePropertyChanged(nameof(CanRegister));
                    Ui(() =>
                    {
                        ErrorMessage = "Sorry, registration is not enabled at this time";
                        Loading      = false;
                    });
                }
                catch (BadRequestException e)
                {
                    Ui(() =>
                    {
                        ErrorMessage = e.Message;
                        Loading      = false;
                    });
                }
                catch (ApiException)
                {
                    Ui(() =>
                    {
                        ErrorMessage = "An Unknown Error Occurred";
                        Loading      = false;
                    });
                }
            });
        }
 private void DoBack()
 {
     MainVm.ChangeView(EvotoView.ForgotPassword);
 }