private void Subscribe() { // create an instance of the topic helper var helper = ServiceBusTopicHelper.Setup(SubscriptionInitializer.Initialize()); // send the message into the topic helper.Subscribe <PizzaOrder>((order) => { // save the order var context = new EnterprisePizzaDataContext(); context.Orders.Add(order); context.SaveChanges(); // write out a note Console.WriteLine("Order {0} just taken with {1} pizza(s)", order.Id, order.Pizzas.Count); // now notify the store of the new order order.IsOrdered = true; // publish the messages as saved but not received yet helper.Publish <PizzaOrder>(order, (m) => { m.Properties["IsOrdered"] = true; m.Properties["IsReceivedByStore"] = false; }); } , "(IsOrdered = false) AND (IsReceivedByStore = false)", "NewPizzaOrders" ); }
public void ToggleIngredientAvailability(ToggleIngredientAvailabilityRequest request) { var ingredient = _dbContext.AvailableIngredients .First(x => x.Name == request.IngredientName); ingredient.IsInStock = request.IsAvailable; _dbContext.AvailableIngredients.Attach(ingredient); var entry = _dbContext.Entry(ingredient); entry.Property(e => e.IsInStock).IsModified = true; _dbContext.SaveChanges(); }