public IList <DomainEvent> Accept(OrderRequest request, Dictionary <String, ProductAggregate> productAggregates)
        {
            var evts = new List <DomainEvent>();

            var evt = OrderAcceptedEvent.FromProto(request, this.OrderID);

            evts.Add(evt);

            foreach (string sku in productAggregates.Keys)
            {
                uint quantity = request.LineItems.ToArray().FirstOrDefault(li => li.SKU == sku).Quantity;
                evts.AddRange(productAggregates[sku].Reserve(this.orderID, request.UserID, quantity));
            }
            return(evts);
        }
Esempio n. 2
0
        public IList <DomainEvent> Accept(OrderRequest request, Dictionary <string, ProductAggregate> productAggregates)
        {
            var evts = new List <DomainEvent>();

            var evt = OrderAcceptedEvent.FromProto(request, this.OrderId);

            evts.Add(evt);

            foreach (var sku in productAggregates.Keys)
            {
                var list = new List <LineItem>();
                foreach (var item in request.LineItems)
                {
                    list.Add(item);
                }
                var quantity = list?.FirstOrDefault(li => li.SKU == sku)?.Quantity;
                evts.AddRange(productAggregates[sku].Reserve(this.orderId, request.UserID, quantity.GetValueOrDefault()));
            }
            return(evts);
        }