From b67302361b60bd32417b3e4c5896b33bf44bbe4e Mon Sep 17 00:00:00 2001 From: Francesco Date: Sat, 8 Aug 2020 15:27:39 +0200 Subject: [PATCH 1/8] Prepared ViewModel for Linq, Add CustomerRepositoryLinq --- LoggingClient/LoggingClient/App.config | 1 + .../LoggingClient/LoggingClient.csproj | 99 +++++++++++++++++++ .../Repository/CustomerRepository.cs | 1 - .../Repository/CustomerRepositoryLinq.cs | 61 ++++++++++++ .../ViewModel/CustomerViewModel.cs | 72 ++++++++++++-- 5 files changed, 225 insertions(+), 9 deletions(-) create mode 100755 LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs diff --git a/LoggingClient/LoggingClient/App.config b/LoggingClient/LoggingClient/App.config index 2950779..0ad6cd9 100644 --- a/LoggingClient/LoggingClient/App.config +++ b/LoggingClient/LoggingClient/App.config @@ -16,6 +16,7 @@ + diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 25b0884..3417f4a 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -86,6 +86,87 @@ MSBuild:Compile Designer + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + True + True + DataAccessLayer.Context.tt + + + True + True + DataAccessLayer.tt + + + True + True + DataAccessLayer.edmx + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + + + DataAccessLayer.tt + Inventar.tt @@ -110,6 +191,7 @@ + @@ -180,6 +262,13 @@ EntityModelCodeGenerator Inventar.Designer.cs + + EntityModelCodeGenerator + DataAccessLayer.Designer.cs + + + DataAccessLayer.edmx + Inventar.edmx @@ -195,6 +284,16 @@ + + TextTemplatingFileGenerator + DataAccessLayer.edmx + DataAccessLayer.Context.cs + + + TextTemplatingFileGenerator + DataAccessLayer.edmx + DataAccessLayer.cs + TextTemplatingFileGenerator Inventar.Context.cs diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepository.cs b/LoggingClient/LoggingClient/Repository/CustomerRepository.cs index 83ae162..c2c6a78 100755 --- a/LoggingClient/LoggingClient/Repository/CustomerRepository.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepository.cs @@ -22,7 +22,6 @@ namespace LoggingClient.Repository public override string PrimaryKeyFromTable => "customer_id"; public List Customers { get; set; } - public Customer _Customers { get; set; } public override void Add(Customer entity) { diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs new file mode 100755 index 0000000..d7820da --- /dev/null +++ b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LoggingClient.Repository +{ + public class CustomerRepositoryLinq : RepositoryBase + { + public List Customers { get; set; } + public CustomerRepositoryLinq(string connectionString) : base(connectionString) + { + Customers = new List(); + } + + public override string TableName => throw new NotImplementedException(); + + public override string ColumnsForSelect => throw new NotImplementedException(); + + public override string ColumnsForAdd => throw new NotImplementedException(); + + public override string PrimaryKeyFromTable => throw new NotImplementedException(); + + public override void Add(Customer entity) + { + throw new NotImplementedException(); + } + + public override void CallStoredProcedure(Customer entity) + { + 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) + { + throw new NotImplementedException(); + } + } +} diff --git a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs index 106408d..ab6255e 100755 --- a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs @@ -169,7 +169,15 @@ namespace LoggingClient.ViewModel } if (_LinqIsChecked) { - //TODO + try + { + var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); + Customers = customerModelRepositoryLinq.GetAll(); + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } } if (!_EfIsChecked && !_LinqIsChecked) { @@ -201,7 +209,16 @@ namespace LoggingClient.ViewModel } if (_LinqIsChecked) { - // TODO + try + { + var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); + customerModelRepositoryLinq.Add(NewCustomerEntry); + Customers = customerModelRepositoryLinq.GetAll(); + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } } if (!_EfIsChecked && !_LinqIsChecked) { @@ -232,6 +249,19 @@ namespace LoggingClient.ViewModel MessageBox.Show("Error occurred: " + ex.Message); } } + if (_LinqIsChecked) + { + try + { + var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); + customerModelRepositoryLinq.Delete(MySelectedItem); + Customers = customerModelRepositoryLinq.GetAll(); + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } + } if (!_EfIsChecked && !_LinqIsChecked) { try @@ -248,15 +278,41 @@ namespace LoggingClient.ViewModel } private void UpdateData() { - try + if (_EfIsChecked) { - var customerModelRepository = new CustomerRepository(TxtConnectionString); - customerModelRepository.Update(this.NewCustomerEntry); - this.Customers = customerModelRepository.GetAll().ToList(); + try + { + //DOTO + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } } - catch (Exception ex) + if (_LinqIsChecked) { - MessageBox.Show("Error occurred: " + ex.Message); + try + { + //DOTO + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } + } + if (!_EfIsChecked && !_LinqIsChecked) + { + + try + { + var customerModelRepository = new CustomerRepository(TxtConnectionString); + customerModelRepository.Update(this.NewCustomerEntry); + this.Customers = customerModelRepository.GetAll().ToList(); + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + } } } From 7c24cf009bee21361aee276cf927116eeba75745 Mon Sep 17 00:00:00 2001 From: francesco Date: Sun, 9 Aug 2020 16:17:41 +0200 Subject: [PATCH 2/8] Minor WPF Changes and Prepare for CTE Testat --- .../LoggingClient/LoggingClient.csproj | 105 ++---------------- LoggingClient/LoggingClient/MainWindow.xaml | 0 .../LoggingClient/MainWindow.xaml.cs | 0 LoggingClient/LoggingClient/Model/Customer.cs | 13 ++- .../LoggingClient/Model/Inventar.Context.cs | 0 .../LoggingClient/Model/Inventar.Context.tt | 0 .../LoggingClient/Model/Inventar.Designer.cs | 0 LoggingClient/LoggingClient/Model/Inventar.cs | 0 .../LoggingClient/Model/Inventar.edmx | 0 .../LoggingClient/Model/Inventar.edmx.diagram | 0 LoggingClient/LoggingClient/Model/Inventar.tt | 0 LoggingClient/LoggingClient/Model/Location.cs | 0 LoggingClient/LoggingClient/Model/Logging.cs | 0 LoggingClient/LoggingClient/Model/Model.cs | 0 LoggingClient/LoggingClient/Model/Node.cs | 0 .../Model/SeverityComboBoxItem.cs | 0 .../Repository/CustomerRepository.cs | 0 .../Repository/CustomerRepositoryEF.cs | 0 .../Repository/CustomerRepositoryLinq.cs | 73 ++++++------ .../Repository/IRepositoryBase.cs | 0 .../Repository/LocationRepository.cs | 0 .../Repository/LoggingRepository.cs | 0 .../Repository/RepositoryBase.cs | 0 .../Validators/IntRangeValidationRule.cs | 0 .../Validators/StringRangeValidationRule.cs | 0 .../ViewModel/Commands/BaseCommand.cs | 0 .../ViewModel/Commands/RelayCommand.cs | 0 .../ViewModel/CustomerViewModel.cs | 28 ++--- .../ViewModel/LocationTreeBuilder.cs | 0 .../ViewModel/LocationViewModel.cs | 10 +- .../LoggingClient/ViewModel/LogViewModel.cs | 0 .../ViewModel/NavigationViewModel.cs | 0 .../LoggingClient/Views/CustomerView.xaml | 18 +-- .../LoggingClient/Views/CustomerView.xaml.cs | 0 .../LoggingClient/Views/LocationView.xaml | 45 ++++---- .../LoggingClient/Views/LocationView.xaml.cs | 0 .../LoggingClient/Views/LogView.xaml | 0 .../LoggingClient/Views/LogView.xaml.cs | 0 LoggingClient/LoggingClient/packages.config | 0 39 files changed, 108 insertions(+), 184 deletions(-) mode change 100755 => 100644 LoggingClient/LoggingClient/MainWindow.xaml mode change 100755 => 100644 LoggingClient/LoggingClient/MainWindow.xaml.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Customer.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.Context.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.Context.tt mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.Designer.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.edmx mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.edmx.diagram mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Inventar.tt mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Location.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Logging.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Model.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/Node.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Model/SeverityComboBoxItem.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/CustomerRepository.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/IRepositoryBase.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/LocationRepository.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/LoggingRepository.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Repository/RepositoryBase.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/LogViewModel.cs mode change 100755 => 100644 LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Views/CustomerView.xaml mode change 100755 => 100644 LoggingClient/LoggingClient/Views/CustomerView.xaml.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Views/LocationView.xaml mode change 100755 => 100644 LoggingClient/LoggingClient/Views/LocationView.xaml.cs mode change 100755 => 100644 LoggingClient/LoggingClient/Views/LogView.xaml mode change 100755 => 100644 LoggingClient/LoggingClient/Views/LogView.xaml.cs mode change 100755 => 100644 LoggingClient/LoggingClient/packages.config diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 3417f4a..1bd4952 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -62,6 +62,7 @@ + @@ -86,87 +87,6 @@ MSBuild:Compile Designer - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - True - True - DataAccessLayer.Context.tt - - - True - True - DataAccessLayer.tt - - - True - True - DataAccessLayer.edmx - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - - - DataAccessLayer.tt - Inventar.tt @@ -262,13 +182,6 @@ EntityModelCodeGenerator Inventar.Designer.cs - - EntityModelCodeGenerator - DataAccessLayer.Designer.cs - - - DataAccessLayer.edmx - Inventar.edmx @@ -284,16 +197,6 @@ - - TextTemplatingFileGenerator - DataAccessLayer.edmx - DataAccessLayer.Context.cs - - - TextTemplatingFileGenerator - DataAccessLayer.edmx - DataAccessLayer.cs - TextTemplatingFileGenerator Inventar.Context.cs @@ -308,5 +211,11 @@ + + + + + + \ No newline at end of file diff --git a/LoggingClient/LoggingClient/MainWindow.xaml b/LoggingClient/LoggingClient/MainWindow.xaml old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/MainWindow.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Customer.cs b/LoggingClient/LoggingClient/Model/Customer.cs old mode 100755 new mode 100644 index 3c547e4..8f2f5cf --- a/LoggingClient/LoggingClient/Model/Customer.cs +++ b/LoggingClient/LoggingClient/Model/Customer.cs @@ -9,19 +9,28 @@ namespace LoggingClient.Model { - using System; - using System.Collections.Generic; + using System.Data.Linq.Mapping; + [Table(Name = "inventarisierungsloesung.Customer")] public partial class Customer { + [Column(IsPrimaryKey = true, Name = "CustomerId")] public long customer_id { get; set; } + [Column(Name ="FirstName")] public string firstname { get; set; } + [Column(Name = "LastName")] public string lastname { get; set; } + [Column(Name = "CustomerNumber")] public string customernumber { get; set; } + [Column(Name = "KundenKontoFK")] public long kundenkonto_fk { get; set; } + [Column(Name = "PhoneNumber")] public string tel { get; set; } + [Column(Name = "EMail")] public string email { get; set; } + [Column(Name = "URL")] public string url { get; set; } + [Column(Name = "Password")] public string password { get; set; } public Customer() { } diff --git a/LoggingClient/LoggingClient/Model/Inventar.Context.cs b/LoggingClient/LoggingClient/Model/Inventar.Context.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.Context.tt b/LoggingClient/LoggingClient/Model/Inventar.Context.tt old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.Designer.cs b/LoggingClient/LoggingClient/Model/Inventar.Designer.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.cs b/LoggingClient/LoggingClient/Model/Inventar.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.edmx b/LoggingClient/LoggingClient/Model/Inventar.edmx old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram b/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Inventar.tt b/LoggingClient/LoggingClient/Model/Inventar.tt old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Location.cs b/LoggingClient/LoggingClient/Model/Location.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Logging.cs b/LoggingClient/LoggingClient/Model/Logging.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Model.cs b/LoggingClient/LoggingClient/Model/Model.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/Node.cs b/LoggingClient/LoggingClient/Model/Node.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Model/SeverityComboBoxItem.cs b/LoggingClient/LoggingClient/Model/SeverityComboBoxItem.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepository.cs b/LoggingClient/LoggingClient/Repository/CustomerRepository.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs old mode 100755 new mode 100644 index d7820da..e24f2e8 --- a/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs @@ -1,59 +1,66 @@ -using System; +using LoggingClient.Model; +using System; using System.Collections.Generic; using System.Data; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace LoggingClient.Repository { - public class CustomerRepositoryLinq : RepositoryBase + public class CustomerRepositoryLinq { - public List Customers { get; set; } - public CustomerRepositoryLinq(string connectionString) : base(connectionString) + inventarisierungsloesungEntities _dataContext; + public CustomerRepositoryLinq() { - Customers = new List(); + _dataContext = new inventarisierungsloesungEntities(); } - public override string TableName => throw new NotImplementedException(); + public void Add(Customer entity) + { + var customer = new Customer() + { + firstname = entity.firstname, + lastname = entity.lastname, + customernumber = entity.customernumber, + kundenkonto_fk = entity.kundenkonto_fk, + tel = entity.tel, + email = entity.email, + url = entity.url, + password = entity.password + }; + _dataContext.Customer.Add(customer); + _dataContext.SaveChanges(); + } - public override string ColumnsForSelect => throw new NotImplementedException(); - - public override string ColumnsForAdd => throw new NotImplementedException(); - - public override string PrimaryKeyFromTable => throw new NotImplementedException(); - - public override void Add(Customer entity) + public void CallStoredProcedure(Customer entity) { throw new NotImplementedException(); } - public override void CallStoredProcedure(Customer entity) + public void Delete(Customer entity) + { + var x = (from c in _dataContext.Customer + where (c.customer_id == entity.customer_id) + select c).SingleOrDefault(); + _dataContext.Customer.Remove(x); + _dataContext.SaveChanges(); + } + + public List GetAll(string whereCondition, Dictionary parameterValues) { throw new NotImplementedException(); } - public override void Delete(Customer entity) + public IQueryable GetAll() + { + return _dataContext.Customer.AsQueryable(); + } + + public Customer GetSingle

(P pkValue) { 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/Repository/IRepositoryBase.cs b/LoggingClient/LoggingClient/Repository/IRepositoryBase.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Repository/RepositoryBase.cs b/LoggingClient/LoggingClient/Repository/RepositoryBase.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/IntRangeValidationRule.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs b/LoggingClient/LoggingClient/Validators/StringRangeValidationRule.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/RelayCommand.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs old mode 100755 new mode 100644 index ab6255e..faf4ba0 --- a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs @@ -33,7 +33,7 @@ namespace LoggingClient.ViewModel } } - public Customer NewCustomerEntry { get; set; } + public Customer SelectedItem { get; set; } private long _customerId; public long customer_id @@ -67,14 +67,14 @@ namespace LoggingClient.ViewModel OnPropertyChanged(nameof(LinqIsChecked)); } } - public Customer SelectedItem { 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; } @@ -171,8 +171,8 @@ namespace LoggingClient.ViewModel { try { - var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); - Customers = customerModelRepositoryLinq.GetAll(); + var customerModelRepositoryLinq = new CustomerRepositoryLinq(); + Customers = customerModelRepositoryLinq.GetAll().ToList(); } catch (Exception ex) { @@ -199,7 +199,7 @@ namespace LoggingClient.ViewModel try { var customerModelRepositoryEF = new CustomerRepositoryEF(); - customerModelRepositoryEF.Add(NewCustomerEntry); + customerModelRepositoryEF.Add(SelectedItem); Customers = customerModelRepositoryEF.GetAll(); } catch (Exception ex) @@ -211,9 +211,9 @@ namespace LoggingClient.ViewModel { try { - var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); - customerModelRepositoryLinq.Add(NewCustomerEntry); - Customers = customerModelRepositoryLinq.GetAll(); + //var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); + //customerModelRepositoryLinq.Add(NewCustomerEntry); + //Customers = customerModelRepositoryLinq.GetAll(); } catch (Exception ex) { @@ -225,7 +225,7 @@ namespace LoggingClient.ViewModel try { var customerModelRepository = new CustomerRepository(TxtConnectionString); - customerModelRepository.Add(this.NewCustomerEntry); + customerModelRepository.Add(this.SelectedItem); this.Customers = customerModelRepository.GetAll().ToList(); } catch (Exception ex) @@ -253,9 +253,9 @@ namespace LoggingClient.ViewModel { try { - var customerModelRepositoryLinq = new CustomerRepositoryLinq(TxtConnectionString); + var customerModelRepositoryLinq = new CustomerRepositoryLinq(); customerModelRepositoryLinq.Delete(MySelectedItem); - Customers = customerModelRepositoryLinq.GetAll(); + Customers = customerModelRepositoryLinq.GetAll().ToList(); } catch (Exception ex) { @@ -267,7 +267,7 @@ namespace LoggingClient.ViewModel try { var customerModelRepository = new CustomerRepository(TxtConnectionString); - customerModelRepository.Delete(this.NewCustomerEntry); + customerModelRepository.Delete(this.SelectedItem); this.Customers = customerModelRepository.GetAll().ToList(); } catch (Exception ex) @@ -306,7 +306,7 @@ namespace LoggingClient.ViewModel try { var customerModelRepository = new CustomerRepository(TxtConnectionString); - customerModelRepository.Update(this.NewCustomerEntry); + customerModelRepository.Update(this.SelectedItem); this.Customers = customerModelRepository.GetAll().ToList(); } catch (Exception ex) diff --git a/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs b/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs old mode 100755 new mode 100644 index d542656..870f35a --- a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs @@ -29,15 +29,13 @@ namespace LoggingClient.ViewModel } } private List _locations; - public Location NewLocationModelEntry { get; set; } + public Location SelectedItem { get; set; } public List> LocationTree { get; set; } public LocationViewModel() { TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;"; Locations = new List(); - NewLocationModelEntry = new Location(); - } public Location MySelectedItem { get; set; } public event PropertyChangedEventHandler PropertyChanged; @@ -126,7 +124,7 @@ namespace LoggingClient.ViewModel try { var locationModelRepository = new LocationRepository(TxtConnectionString); - locationModelRepository.Add(this.NewLocationModelEntry); + locationModelRepository.Add(SelectedItem); this.Locations = locationModelRepository.GetAll(); } catch (Exception ex) @@ -139,7 +137,7 @@ namespace LoggingClient.ViewModel try { var locationModelRepository = new LocationRepository(TxtConnectionString); - locationModelRepository.Delete(this.NewLocationModelEntry); + locationModelRepository.Delete(SelectedItem); this.Locations = locationModelRepository.GetAll(); } catch (Exception ex) @@ -152,7 +150,7 @@ namespace LoggingClient.ViewModel try { var locationModelRepository = new LocationRepository(TxtConnectionString); - locationModelRepository.Update(this.NewLocationModelEntry); + locationModelRepository.Update(SelectedItem); this.Locations = locationModelRepository.GetAll(); } catch (Exception ex) diff --git a/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LogViewModel.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs old mode 100755 new mode 100644 diff --git a/LoggingClient/LoggingClient/Views/CustomerView.xaml b/LoggingClient/LoggingClient/Views/CustomerView.xaml old mode 100755 new mode 100644 index dfc9405..1fc9687 --- a/LoggingClient/LoggingClient/Views/CustomerView.xaml +++ b/LoggingClient/LoggingClient/Views/CustomerView.xaml @@ -15,7 +15,7 @@ - + @@ -35,7 +35,7 @@