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>()));
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); }
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()); }
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)); } }
public static ProductAmount ToDomainModel(this CartItemDto cartItemDto) => ProductAmount.Of( ProductId.From(cartItemDto.ProductId), cartItemDto.Amount, AmountUnit.Unit);