Beispiel #1
0
 public void Add(OrderItem entity)
 {
     entity.Order = db.Orders.Find(entity.Order.Id);
     entity.Good = db.Goods.Find(entity.Good.Id);
     db.OrderItems.Add(entity);
     db.SaveChanges();
 }
Beispiel #2
0
        public void Edit(OrderItem orderItem)
        {
            //db.Entry(orderItem).State = EntityState.Modified;

            var item = db.OrderItems.FirstOrDefault(i => i.Id == orderItem.Id);

            if (item != null)
            {
                if (orderItem.Order != null)
                {
                    item.Order = orderItem.Order;
                }

                item.Good = orderItem.Good;
                item.Number = orderItem.Number;
                item.PriceSale = orderItem.PriceSale;
            }

            db.SaveChanges();
        }