public bool deliverStock(int productId, int quantity) { using (var ctx = new ChocolateStoreUkEntities2()) { Product p = ctx.Products.Find(productId); p.Quantity = p.Quantity + quantity; int ret = ctx.SaveChanges(); return(ret > 0); } }
public bool dismissOrder(int orderId, string justification) { using (var ctx = new ChocolateStoreUkEntities2()) { PendingOrder po = ctx.PendingOrders.Find(orderId); HQServiceReference.HQServiceClient client = new HQServiceReference.HQServiceClient(); bool logRet = client.logLocalOrder(po.OrderID, po.ClientID, po.ProductID, po.Date.ToShortDateString(), po.Quantity, po.ShipperID, false, justification); logDismissedLocalOrder(po, justification); ctx.PendingOrders.Remove(po); int ret = ctx.SaveChanges(); return(logRet && ret > 0); } }
public bool logDismissedLocalOrder(PendingOrder po, string justification) { using (var ctx = new ChocolateStoreUkEntities2()) { Order o = new Order(); o.OrderID = po.OrderID; o.ClientID = po.ClientID; o.ProductID = po.ProductID; o.Quantity = po.Quantity; o.Date = po.Date; o.ShipperID = po.ShipperID; o.Accepted = 0; o.Justification = justification; ctx.Orders.Add(o); int ret = ctx.SaveChanges(); return(ret > 0); } }