public Order(int orderId, string productId, DateTime moment, IWebshopCallback callback) { OrderId = orderId; ProductId = productId; Moment = moment; WebshopCallback = callback; }
public void Connect() { IWebshopCallback currentClient = OperationContext.Current.GetCallbackChannel <IWebshopCallback>(); if (!clients.Contains(currentClient)) { clients.Add(currentClient); clients.ForEach(client => client.NewClientConnected(clients.Count)); } }
public void Disconnect() { IWebshopCallback currentClient = OperationContext.Current.GetCallbackChannel <IWebshopCallback>(); if (clients.Contains(currentClient)) { clients.Remove(currentClient); clients.ForEach(client => client.DisconnectedClient(clients.Count)); } }
public void connect() { IWebshopCallback clientCallback = OperationContext.Current.GetCallbackChannel <IWebshopCallback>(); clients.Add(clientCallback); foreach (IWebshopCallback client in clients) { client.newClientConnected(clients.Count); } }
public bool BuyProduct(string ProductId) { IWebshopCallback clientCallback = OperationContext.Current.GetCallbackChannel <IWebshopCallback>(); foreach (var productsItem in this.productItems) { if (productsItem.ProductId == ProductId) { if (productsItem.Stock > 0) { productsItem.Stock--; foreach (var client in this.connectedClients) { if (client != clientCallback) { client.productSold(productsItem); } } Order order = new Order { ProductId = productsItem.ProductId, Moment = DateTime.Now, WebshopCallback = clientCallback }; this.orderList.Add(order); // send this order to all shipping clients this.newOrderEvent(order); return(true); } } } return(false); }
public bool BuyProduct(string productId) { IWebshopCallback currentClient = OperationContext.Current.GetCallbackChannel <IWebshopCallback>(); Item item = GetProduct(productId); if (item.OnSale) { Order order = new Order(counter++, productId, DateTime.Now, currentClient); orders.Add(order); if (ShipOrder(order.OrderId)) { item.Stock--; foreach (IWebshopCallback client in clients) { if (client != currentClient) { client.ProductSold(item); } } return(true); } } return(false); }