Exemple #1
0
        /// <summary>
        /// checks if data is valid, then sends a password change request
        /// </summary>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <param name="newPasswordRe"></param>
        /// <returns></returns>
        public async Task <bool> ChangePassword(string oldPassword, string newPassword, string newPasswordRe)
        {
            try
            {
                IsLoading = true;
                if (newPassword != newPasswordRe)
                {
                    throw new Exception("A két új jelszó értéke nem egyezik meg!");
                }
                ChangePasswordRequest changePasswordRequest = new ChangePasswordRequest
                {
                    OldPassword = oldPassword,
                    NewPassword = newPassword
                };
                await _accountApiService.ChangePassword(changePasswordRequest);

                return(true);
            }
            catch (Exception e)
            {
                _dialogService.ShowWarning(e.Message);
                return(false);
            }
            finally
            {
                IsLoading = false;
            }
        }
Exemple #2
0
        /// <summary>
        /// sends a registration request to the server
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="newPassword"></param>
        /// <param name="newPasswordRe"></param>
        /// <returns></returns>
        public async Task <bool> RegisterUser(string userName, string newPassword, string newPasswordRe)
        {
            try
            {
                IsLoading = true;
                if (newPassword != newPasswordRe)
                {
                    throw new Exception("A két jelszó értéke nem egyezik meg!");
                }

                var registerAccountRequest = new RegisterAccountRequest
                {
                    EmployeeId = Parameter,
                    Password   = newPassword,
                    Username   = userName
                };

                await _accountApiService.RegisterAccount(registerAccountRequest);

                return(true);
            }
            catch (Exception e)
            {
                _dialogService.ShowWarning(e.Message);
                return(false);
            }
            finally
            {
                IsLoading = false;
            }
        }
 /// <summary>
 /// Creates an account for the selected employee
 /// </summary>
 private void OnCreateAccountCommand()
 {
     try
     {
         var result = _dialogService.ShowDialog <NewEmployeeRegisterWindow, NewEmployeeRegisterWindowViewModel, int, object>(Employee.Value.Id);
         if (result.Accepted)
         {
             _dialogService.ShowAlert($"{Employee.Value.Name} dolgozó felhasználója sikeresen létrehozva!");
             _navigationService.GoBack();
         }
     }
     catch (Exception e)
     {
         _loggingService.LogInformation("Error during creation of new account!", e);
         _dialogService.ShowWarning(e.Message);
     }
 }
Exemple #4
0
 /// <summary>
 /// sends loginrequest
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public async Task Login(string username, string password)
 {
     try
     {
         IsLoading       = true;
         ReturnParameter = await _accountApiService.Login(username, password);
     }catch (Exception e)
     {
         _dialogService.ShowWarning(e.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }