private static Order RestoreFrom(SalesDb.Order dbOrder)
            {
                var priceAgreementType = dbOrder.PriceAgreementType.ToDomainModel <PriceAgreementType>();

                return(priceAgreementType switch
                {
                    PriceAgreementType.Non => RestoreWithNoPriceAgreement(dbOrder),
                    PriceAgreementType.Temporary => RestoreWithTemporaryPriceAgreement(dbOrder),
                    PriceAgreementType.Final => RestoreWithFinalPriceAgreement(dbOrder),
                    _ => throw new ArgumentOutOfRangeException(nameof(priceAgreementType), priceAgreementType, null)
                });
 private SalesDb.Order GetDbOrder(Order order)
 {
     if (_orders.TryGetValue(order.Id, out var dbOrder))
     {
         return(dbOrder);
     }
     dbOrder = new SalesDb.Order {
         Id = order.Id.Value
     };
     _dbContext.Orders.Add(dbOrder);
     return(dbOrder);
 }
 private static Order.Snapshot CreateSnapshotFrom(SalesDb.Order dbOrder) => new Order.Snapshot(
     dbOrder.Id,
     dbOrder.Items
     .Select(dbOrderItem => new Order.Snapshot.Item(
                 dbOrderItem.ProductId,
                 dbOrderItem.Amount,
                 dbOrderItem.AmountUnit,
                 dbOrderItem.Price,
                 dbOrderItem.Currency))
     .ToImmutableArray(),
     dbOrder.PriceAgreementType,
     dbOrder.PriceAgreementExpiresOn,
     dbOrder.IsPlaced);
 private static void Merge(SalesDb.Order dbOrder, Order.Snapshot snapshot)
 {
     dbOrder.Items = snapshot.Items
                     .Select(item => new SalesDb.OrderItem
     {
         ProductId  = item.ProductId,
         Amount     = item.Amount,
         AmountUnit = item.AmountUnit,
         Price      = item.Price,
         Currency   = item.Currency
     })
                     .ToList();
     dbOrder.PriceAgreementType      = snapshot.PriceAgreementType;
     dbOrder.PriceAgreementExpiresOn = snapshot.PriceAgreementExpiresOn;
     dbOrder.IsPlaced = snapshot.IsPlaced;
 }