public void Handle(SeatCreated @event)
        {
            using (var context = contextFactory.Invoke()) {
                var dto = context.Find <PricedOrderLineSeatTypeDescription>(@event.SourceId);
                if (dto == null)
                {
                    dto = new PricedOrderLineSeatTypeDescription {
                        SeatTypeId = @event.SourceId
                    };
                    context.Set <PricedOrderLineSeatTypeDescription>().Add(dto);
                }

                dto.Name = @event.Name;
                context.SaveChanges();
            }
        }
        public async Task Consume(ConsumeContext <SeatCreated> consumeContext)
        {
            await using var repository = this.contextFactory.Invoke();
            var dto = await repository.Find <PricedOrderLineSeatTypeDescription>(consumeContext.Message.SourceId);

            if (dto == null)
            {
                dto = new PricedOrderLineSeatTypeDescription {
                    SeatTypeId = consumeContext.Message.SourceId
                };
                repository.Set <PricedOrderLineSeatTypeDescription>().Add(dto);
            }

            dto.Name = consumeContext.Message.Name;
            await repository.SaveChangesAsync();
        }
        public async Task Consume(ConsumeContext <SeatUpdated> consumeContext)
        {
            await using var context = this.contextFactory.Invoke();
            var dto = await context.Find <PricedOrderLineSeatTypeDescription>(consumeContext.Message.SourceId);

            if (dto == null)
            {
                dto = new PricedOrderLineSeatTypeDescription {
                    SeatTypeId = consumeContext.Message.SourceId
                };
                context.Set <PricedOrderLineSeatTypeDescription>().Add(dto);
            }

            dto.Name = consumeContext.Message.Name;
            context.SaveChanges();
            this.seatDescriptionsCache.Set(dto.SeatTypeId.ToString(), dto, DateTimeOffset.UtcNow.AddMinutes(5));
        }
        public void Handle(SeatUpdated @event)
        {
            using (var context = contextFactory.Invoke()) {
                var dto = context.Find <PricedOrderLineSeatTypeDescription>(@event.SourceId);
                if (dto == null)
                {
                    dto = new PricedOrderLineSeatTypeDescription {
                        SeatTypeId = @event.SourceId
                    };
                    context.Set <PricedOrderLineSeatTypeDescription>().Add(dto);
                }

                dto.Name = @event.Name;
                context.SaveChanges();
                seatDescriptionsCache.Set("SeatDescription_" + dto.SeatTypeId, dto, new CacheItemPolicy {
                    AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5)
                });
            }
        }