コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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)
                });
            }
        }