Exemplo n.º 1
0
        public void Handle(SeatCreated @event)
        {
            using (var repository = contextFactory.Invoke()) {
                var dto = repository.Find <SeatType>(@event.SourceId);
                if (dto != null)
                {
                    Trace.TraceWarning(
                        "Ignoring SeatCreated event for seat type with ID {0} as it was already created.",
                        @event.SourceId);
                }
                else
                {
                    dto = new SeatType(
                        @event.SourceId,
                        @event.ConferenceId,
                        @event.Name,
                        @event.Description,
                        @event.Price,
                        @event.Quantity);

                    bus.Send(
                        new AddSeats {
                        ConferenceId = @event.ConferenceId,
                        SeatType     = @event.SourceId,
                        Quantity     = @event.Quantity
                    });

                    repository.Save(dto);
                }
            }
        }
        public void Handle(SeatCreated @event)
        {
            var dto = GetSeatTypeView(@event.SourceId);

            if (dto != null)
            {
                Trace.TraceWarning(
                    "Ignoring SeatCreated event for seat type with ID {0} as it was already created.",
                    @event.SourceId);
            }
            else
            {
                dto = new SeatTypeView(
                    @event.SourceId,
                    @event.ConferenceId,
                    @event.Name,
                    @event.Description,
                    @event.Price,
                    @event.Quantity);

                this.bus.Send(
                    new AddSeats
                {
                    ConferenceId = @event.ConferenceId,
                    SeatType     = @event.SourceId,
                    Quantity     = @event.Quantity
                });

                seatTypeRepository.Insert(dto);
            }
        }
        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();
            }
        }
Exemplo n.º 4
0
        public static Seat Create(Guid sessionId, Guid?studentId, Guid companyId)
        {
            sessionId.EnsureNotEmpty(nameof(sessionId));
            companyId.EnsureNotEmpty(nameof(companyId));

            var seat = new Seat(History.Empty);

            seat.AggregateId = Guid.NewGuid();

            var @event = new SeatCreated(seat.AggregateId, 1, sessionId, studentId, companyId);

            seat.Apply(@event);
            seat.UncommitedEvents.Add(@event);

            return(seat);
        }