//return new order id in hq table public int requestStockToHQ(int productId, int quantity) { using (var ctx = new ChocolateStoreUkEntities2()) { int proposedIdFromOrders = ctx.Orders.Max(p => p.OrderID); int proposedIdFromPending = ctx.PendingOrders.Max(p => p.OrderID); HQServiceReference.HQServiceClient client = new HQServiceReference.HQServiceClient(); int newId = client.requestStockHQ(Math.Max(proposedIdFromOrders, proposedIdFromPending), "uk", productId, quantity); return(newId); } }
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 acceptOrder(int orderId) { using (var ctx = new ChocolateStoreUkEntities2()) { var result = ctx.spConfirmPendingOrder(orderId); if (result > 0) { Order o = ctx.Orders.Find(orderId); HQServiceReference.HQServiceClient client = new HQServiceReference.HQServiceClient(); bool logRet = client.logLocalOrder(o.OrderID, o.ClientID, o.ProductID, o.Date.ToShortDateString(), o.Quantity, o.ShipperID, true, ""); return(logRet); } else { return(false); } } }