GetAll()
+ {
+ using (var context = new inventarisierungsloesungEntities())
+ {
+ return context.Customer.ToList();
+ }
+ }
+
+ public Customer GetSingle(P pkValue)
{
throw new NotImplementedException();
}
- public override void Delete(Customer entity)
- {
- throw new NotImplementedException();
- }
-
- public override List GetAll(string whereCondition, Dictionary parameterValues)
- {
- throw new NotImplementedException();
- }
-
- public override List GetAll()
- {
- throw new NotImplementedException();
- }
-
- public override Customer GetSingle(P pkValue)
- {
- throw new NotImplementedException();
- }
-
- public override void Update(Customer entity)
+ public void Update(Customer entity)
{
throw new NotImplementedException();
}
diff --git a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs
index 7940abd..106408d 100755
--- a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs
+++ b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs
@@ -22,6 +22,7 @@ namespace LoggingClient.ViewModel
private ICommand _btnLoadDataClick;
private ICommand _btnDeleteDataClick;
+ private List _customers;
public List Customers
{
get => _customers;
@@ -31,12 +32,21 @@ namespace LoggingClient.ViewModel
OnPropertyChanged("Customers");
}
}
- private List _customers;
+
public Customer NewCustomerEntry { get; set; }
- private bool _EfIsChecked;
- private bool _LinqIsChecked;
+ private long _customerId;
+ public long customer_id
+ {
+ get { return _customerId; }
+ set
+ {
+ _customerId = value;
+ OnPropertyChanged(nameof(customer_id));
+ }
+ }
+ private bool _EfIsChecked;
public bool EfIsChecked
{
get { return _EfIsChecked; }
@@ -47,6 +57,7 @@ namespace LoggingClient.ViewModel
}
}
+ private bool _LinqIsChecked;
public bool LinqIsChecked
{
get { return _LinqIsChecked; }
@@ -56,6 +67,7 @@ namespace LoggingClient.ViewModel
OnPropertyChanged(nameof(LinqIsChecked));
}
}
+ public Customer SelectedItem { get; set; }
public CustomerViewModel()
{
@@ -145,13 +157,10 @@ namespace LoggingClient.ViewModel
{
if (_EfIsChecked)
{
- // TODO Implement Repository-Pattern
try
{
- using (var context = new inventarisierungsloesungEntities())
- {
- Customers = context.Customer.ToList();
- }
+ var customerModelRepositoryEF = new CustomerRepositoryEF();
+ Customers = customerModelRepositoryEF.GetAll();
}
catch (Exception ex)
{
@@ -162,12 +171,12 @@ namespace LoggingClient.ViewModel
{
//TODO
}
- if (!(_EfIsChecked && _LinqIsChecked))
+ if (!_EfIsChecked && !_LinqIsChecked)
{
try
{
var customerModelRepository = new CustomerRepository(TxtConnectionString);
- this.Customers = customerModelRepository.GetAll().ToList();
+ Customers = customerModelRepository.GetAll().ToList();
}
catch (Exception ex)
{
@@ -181,22 +190,9 @@ namespace LoggingClient.ViewModel
{
try
{
- using (var context = new inventarisierungsloesungEntities())
- {
- var Customer = new Customer()
- {
- customer_id = 6,
- firstname = "bvla",
- lastname = "asdf",
- customernumber = "asdf",
- kundenkonto_fk = 99,
- tel = "0798765432",
- email = "asdf@adsf.asdf",
- url = "www.asdf.ch",
- password = "password"
- };
-
- }
+ var customerModelRepositoryEF = new CustomerRepositoryEF();
+ customerModelRepositoryEF.Add(NewCustomerEntry);
+ Customers = customerModelRepositoryEF.GetAll();
}
catch (Exception ex)
{
@@ -207,7 +203,7 @@ namespace LoggingClient.ViewModel
{
// TODO
}
- if (!(_EfIsChecked && _LinqIsChecked))
+ if (!_EfIsChecked && !_LinqIsChecked)
{
try
{
@@ -223,15 +219,31 @@ namespace LoggingClient.ViewModel
}
private void DeleteData()
{
- try
+ if (_EfIsChecked)
{
- var customerModelRepository = new CustomerRepository(TxtConnectionString);
- customerModelRepository.Delete(this.NewCustomerEntry);
- this.Customers = customerModelRepository.GetAll().ToList();
+ try
+ {
+ var customerModelRepositoryEF = new CustomerRepositoryEF();
+ customerModelRepositoryEF.Delete(MySelectedItem);
+ Customers = customerModelRepositoryEF.GetAll();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error occurred: " + ex.Message);
+ }
}
- catch (Exception ex)
+ if (!_EfIsChecked && !_LinqIsChecked)
{
- MessageBox.Show("Error occurred: " + ex.Message);
+ 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()
diff --git a/LoggingClient/LoggingClient/Views/CustomerView.xaml b/LoggingClient/LoggingClient/Views/CustomerView.xaml
index 3078005..dfc9405 100755
--- a/LoggingClient/LoggingClient/Views/CustomerView.xaml
+++ b/LoggingClient/LoggingClient/Views/CustomerView.xaml
@@ -21,19 +21,135 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+