示例#1
0
        private void PerformLogin()
        {
            ErrorMessage = "";

            if (Username == null)
            {
                ErrorMessage = "Please enter username";
                return;
            }

            if (Password == null)
            {
                ErrorMessage = "Please enter password";
                return;
            }

            try
            {
                if (AccountManager.LoginUser(Username, Password))
                {
                    // Login was successful, move to chat list
                    ViewPresenter.PushView(new Views.ChatListView());
                }
            }
            catch (ApiException e)
            {
                var error = ErrorCodes.TranslateError(e.ErrorContent);
                ErrorMessage = error.Message;
            }
        }
        private void PerformSave()
        {
            ErrorMessage = "";

            var am = AccountManager.GetInstance();

            bool usernameChanged    = Username != am.Username;
            bool passwordChanged    = Password != "" && Password == PasswordConfirm && Password == am.Password;
            bool emailChanged       = Email != am.Email;
            bool displayNameChanged = DisplayName != am.DisplayName;

            try
            {
                // Continue with registration process
                DefaultApi api = new DefaultApi("http://localhost:8080/api/");

                bool ret = false;
                ret = AccountManager.UpdateUser(AccountManager.GetInstance().Token,
                                                usernameChanged ? Username : null,
                                                passwordChanged ? Password : null,
                                                emailChanged ? Email : null,
                                                displayNameChanged ? DisplayName : null);

                if (ret)
                {
                    // Get out of registration screen now that we're registered
                    ViewPresenter.PopView();
                }
            }
            catch (ApiException e)
            {
                var error = ErrorCodes.TranslateError(e.ErrorContent);
                ErrorMessage = error.Message;
            }
        }
示例#3
0
        public static ViewPresenter GetInstance()
        {
            if (_viewPresenter == null)
            {
                _viewPresenter = new ViewPresenter();
            }

            return(_viewPresenter);
        }
示例#4
0
        public static ViewPresenter GetInstance()
        {
            if(_viewPresenter == null)
            {
                _viewPresenter = new ViewPresenter();
            }

            return _viewPresenter;
        }
        private void PerformRegister()
        {
            ErrorMessage = "";

            if (Username == null)
            {
                ErrorMessage = "Please enter username";
                return;
            }

            if (Password == null)
            {
                ErrorMessage = "Please enter password";
                return;
            }

            if (PasswordConfirm == null)
            {
                ErrorMessage = "Please enter password confirmation";
                return;
            }

            if (Email == null)
            {
                ErrorMessage = "Please enter email";
                return;
            }

            if (Password != PasswordConfirm)
            {
                ErrorMessage = "Password does not match";
                return;
            }

            try
            {
                // Continue with registration process
                if (AccountManager.RegisterUser(Username, Password, Email, DisplayName))
                {
                    // Get out of registration screen now that we're registered
                    ViewPresenter.PopView();

                    if (AccountManager.LoginUser(Username, Password))
                    {
                        // If the post-registration login was successful, automatically move to the friend list
                        ViewPresenter.PushView(new Views.FriendListView());
                    }
                }
            }
            catch (ApiException e)
            {
                var error = ErrorCodes.TranslateError(e.ErrorContent);
                ErrorMessage = error.Message;
            }
        }
示例#6
0
 private void Signout()
 {
     AccountManager.Signout();
     ViewPresenter.PopView();
 }
示例#7
0
 private void OptionsView()
 {
     ViewPresenter.PushView(new Views.OptionsView());
 }