GetAll()
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override Customer GetSingle(P pkValue)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public override void Update(Customer entity)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+}
diff --git a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
index 6da4e24..3fbedad 100755
--- a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
+++ b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs
@@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using MySql.Data.MySqlClient;
+using System.Linq.Expressions;
using LoggingClient.Model;
namespace LoggingClient.Repository
diff --git a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs
new file mode 100755
index 0000000..3c4c93d
--- /dev/null
+++ b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs
@@ -0,0 +1,179 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using DuplicateCheckerLib;
+using System.Windows.Input;
+using LoggingClient.Repository;
+using LoggingClient.Model;
+using System.Windows;
+using LoggingClient.ViewModel.Commands;
+
+namespace LoggingClient.ViewModel
+{
+ public class CustomerViewModel : INotifyPropertyChanged
+ {
+ private string _txtConnectionString;
+ private readonly DuplicateChecker _dupChecker;
+
+ private ICommand _btnAddDataClick;
+ private ICommand _btnFindDuplicatesClick;
+ private ICommand _btnUpdateDataClick;
+ private ICommand _btnLoadDataClick;
+ private ICommand _btnDeleteDataClick;
+
+ public List Customers
+ {
+ get => _customers;
+ set
+ {
+ _customers = value;
+ OnPropertyChanged("Customers");
+ }
+ }
+ private List _customers;
+ public Customer NewCustomerEntry { get; set; }
+
+ public CustomerViewModel()
+ {
+ TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
+
+ Customers = new List();
+ NewCustomerEntry = new Customer();
+ _dupChecker = new DuplicateChecker();
+ }
+ public Customer MySelectedItem { get; set; }
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public string TxtConnectionString
+ {
+ get => _txtConnectionString;
+ set
+ {
+ _txtConnectionString = value;
+ OnPropertyChanged(nameof(TxtConnectionString));
+ }
+ }
+ public ICommand BtnAddDataClick
+ {
+ get
+ {
+ return _btnAddDataClick ?? (_btnAddDataClick = new RelayCommand(
+ x =>
+ {
+ AddData();
+ }));
+ }
+ }
+ public ICommand BtnUpdateDataClick
+ {
+ get
+ {
+ return _btnUpdateDataClick ?? (_btnUpdateDataClick = new RelayCommand(
+ x =>
+ {
+ UpdateData();
+ }));
+ }
+ }
+ public ICommand BtnLoadDataClick
+ {
+ get
+ {
+ return _btnLoadDataClick ?? (_btnLoadDataClick = new RelayCommand(
+ x =>
+ {
+ LoadData();
+ }));
+ }
+ }
+ public ICommand BtnFindDuplicatesClick
+ {
+ get
+ {
+ return _btnFindDuplicatesClick ?? (_btnFindDuplicatesClick = new RelayCommand(
+ x =>
+ {
+ BtnFindDuplicates_Click();
+ }));
+ }
+ }
+ public ICommand BtnDeleteDataClick
+ {
+ get
+ {
+ return _btnDeleteDataClick ?? (_btnDeleteDataClick = new RelayCommand(
+ x =>
+ {
+ DeleteData();
+ }));
+ }
+ }
+ public List BtnFindDuplicates_Click()
+ {
+ var customerModelRepository = new CustomerRepository(TxtConnectionString);
+ this.Customers = customerModelRepository.GetAll().ToList();
+ var dupList = _dupChecker.FindDuplicates(Customers);
+ Customers = new List(dupList.Cast());
+
+ return Customers;
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var customerModelRepository = new CustomerRepository(TxtConnectionString);
+ this.Customers = customerModelRepository.GetAll().ToList();
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree"));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error occurred: " + ex.Message);
+ }
+ }
+ private void AddData()
+ {
+ try
+ {
+ var customerModelRepository = new CustomerRepository(TxtConnectionString);
+ customerModelRepository.Add(this.NewCustomerEntry);
+ this.Customers = customerModelRepository.GetAll().ToList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error occurred: " + ex.Message);
+ }
+ }
+ private void DeleteData()
+ {
+ try
+ {
+ var customerModelRepository = new CustomerRepository(TxtConnectionString);
+ customerModelRepository.Delete(this.NewCustomerEntry);
+ this.Customers = customerModelRepository.GetAll().ToList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error occurred: " + ex.Message);
+ }
+ }
+ private void UpdateData()
+ {
+ try
+ {
+ var customerModelRepository = new CustomerRepository(TxtConnectionString);
+ customerModelRepository.Update(this.NewCustomerEntry);
+ this.Customers = customerModelRepository.GetAll().ToList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error occurred: " + ex.Message);
+ }
+ }
+
+ private void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
diff --git a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs
index 36cdaa7..d2e4855 100755
--- a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs
+++ b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs
@@ -9,6 +9,7 @@ namespace WpfControlNugget.ViewModel
{
public ICommand LogsCommand { get; set; }
public ICommand LocationsCommand { get; set; }
+ public ICommand CustomersCommand { get; set; }
private object _selectedViewModel;
public object SelectedViewModel
@@ -21,6 +22,7 @@ namespace WpfControlNugget.ViewModel
{
LogsCommand = new BaseCommand(OpenLogs);
LocationsCommand = new BaseCommand(OpenLocations);
+ CustomersCommand = new BaseCommand(OpenCustomers);
}
private void OpenLogs(object obj)
@@ -32,6 +34,10 @@ namespace WpfControlNugget.ViewModel
{
SelectedViewModel = new LocationViewModel();
}
+ private void OpenCustomers(object obj)
+ {
+ SelectedViewModel = new CustomerViewModel();
+ }
public event PropertyChangedEventHandler PropertyChanged;
diff --git a/LoggingClient/LoggingClient/Views/CustomerView.xaml b/LoggingClient/LoggingClient/Views/CustomerView.xaml
new file mode 100755
index 0000000..2d71fc1
--- /dev/null
+++ b/LoggingClient/LoggingClient/Views/CustomerView.xaml
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LoggingClient/LoggingClient/Views/CustomerView.xaml.cs b/LoggingClient/LoggingClient/Views/CustomerView.xaml.cs
new file mode 100755
index 0000000..905a145
--- /dev/null
+++ b/LoggingClient/LoggingClient/Views/CustomerView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace LoggingClient.Views
+{
+ ///
+ /// Interaction logic for CustomerView.xaml
+ ///
+ public partial class CustomerView : UserControl
+ {
+ public CustomerView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/LoggingClient/LoggingClient/Views/LocationView.xaml b/LoggingClient/LoggingClient/Views/LocationView.xaml
index 8004178..d216f7c 100755
--- a/LoggingClient/LoggingClient/Views/LocationView.xaml
+++ b/LoggingClient/LoggingClient/Views/LocationView.xaml
@@ -53,10 +53,10 @@
-->
-
-
+