public void Handle(AnchorCreated @event) { using (var context = this.contextFactory.Create()) { var dto = DbContext.Find <PricedOrderLineAnchorTypeDescription>(@event.SourceId); if (dto == null) { dto = new PricedOrderLineAnchorTypeDescription { SeatTypeID = @event.SourceId }; DbContext.Set <PricedOrderLineAnchorTypeDescription>().Add(dto); } dto.Name = @event.Name; context.SaveChanges(); } }
public void Handle(AnchorUpdated @event) { using (var context = this.contextFactory.Create()) { var dto = DbContext.Find <PricedOrderLineAnchorTypeDescription>(@event.SourceId); if (dto == null) { dto = new PricedOrderLineAnchorTypeDescription { SeatTypeID = @event.SourceId }; DbContext.Set <PricedOrderLineAnchorTypeDescription>().Add(dto); } dto.Name = @event.Name; context.SaveChanges(); this.seatDescriptionsCache.Set("SeatDescription_" + dto.SeatTypeID.ToString(), dto, DateTimeOffset.UtcNow.AddMinutes(5)); } }