Add Update Functionality on Customer
This commit is contained in:
parent
c12615bc1b
commit
d23f8cf465
@ -90,6 +90,7 @@
|
||||
<Compile Include="Model\Customer.cs">
|
||||
<DependentUpon>Inventar.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\CustomerLinq.cs" />
|
||||
<Compile Include="Model\Inventar.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
@ -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() { }
|
||||
|
42
LoggingClient/LoggingClient/Model/CustomerLinq.cs
Normal file
42
LoggingClient/LoggingClient/Model/CustomerLinq.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ namespace LoggingClient.Repository
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IQueryable<Customer> GetAll()
|
||||
public List<Customer> GetAll()
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
return context.Customer.AsQueryable();
|
||||
return context.Customer.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<Customer> IRepositoryBase<Customer>.GetAll()
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user