예제 #1
0
 internal static Quote ToDomainModel(this QuoteDto quoteDto) => Quote.For(
     ProductAmount.Of(
         ProductId.From(quoteDto.ProductId),
         quoteDto.Amount,
         quoteDto.UnitCode.ToDomainModel <AmountUnit>()),
     Money.Of(
         quoteDto.Price,
         quoteDto.CurrencyCode.ToDomainModel <Currency>()));
예제 #2
0
            public void Apply(Order order)
            {
                var quotes = PriceConfirmations
                             .Select(confirmation => Quote.For(
                                         ProductAmount.Of(
                                             ProductId.From(confirmation.ProductId),
                                             Amount.Of(
                                                 confirmation.Amount,
                                                 confirmation.AmountUnit.ToDomainModel <AmountUnit>())),
                                         Money.Of(
                                             confirmation.Price,
                                             confirmation.Currency.ToDomainModel <Currency>())))
                             .ToImmutableArray();

                order._priceAgreement = PriceAgreement.Temporary(quotes, PriceAgreementExpiresOn);
            }
예제 #3
0
            public void Apply(Order order)
            {
                var quotes = new List <Quote>();

                foreach (var priceConfirmation in PriceConfirmations)
                {
                    var productId = ProductId.From(priceConfirmation.ProductId);
                    var amount    = Amount.Of(
                        priceConfirmation.Amount,
                        priceConfirmation.AmountUnit.ToDomainModel <AmountUnit>());
                    order._items.Add(
                        ProductUnit.Of(
                            productId,
                            priceConfirmation.AmountUnit.ToDomainModel <AmountUnit>()),
                        amount);
                    quotes.Add(Quote.For(
                                   ProductAmount.Of(productId, amount),
                                   Money.Of(
                                       priceConfirmation.Price,
                                       priceConfirmation.Currency.ToDomainModel <Currency>())));
                }
                order._priceAgreement = PriceAgreement.Final(quotes.ToImmutableArray());
            }
예제 #4
0
        public void CreateOrder(CreateOrderRequest request)
        {
            var command = new CreateOrderCommand(CustomerId.From(request.CustomerId));

            _commandDispatcher.Dispatch(command);
            foreach (var orderItem in request.OrderItems)
            {
                _commandDispatcher.Dispatch(new AddItemToOrderCommand(command.OrderIdCreated, ProductId.From(orderItem.ProductId), orderItem.Quantity));
            }
        }
예제 #5
0
 public static ProductAmount ToDomainModel(this CartItemDto cartItemDto) => ProductAmount.Of(
     ProductId.From(cartItemDto.ProductId),
     cartItemDto.Amount,
     AmountUnit.Unit);