From 8abc9fc2f480911d7f311785f627b6fd4cc168a9 Mon Sep 17 00:00:00 2001 From: ViperioN1339 Date: Thu, 24 Apr 2025 10:51:14 +0200 Subject: [PATCH] =?UTF-8?q?Zeiterfassung=20+=20=C3=84nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChronoFlow.Controller/LoginController.cs | 29 ++++++++++++++ ChronoFlow.Model/User.cs | 14 +++++++ ChronoFlow.View/App.axaml | 2 +- ChronoFlow.View/App.axaml.cs | 6 ++- ChronoFlow.View/ChronoFlow.View.csproj | 10 +++++ ChronoFlow.View/LoginWindow.axaml | 18 +++++++++ ChronoFlow.View/LoginWindow.axaml.cs | 46 +++++++++++++++++++++++ ChronoFlow.View/MainWindow.axaml | 20 +++++++++- ChronoFlow.View/MainWindow.axaml.cs | 39 ++++++++++++++++++- ChronoFlow.View/ViewManager.cs | 48 ++++++++++++++++++++++++ 10 files changed, 226 insertions(+), 6 deletions(-) create mode 100644 ChronoFlow.Controller/LoginController.cs create mode 100644 ChronoFlow.Model/User.cs create mode 100644 ChronoFlow.View/LoginWindow.axaml create mode 100644 ChronoFlow.View/LoginWindow.axaml.cs create mode 100644 ChronoFlow.View/ViewManager.cs diff --git a/ChronoFlow.Controller/LoginController.cs b/ChronoFlow.Controller/LoginController.cs new file mode 100644 index 0000000..e10bdb9 --- /dev/null +++ b/ChronoFlow.Controller/LoginController.cs @@ -0,0 +1,29 @@ +// Datei: Controller/LoginController.cs +using ChronoFlow.Model; +using System.Collections.Generic; +using System.Linq; + +namespace ChronoFlow.Controller; + +/// +/// Verwaltet die Authentifizierung von Benutzern. +/// + +public class LoginController +{ + //Beispielhafte Benutzerliste (später DB) + private List _users = new() + { + new User { Username = "admin", Password = "admin123", Role = "Admin" }, + new User { Username = "max", Password = "max123", Role = "Mitarbeiter" } + }; + + /// + /// Prüft, ob ein Benutzer mit den eingegebenen Daten existiert. + /// + + public User? Authenticate(string username, string password) + { + return _users.FirstOrDefault(u => u.Username == username && u.Password == password); + } +} diff --git a/ChronoFlow.Model/User.cs b/ChronoFlow.Model/User.cs new file mode 100644 index 0000000..27c19ca --- /dev/null +++ b/ChronoFlow.Model/User.cs @@ -0,0 +1,14 @@ +namespace ChronoFlow.Model +{ + + /// + /// Repräsentiert einen Benutzer mit Benutzernamen, Passwort und Rolle. + /// + + public class User + { + public string Username { get; set; } + public string Password { get; set; } //vorerst im Klartext, wird später geändert + public string Role { get; set; } //"Admin" oder "Mitarbeiter" + } +} \ No newline at end of file diff --git a/ChronoFlow.View/App.axaml b/ChronoFlow.View/App.axaml index c69542f..dafeae2 100644 --- a/ChronoFlow.View/App.axaml +++ b/ChronoFlow.View/App.axaml @@ -1,6 +1,6 @@ diff --git a/ChronoFlow.View/App.axaml.cs b/ChronoFlow.View/App.axaml.cs index 728091e..e27c051 100644 --- a/ChronoFlow.View/App.axaml.cs +++ b/ChronoFlow.View/App.axaml.cs @@ -1,8 +1,9 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using ChronoFlow.View; -namespace ChronoFlow.View; +namespace ChronoFlow; public partial class App : Application { @@ -15,7 +16,8 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow(); + // Starte das Programm mit dem Login-Fenster + desktop.MainWindow = new LoginWindow(); } base.OnFrameworkInitializationCompleted(); diff --git a/ChronoFlow.View/ChronoFlow.View.csproj b/ChronoFlow.View/ChronoFlow.View.csproj index f058610..1797e5c 100644 --- a/ChronoFlow.View/ChronoFlow.View.csproj +++ b/ChronoFlow.View/ChronoFlow.View.csproj @@ -24,4 +24,14 @@ + + + + + + + + ZeiterfassungView.axaml + + diff --git a/ChronoFlow.View/LoginWindow.axaml b/ChronoFlow.View/LoginWindow.axaml new file mode 100644 index 0000000..15c7f6c --- /dev/null +++ b/ChronoFlow.View/LoginWindow.axaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + +