diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 8881a48..e6d84d7 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -90,6 +90,7 @@ Inventar.tt + True True diff --git a/LoggingClient/LoggingClient/Model/Customer.cs b/LoggingClient/LoggingClient/Model/Customer.cs index 8f2f5cf..2118d2a 100644 --- a/LoggingClient/LoggingClient/Model/Customer.cs +++ b/LoggingClient/LoggingClient/Model/Customer.cs @@ -9,28 +9,16 @@ namespace LoggingClient.Model { - 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/CustomerLinq.cs b/LoggingClient/LoggingClient/Model/CustomerLinq.cs new file mode 100644 index 0000000..5fa4088 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/CustomerLinq.cs @@ -0,0 +1,42 @@ +using System.Data.Linq.Mapping; + +namespace LoggingClient.Model +{ + [Table(Name = "inventarisierungsloesung.Customer")] + public class CustomerLinq + { + [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 CustomerLinq() { } + + public CustomerLinq(long Id, string FirstName, string LastName, string CustomerNumber, long Customer_fk, string PhoneNumber, string EMail, string URL, string Password) + { + this.customer_id = Id; + this.firstname = FirstName; + this.lastname = LastName; + this.customernumber = CustomerNumber; + this.kundenkonto_fk = Customer_fk; + this.tel = PhoneNumber; + this.email = EMail; + this.url = URL; + this.password = Password; + } + } +} diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs index 83dc3fd..a78b8f6 100644 --- a/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs @@ -1,6 +1,7 @@ using LoggingClient.Model; using System; using System.Collections.Generic; +using System.Data.Entity.Migrations; using System.Linq; namespace LoggingClient.Repository @@ -75,7 +76,11 @@ namespace LoggingClient.Repository public void Update(Customer entity) { - throw new NotImplementedException(); + using (var context = new inventarisierungsloesungEntities()) + { + context.Customer.AddOrUpdate(entity); + context.SaveChanges(); + } } } } diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs index f2b5cad..f539c5c 100644 --- a/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs @@ -64,12 +64,12 @@ namespace LoggingClient.Repository throw new NotImplementedException(); } - public IQueryable GetAll() + public List GetAll() { using (var context = new inventarisierungsloesungEntities()) { - return context.Customer.AsQueryable(); - } + return context.Customer.ToList(); + } } public Customer GetSingle

(P pkValue) @@ -79,7 +79,22 @@ namespace LoggingClient.Repository public void Update(Customer entity) { - throw new NotImplementedException(); + using (var context = new inventarisierungsloesungEntities()) + { + var x = (from c in context.Customer + where (c.customer_id == entity.customer_id) + select c).SingleOrDefault(); + + x.firstname = entity.firstname; + x.lastname = entity.lastname; + x.customernumber = entity.customernumber; + x.kundenkonto_fk = entity.kundenkonto_fk; + x.tel = entity.tel; + x.email = entity.email; + x.url = entity.url; + x.password = entity.password; + context.SaveChanges(); + } } List IRepositoryBase.GetAll() diff --git a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs index 2f85bb2..e5d2463 100644 --- a/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/CustomerViewModel.cs @@ -282,7 +282,9 @@ namespace LoggingClient.ViewModel { try { - //DOTO + var customerModelRepositoryEF = new CustomerRepositoryEF(); + customerModelRepositoryEF.Update(MySelectedItem); + Customers = customerModelRepositoryEF.GetAll(); } catch (Exception ex) { @@ -293,7 +295,9 @@ namespace LoggingClient.ViewModel { try { - //DOTO + var customerModelRepositoryLinq = new CustomerRepositoryLinq(); + customerModelRepositoryLinq.Update(MySelectedItem); + Customers = customerModelRepositoryLinq.GetAll().ToList(); } catch (Exception ex) {