+ {
+ ///
+ /// Liefert ein einzelnes Model-Objekt vom Typ M zurück,
+ /// welches anhand dem übergebenen PrimaryKey geladen wird.
+ ///
+ /// Type des PrimaryKey
+ /// Wert des PrimaryKey
+ /// gefundenes Model-Objekt, ansonsten null
+ M GetSingle(P pkValue);
+
+ ///
+ /// Fügt das Model-Objekt zur Datenbank hinzu (Insert)
+ ///
+ /// zu speicherndes Model-Object
+ void Add(M entity);
+
+ ///
+ /// Löscht das Model-Objekt aus der Datenbank (Delete)
+ ///
+ /// zu löschendes Model-Object
+ void Delete(M entity);
+
+ ///
+ /// Aktualisiert das Model-Objekt in der Datenbank hinzu (Update)
+ ///
+ /// zu aktualisierendes Model-Object
+ void Update(M entity);
+
+ ///
+ /// Gibt eine Liste von Model-Objekten vom Typ M zurück,
+ /// die gemäss der WhereBedingung geladen wurden. Die Werte der
+ /// Where-Bedingung können als separat übergeben werden,
+ /// damit diese für PreparedStatements verwendet werden können.
+ /// (Verhinderung von SQL-Injection)
+ ///
+ /// WhereBedingung als string
+ /// z.B. "NetPrice > @netPrice and Active = @active and Description like @desc
+ /// Parameter-Werte für die Wherebedingung
+ /// bspw: {{"netPrice", 10.5}, {"active", true}, {"desc", "Wolle%"}}
+ ///
+ List GetAll(string whereCondition, Dictionary parameterValues);
+
+ ///
+ /// Gibt eine Liste aller in der DB vorhandenen Model-Objekte vom Typ M zurück
+ ///
+ ///
+ List GetAll();
+
+ ///
+ /// Zählt in der Datenbank die Anzahl Model-Objekte vom Typ M, die der
+ /// Where-Bedingung entsprechen
+ ///
+ /// WhereBedingung als string
+ /// z.B. "NetPrice > @netPrice and Active = @active and Description like @desc
+ /// Parameter-Werte für die Wherebedingung
+ /// bspw: {{"netPrice", 10.5}, {"active", true}, {"desc", "Wolle%"}}
+ ///
+ long Count(string whereCondition, Dictionary parameterValues);
+
+ ///
+ /// Zählt alle Model-Objekte vom Typ M
+ ///
+ ///
+ long Count();
+
+ ///
+ /// Gibt den Tabellennamen zurück, auf die sich das Repository bezieht
+ ///
+ string TableName { get; }
+ }
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs
new file mode 100755
index 0000000..f13ec8e
--- /dev/null
+++ b/LoggingClient/LoggingClient/Repository/LocationRepository.cs
@@ -0,0 +1,50 @@
+using LoggingClient.Model;
+using System.Collections.Generic;
+
+namespace LoggingClient.Repository
+{
+ class LocationRepository : RepositoryBase
+ {
+ public override string TableName => throw new System.NotImplementedException();
+
+ public override void Add(Location entity)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override long Count(string whereCondition, Dictionary parameterValues)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override long Count()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override void Delete(Location entity)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override List GetAll(string whereCondition, Dictionary parameterValues)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override List GetAll()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override Location GetSingle(P pkValue)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override void Update(Location entity)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+}
diff --git a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
new file mode 100755
index 0000000..36bf3d4
--- /dev/null
+++ b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
@@ -0,0 +1,54 @@
+using LoggingClient.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LoggingClient.Repository
+{
+ class LoggingRepository : RepositoryBase
+ {
+ public override string TableName => throw new NotImplementedException();
+
+ public override void Add(Logging entity)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override long Count(string whereCondition, Dictionary parameterValues)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override long Count()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Delete(Logging entity)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override List GetAll(string whereCondition, Dictionary parameterValues)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override List GetAll()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override Logging GetSingle(P pkValue)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Update(Logging entity)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/LoggingClient/LoggingClient/Repository/RepositoryBase.cs b/LoggingClient/LoggingClient/Repository/RepositoryBase.cs
new file mode 100755
index 0000000..b2000f2
--- /dev/null
+++ b/LoggingClient/LoggingClient/Repository/RepositoryBase.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LoggingClient.Repository
+{
+ public abstract class RepositoryBase : IRepositoryBase
+ {
+ public abstract string TableName { get; }
+
+ public abstract void Add(M entity);
+ public abstract long Count(string whereCondition, Dictionary parameterValues);
+ public abstract long Count();
+ public abstract void Delete(M entity);
+ public abstract List GetAll(string whereCondition, Dictionary parameterValues);
+ public abstract List GetAll();
+ public abstract M GetSingle(P pkValue);
+ public abstract void Update(M entity);
+ }
+}
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
old mode 100644
new mode 100755
index f84825a..b128820
--- a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
+++ b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs
@@ -26,7 +26,7 @@ namespace LoggingClient.ViewModel
private ICommand _btnAdddataClick;
private ICommand _btnFindDuplicateClick;
- public ObservableCollection Logs
+ public ObservableCollection Logs
{
get => _logs;
set
@@ -35,15 +35,15 @@ namespace LoggingClient.ViewModel
OnPropertyChanged("Logs");
}
}
- private ObservableCollection _logs;
+ private ObservableCollection _logs;
public ObservableCollection SeverityComboBox { get; set; }
public LogViewModel()
{
- TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=foekicoe9i4kpos;";
+ TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
_enterSeverity = 1;
- Logs = new ObservableCollection();
+ Logs = new ObservableCollection();
SeverityComboBox = new ObservableCollection(){
new SeverityComboBoxItem(){Id=1, Severity= 1},
new SeverityComboBoxItem(){Id=2, Severity= 2},
@@ -51,7 +51,7 @@ namespace LoggingClient.ViewModel
};
_duplicateChecker = new DuplicateChecker();
}
- public LogModel MySelectedItem { get; set; }
+ public Logging MySelectedItem { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public SeverityComboBoxItem SetSeverity { get; set; }
@@ -177,7 +177,7 @@ namespace LoggingClient.ViewModel
{
location = reader.GetString("location");
}
- Logs.Add(new LogModel(
+ Logs.Add(new Logging(
reader.GetInt32("id"),
reader.GetString("pod"),
location,
@@ -247,12 +247,12 @@ namespace LoggingClient.ViewModel
MessageBox.Show("Error occurred: " + ex.Message);
}
}
- public ObservableCollection BtnFindDuplicate_Click()
+ public ObservableCollection BtnFindDuplicate_Click()
{
LoadData();
var duplicateList = _duplicateChecker.FindDuplicates(Logs);
- Logs = new ObservableCollection(duplicateList.Cast());
+ Logs = new ObservableCollection(duplicateList.Cast());
return Logs;
}