コード例 #1
0
        public async Task <OfferConfirmed> Handle(ConfirmOfferCommand command)
        {
            var(orderId, offer) = CreateDomainModelFrom(command);
            var order = await _orders.GetBy(orderId);

            var orderHeader = await _orderHeaders.GetBy(orderId);

            var currentOffer = await _calculatePrices.For(orderHeader.ClientId,
                                                          SalesChannel.Wholesales,
                                                          offer.ProductAmounts,
                                                          offer.Currency);

            if (!offer.Equals(currentOffer))
            {
                throw new DomainException();
            }
            var priceChangesPolicy = await _priceChangesPolicies.ChooseFor(orderHeader.ClientId);

            var now = _clock.Now;

            order.ConfirmPrices(offer, now + _offerExpirationTime, now, priceChangesPolicy);
            await _orders.Save(order);

            return(CreateEventFrom(orderId, offer));
        }
コード例 #2
0
 private static (OrderId, Offer) CreateDomainModelFrom(ConfirmOfferCommand command) => (