public Lamp Update(Lamp lampUpdate) { var newOrderLines = new List <OrderLine>(lampUpdate.OrderLines); _ltx.Attach(lampUpdate).State = EntityState.Modified; _ltx.OrderLines.RemoveRange( _ltx.OrderLines.Where(ol => ol.LampId == lampUpdate.Id)); foreach (var ol in newOrderLines) { _ltx.Entry(ol).State = EntityState.Added; } _ltx.SaveChanges(); return(lampUpdate); }
public Order Create(Order order) { _ltx.Attach(order).State = EntityState.Added; _ltx.SaveChanges(); return(order); }