Пример #1
0
        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);
        }
Пример #2
0
 public Order Create(Order order)
 {
     _ltx.Attach(order).State = EntityState.Added;
     _ltx.SaveChanges();
     return(order);
 }