Add DashboardWindow, controlls to close the login than open the dashboard

This commit is contained in:
Rene Schwarz
2021-04-04 21:22:13 +02:00
parent 5a1681498a
commit 73f864ea20
49 changed files with 729 additions and 24 deletions

View File

@@ -3,6 +3,6 @@ using System.Collections.Generic;
using System.Text;
namespace Server_Dashboard {
class MainViewModel : BaseViewModel {
class DashboardViewModel : BaseViewModel {
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Server_Dashboard {
interface IWindowHelper {
Action Close { get; set; }
}
}

View File

@@ -1,11 +1,12 @@
using System;
using Server_Dashboard.Views;
using System;
using System.Collections.Generic;
using System.Security;
using System.Text;
using System.Windows.Input;
namespace Server_Dashboard {
class LoginViewModel : BaseViewModel {
class LoginViewModel : BaseViewModel, IWindowHelper {
private string username;
@@ -28,7 +29,7 @@ namespace Server_Dashboard {
OnPropertyChanged(nameof(errorText));
}
}
public Action Close { get ; set; }
public LoginViewModel() {
LoginCommand = new RelayCommand(Login);
@@ -39,7 +40,10 @@ namespace Server_Dashboard {
private void Login(object parameter) {
if (!String.IsNullOrWhiteSpace(Username) && !String.IsNullOrWhiteSpace((parameter as IHavePassword).SecurePassword.Unsecure())) {
if (DatabaseHandler.CheckLogin(Username, (parameter as IHavePassword).SecurePassword.Unsecure())) {
Console.WriteLine();
DashboardWindow window = new DashboardWindow();
window.DataContext = new DashboardViewModel();
window.Show();
Close?.Invoke();
} else {
ErrorText = "Username or password is wrong.";
return;