private async void UserSignUp(object parameter) { PasswordBox passwordBox = parameter as PasswordBox; MemberServiceProvider memberService = new MemberServiceProvider(); SignupModel signup = new SignupModel(); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); signup.Username = LoginModel.UserUsername; signup.Password = LoginModel.UserPassword; try { var signupDataModel = await memberService.RegisterUserAsync(signup, cancellationTokenSource.Token); if (signupDataModel != null) { GenericMessageView view = new GenericMessageView(); Mediator.Instance.NotifyViewModel(MediatorMessages.GenericMessageViewModel, MediatorMessages.GenericMessageView, view); Mediator.Instance.NotifyViewModel(MediatorMessages.GenericMessageViewModel, MediatorMessages.GenericMessage, "Successfuly created your account."); view.Owner = App.Current.MainWindow; view.ShowDialog(); } } catch (Exception ex) { ShowGenericMessage(ex.Message); } //passwordBox?.Clear(); //loginModel.UserUsername = string.Empty; }
private async void UserLogin() { var isEmpty = ValidateFields(LoginModel.UserUsername, LoginModel.UserPassword); if (!isEmpty) { return; } MemberServiceProvider memberService = new MemberServiceProvider(); UserAccountModel userAccountModel = new UserAccountModel(); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); userAccountModel.Username = LoginModel.UserUsername; userAccountModel.Password = LoginModel.UserPassword; try { var result = await memberService.AuthenticateUserAsync(userAccountModel, cancellationTokenSource.Token); if (result != null) { MainDashboard mainDashboard = new MainDashboard(); App.Current.MainWindow.Close(); mainDashboard.Owner = App.Current.MainWindow; mainDashboard.ShowDialog(); ClearFields(); } } catch (Exception ex) { ShowGenericMessage(ex.Message); } }