Пример #1
0
 public void Add(CustomerDTO item)
 {
     p1p.Data.Customer mdlCustomer = (p1p.Data.Customer)P1PObjectMapper.Convert(item, typeof(p1p.Data.Customer));
     mdlCustomer.InsertDate = DateTime.Now;
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         ctx.Customers.Add(mdlCustomer);
         ctx.SaveChanges();
     }
 }
Пример #2
0
 public void Update(CustomerDTO item)
 {
     p1p.Data.Customer mdlCustomer = (p1p.Data.Customer)P1PObjectMapper.Convert(item, typeof(p1p.Data.Customer));
     p1p.Data.Customer match;
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         match = ctx.Customers.Single(c => c.Id == item.Id);
         ctx.Entry(match).CurrentValues.SetValues(item);
         ctx.SaveChanges();
     }
 }