Example #1
0
        private static OrderAdjustment Copy(OrderAdjustment adjustment, IAdjustmentPersister adjustmentPersister)
        {
            var newAdjustment = adjustmentPersister.CreateAdjustment(adjustmentPersister.GetAdjustmentType(adjustment));

            newAdjustment.Id            = adjustment.Id;
            newAdjustment.InitialPrice  = adjustment.InitialPrice;
            newAdjustment.AdjustedPrice = adjustment.AdjustedPrice;

            var amount = ((IPersistableAdjustment)adjustment).Amount;

            if (amount is PercentageAdjustmentAmount)
            {
                ((IPersistableAdjustment)newAdjustment).Amount = new PercentageAdjustmentAmount {
                    PercentageChange = ((PercentageAdjustmentAmount)amount).PercentageChange
                }
            }
            ;
            else
            {
                ((IPersistableAdjustment)newAdjustment).Amount = new FixedAdjustmentAmount {
                    FixedChange = ((FixedAdjustmentAmount)amount).FixedChange
                }
            };
            ((IPersistableAdjustment)newAdjustment).Code        = ((IPersistableAdjustment)adjustment).Code;
            ((IPersistableAdjustment)newAdjustment).ReferenceId = ((IPersistableAdjustment)adjustment).ReferenceId;
            return(newAdjustment);
        }
    }
Example #2
0
 private static Order Copy(Order order, IAdjustmentPersister adjustmentPersister)
 {
     return(new Order
     {
         Id = order.Id,
         Price = order.Price,
         AdjustedPrice = order.AdjustedPrice,
         Currency = order.Currency,
         Items = Copy(order.Items),
         Adjustments = Copy(order.Adjustments, adjustmentPersister),
     });
 }
Example #3
0
 public static ProductOrderEntity Map(this Order order, IAdjustmentPersister adjustmentPersister)
 {
     return(new ProductOrderEntity
     {
         id = order.Id,
         confirmationCode = order.ConfirmationCode,
         ownerId = order.OwnerId,
         purchaserId = order.PurchaserId,
         time = order.Time,
         priceExclTax = order.Price,
         priceInclTax = order.AdjustedPrice,
         currency = order.Currency.Iso4217Code,
         ProductOrderItemEntities = order.Items == null ? null : order.Items.Map(order.Id),
         ProductOrderAdjustmentEntities = order.Adjustments == null ? null : order.Adjustments.Map(order.Id, adjustmentPersister),
     });
 }
Example #4
0
 public static Order Map(this ProductOrderEntity entity, IAdjustmentPersister adjustmentPersister)
 {
     return(new Order
     {
         Id = entity.id,
         ConfirmationCode = entity.confirmationCode,
         OwnerId = entity.ownerId,
         PurchaserId = entity.purchaserId,
         Time = entity.time,
         Price = entity.priceExclTax,
         AdjustedPrice = entity.priceInclTax,
         Currency = Currency.GetCurrency(entity.currency),
         Items = (from i in entity.ProductOrderItemEntities select i.Map()).ToList(),
         Adjustments = (from a in entity.ProductOrderAdjustmentEntities orderby a.rank select a.Map(adjustmentPersister)).ToList(),
     });
 }
Example #5
0
        private static OrderAdjustment Map(this ProductOrderAdjustmentEntity entity, IAdjustmentPersister adjustmentPersister)
        {
            var adjustment = adjustmentPersister.CreateAdjustment(entity.type);

            adjustment.Id            = entity.id;
            adjustment.InitialPrice  = entity.initialPrice;
            adjustment.AdjustedPrice = entity.adjustedPrice;
            ((IPersistableAdjustment)adjustment).Amount = entity.percentageAmount != null
                ? (AdjustmentAmount) new PercentageAdjustmentAmount {
                PercentageChange = entity.percentageAmount.Value
            }
                : new FixedAdjustmentAmount {
                FixedChange = entity.fixedAmount ?? 0
            };
            ((IPersistableAdjustment)adjustment).Code        = entity.code;
            ((IPersistableAdjustment)adjustment).ReferenceId = entity.referenceId;
            return(adjustment);
        }
Example #6
0
 private static IList <OrderAdjustment> Copy(IEnumerable <OrderAdjustment> adjustments, IAdjustmentPersister adjustmentPersister)
 {
     return((from a in adjustments select Copy(a, adjustmentPersister)).ToList());
 }
Example #7
0
 public MockPurchasesCommand(IAdjustmentPersister adjustmentPersister)
 {
     _adjustmentPersister = adjustmentPersister;
 }
Example #8
0
 public OrderPricesCommand(ICreditCardsQuery creditCardsQuery, IAdjustmentPersister adjustmentPersister)
 {
     _creditCardsQuery    = creditCardsQuery;
     _adjustmentPersister = adjustmentPersister;
 }
Example #9
0
        private static ProductOrderAdjustmentEntity Map(this OrderAdjustment adjustment, int rank, Guid orderId, IAdjustmentPersister adjustmentPersister)
        {
            var entity = new ProductOrderAdjustmentEntity
            {
                id            = adjustment.Id,
                rank          = rank,
                orderId       = orderId,
                type          = adjustmentPersister.GetAdjustmentType(adjustment),
                code          = ((IPersistableAdjustment)adjustment).Code,
                referenceId   = ((IPersistableAdjustment)adjustment).ReferenceId,
                initialPrice  = adjustment.InitialPrice,
                adjustedPrice = adjustment.AdjustedPrice,
            };

            var amount = ((IPersistableAdjustment)adjustment).Amount;

            if (amount is PercentageAdjustmentAmount)
            {
                entity.fixedAmount      = null;
                entity.percentageAmount = ((PercentageAdjustmentAmount)amount).PercentageChange;
            }
            else if (amount is FixedAdjustmentAmount)
            {
                entity.fixedAmount      = ((FixedAdjustmentAmount)amount).FixedChange;
                entity.percentageAmount = null;
            }

            return(entity);
        }
Example #10
0
        private static EntitySet <ProductOrderAdjustmentEntity> Map(this IEnumerable <OrderAdjustment> adjustments, Guid orderId, IAdjustmentPersister adjustmentPersister)
        {
            var set = new EntitySet <ProductOrderAdjustmentEntity>();

            set.AddRange(adjustments.Select((a, rank) => a.Map(rank, orderId, adjustmentPersister)));
            return(set);
        }
Example #11
0
 public OrdersRepository(IDataContextFactory dataContextFactory, IAdjustmentPersister adjustmentPersister)
     : base(dataContextFactory)
 {
     _adjustmentPersister = adjustmentPersister;
 }