public void Handle(OrderTotalsCalculated @event)
        {
            var seatTypeIds = @event.Lines.OfType <SeatOrderLine>().Select(x => x.SeatType).Distinct().ToArray();

            var dto = pricedOrderRepository.GetBy(x => x.OrderId == @event.SourceId).FirstOrDefault();

            if (!WasNotAlreadyHandled(dto, @event.Version))
            {
                // message already handled, skip.
                return;
            }

            //var seatTypeDescriptions = GetSeatTypeDescriptions(seatTypeIds, context);
            dto.Lines = new List <PricedOrderLine>();
            for (int i = 0; i < @event.Lines.Length; i++)
            {
                var orderLine = @event.Lines[i];
                var line      = new PricedOrderLine
                {
                    LineTotal = orderLine.LineTotal,
                    Position  = i,
                };

                var seatOrderLine = orderLine as SeatOrderLine;
                if (seatOrderLine != null)
                {
                    // should we update the view model to avoid losing the SeatTypeId?
                    line.Description = seatTypeRepository.GetByKey(seatOrderLine.SeatType).Name;
                    line.UnitPrice   = seatOrderLine.UnitPrice;
                    line.Quantity    = seatOrderLine.Quantity;
                }

                dto.Lines.Add(line);
            }

            dto.Total          = @event.Total;
            dto.IsFreeOfCharge = @event.IsFreeOfCharge;
            dto.OrderVersion   = @event.Version;

            pricedOrderRepository.Update(dto);
        }
예제 #2
0
        public Guid?LocateOrder(string email, string accessCode)
        {
            var rep             = new ConferenceMongoRepository <DraftOrder>();
            var orderProjection = rep.GetBy(o =>
                                            o.RegistrantEmail == email && o.AccessCode == accessCode)
                                  .FirstOrDefault();

            if (orderProjection != null)
            {
                return(orderProjection.OrderId);
            }

            return(null);
        }
        public IList <SeatTypeName> GetSeatTypeNames(IEnumerable <Guid> seatTypes)
        {
            var distinctIds = seatTypes.Distinct().ToArray();

            if (distinctIds.Length == 0)
            {
                return(new List <SeatTypeName>());
            }

            var rep = new ConferenceMongoRepository <SeatTypeView>();

            return(rep.GetBy(x => distinctIds.Contains(x.SeatTypeId))
                   .Select(s => new SeatTypeName {
                Id = s.SeatTypeId, Name = s.Name
            })
                   .ToList());
        }
        public IList <ConferenceAlias> GetPublishedConferences()
        {
            var alias          = new List <ConferenceAlias>();
            var rep            = new ConferenceMongoRepository <ConferenceView>();
            var conferenceList = rep.GetBy(dto => dto.IsPublished);

            if (conferenceList.Count() > 0)
            {
                alias = conferenceList.Select(x =>
                                              new ConferenceAlias
                {
                    Id      = x.ConferenceId,
                    Code    = x.Code,
                    Name    = x.Name,
                    Tagline = x.Tagline
                })
                        .ToList();
            }
            return(alias);
        }
예제 #5
0
        public OrderSeats FindOrderSeats(Guid assignmentsId)
        {
            var rep = new ConferenceMongoRepository <OrderSeats>();

            return(rep.GetBy(o => o.AssignmentsId == assignmentsId).FirstOrDefault());
        }
예제 #6
0
        public PricedOrder FindPricedOrder(Guid orderId)
        {
            var rep = new ConferenceMongoRepository <PricedOrder>();

            return(rep.GetBy(o => o.OrderId == orderId).FirstOrDefault());
        }
예제 #7
0
        private OrderSeats Find(Guid id)
        {
            var dto = orderSeatsRepository.GetBy(o => o.OrderId == id).FirstOrDefault();

            return(dto);
        }
        private IEnumerable <ConferenceView> GetConferenceByCode(string conferenceCode)
        {
            var rep = new ConferenceMongoRepository <ConferenceView>();

            return(rep.GetBy(dto => dto.Code == conferenceCode));
        }
 private DraftOrder GetDraftOrder(Guid orderId)
 {
     return(draftOrderRepository.GetBy(p => p.OrderId == orderId).FirstOrDefault());
 }
 private ConferenceView GetConferenceView(Guid conferenceId)
 {
     return(conferenceRepository.GetBy(p => p.ConferenceId == conferenceId).FirstOrDefault());
 }
 private SeatTypeView GetSeatTypeView(Guid seatTypeId)
 {
     return(seatTypeRepository.GetBy(p => p.SeatTypeId == seatTypeId).FirstOrDefault());
 }