public double RequestOrder(MixedOrder order) { double sum = 0; for (int i = 0; i < order.mixedOrder.Count; i++) { if (order.mixedOrder.ElementAt(i).productID == (list[i].ProductId)) { if (order.mixedOrder.ElementAt(i).quantity > (list[i].Quantity)) { throw new NotAvailableInInventoryException("The order can not be made!"); } else sum += order.mixedOrder.ElementAt(i).quantity * list[i].PriceAfter; } } return sum; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Console.WriteLine($"Bake service is running at: {DateTime.Now}"); while (!stoppingToken.IsCancellationRequested) { var allConnections = new Dictionary <string, IConsumer <string, string> >(SignalRKafkaProxy.AllConsumers); Console.WriteLine("Connections count:" + allConnections.Count); foreach (var c in allConnections) { Console.WriteLine("ConnectionId: " + c.Key); } if (allConnections != null) { foreach (var connection in allConnections) { //Read a message string connectionId = connection.Key; Console.WriteLine($"connection: {connectionId}, consumer:{connection.Value}"); IConsumer <string, string> consumerConnection = connection.Value; var consumerResult = consumerConnection.Consume(new TimeSpan(0, 0, 15)); if (consumerResult != null) { //Deserilaize MixedOrder orderRequest = JsonConvert.DeserializeObject <MixedOrder>(consumerResult.Value); Console.WriteLine($"Info: Recieved order to mix. Id# {orderRequest.Id}"); //Step 1: If there is a new message in KAFKA "Orders" topic, inform the client. Console.WriteLine($"Informing UI connected clients about the newly recieved order. Id# {orderRequest.Id}"); await _orderMonitorHub.Clients.Client(connectionId).InformNewOrderToBake(orderRequest); } } } } }
public CupcakeOrderBatterMixedEvent(MixedOrder order) { this.Order = order; }
public MarkOrderStatusAsMixedCommand(MixedOrder order) { this.Order = order; }