public async Task RestaurantCreatedConsumeFakeMessage()
        {
            RestaurantCreated restaurantCreated = new RestaurantCreated()
            {
                Code = "BOSCHESE",
                Id   = 1
            };

            var sub = new RestaurantCreatedPubSubSubScriber(bus, dataContext);
            await sub.Consume(restaurantCreated, new MessageContext()
            {
                GlobalRequestId = Guid.NewGuid()
            });
        }
        public async Task Consume(RestaurantCreated message, MessageContext context)
        {
            this.dataContext = DataUtility.GetDataContext(dataContext);;
            using (dataContext)
            {
                Restaurant restaurant = dataContext.Restaurants.SingleOrDefault(p => p.Id == message.Id);
                if (restaurant != null)
                {
                    return;
                }

                restaurant = new Restaurant
                {
                    Id   = message.Id,
                    Code = message.Code
                };

                dataContext.Restaurants.Add(restaurant);

                await dataContext.SaveChangesAsync();
            }
        }
Beispiel #3
0
 private static bool OnRestaurantCreated(RestaurantCreated arg)
 {
     return(true);
 }
 private static ICreateRestaurantResult OnRestaurantCreated(RestaurantCreated arg)
 {
     return(arg);
 }
Beispiel #5
0
 private static bool OnRestaurantCreated(RestaurantCreated arg)
 {
     Console.WriteLine(arg.RestaurantAgg.ToString());
     return(true);
 }