//deletes orderline from database public void DeleteOrderLine(OrderManagement.DAL.OrderLinesTable orderLine) { using (OrderManagementDBEntities ct = new OrderManagementDBEntities()) { OrderLinesTable or = ct.OrderLinesTable.First(t => t.Id == orderLine.Id); ct.Entry(or).State = System.Data.EntityState.Deleted; ct.SaveChanges(); } }
//method for editing order line //not used as order lines never edited //instead they are deleted and added public void EditOrderLine(OrderLinesTable editOrderLine) { using (OrderManagementDBEntities editLine = new OrderManagementDBEntities()) { OrderLinesTable el = editLine.OrderLinesTable.First(t => t.Id == editOrderLine.Id); el.QuantityOrdered = editOrderLine.QuantityOrdered; el.TotalForItem = editOrderLine.QuantityOrdered * el.SellingPrice; editLine.Entry(el).State = System.Data.EntityState.Modified; editLine.SaveChanges(); } }