Ejemplo n.º 1
0
 public TripService(CabService cabService, RiderService riderService, ICabMatchStrategy cabMatchStrategy, IPricingStrategy pricingStrategy)
 {
     _cabService       = cabService;
     _riderService     = riderService;
     _cabMatchStrategy = cabMatchStrategy;
     _pricingStrategy  = pricingStrategy;
 }
Ejemplo n.º 2
0
 private PriceList(
     List <PriceListItemData> items,
     IPricingStrategy pricingStrategy)
 {
     _items           = items;
     _pricingStrategy = pricingStrategy;
 }
Ejemplo n.º 3
0
 public CustomersController(InstantDeliveryContext context, UserManager <User, string> userManager,
                            IPricingStrategy pricingStrategy)
 {
     this.context         = context;
     this.userManager     = userManager;
     this.pricingStrategy = pricingStrategy;
 }
Ejemplo n.º 4
0
 public CustomersController(InstantDeliveryContext context, UserManager<User, string> userManager,
     IPricingStrategy pricingStrategy)
 {
     this.context = context;
     this.userManager = userManager;
     this.pricingStrategy = pricingStrategy;
 }
Ejemplo n.º 5
0
        public ProductOrder(Guid productOrderId, Guid productId, decimal unitPrice, IPricingStrategy pricingStrategy, int units = 1)
        {
            if (units < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(units));
            }
            if (unitPrice < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(unitPrice));
            }

            _pricingStrategy = pricingStrategy ?? throw new ArgumentNullException(nameof(pricingStrategy));

            ProductOrderId = productOrderId;
            ProductId      = productId;

            _unitPrice = unitPrice;
            _units     = units;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get best offer promotions
        /// </summary>
        /// <returns></returns>
        protected ICollection <AppliedPromotion> ChoosePromotions()
        {
            ICollection <AppliedPromotion> appliedPromotions = new HashSet <AppliedPromotion>();

            foreach (var saleLineItem in saleLineItems)
            {
                IPricingStrategy        pricingStrategy = PricingStrategyFactory.NewInstance().CreateStrategy();
                IEnumerable <Promotion> promotions      = availablePromotions.Where(x => x.Id == saleLineItem.Product.Id);
                foreach (Promotion promotion in promotions)
                {
                    pricingStrategy.ApplyPromotion(promotion);
                }

                var appliedPromotion = pricingStrategy.GetAppliedPromotion(saleLineItem);
                if (appliedPromotion != null)
                {
                    appliedPromotions.Add(appliedPromotion);
                }
            }

            return(appliedPromotions);
        }
Ejemplo n.º 7
0
        public OrderItem(Guid id, Guid productId, Price unitPrice, IPricingStrategy pricingStrategy, int units = 1) : base(id)
        {
            if (units < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(units));
            }
            if (unitPrice == null)
            {
                throw new ArgumentNullException(nameof(unitPrice));
            }
            if (unitPrice.Value < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(unitPrice));
            }

            _pricingStrategy = pricingStrategy ?? throw new ArgumentNullException(nameof(pricingStrategy));

            ProductId = productId;

            _unitPrice = unitPrice;
            _units     = units;
        }
Ejemplo n.º 8
0
 public OrderTests()
 {
     _pricingRulesRepository = Substitute.For <IVolumePricingRulesRepository>();
     _pricingStrategy        = Substitute.For <IPricingStrategy>();
     _pricingStrategyFactory = new PricingStrategyFactory(_pricingRulesRepository);
 }
Ejemplo n.º 9
0
 public static PriceList Create(
     List <PriceListItemData> items,
     IPricingStrategy pricingStrategy)
 {
     return(new PriceList(items, pricingStrategy));
 }
 public Customer(IPricingStrategy strategy)
 {
     this.CartItem = new List <double>();
     this.Strategy = strategy;
 }
 /// <summary>
 /// Konstruktor kontrolera przesyłek.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="pricingStrategy"></param>
 public PackagesController(InstantDeliveryContext context, IPricingStrategy pricingStrategy)
 {
     this.context         = context;
     this.pricingStrategy = pricingStrategy;
 }
Ejemplo n.º 12
0
 public DefaultStrategyTest()
 {
     _productRepository = A.Fake <IProductRepository>();
     _pricingStrategy   = new DefaultStrategy(_productRepository);
 }
Ejemplo n.º 13
0
 public Item(IPricingStrategy strategy)
 {
     this._surveys         = new HashSet <ItemSurvey>();
     this._pricingStrategy = strategy;
 }
Ejemplo n.º 14
0
 public void AddPricingStrategy(IPricingStrategy pricingStrategy)
 {
     PricingStrategies.Add(pricingStrategy);
 }
 public ApplySauceStrategyTest()
 {
     _productRepository = A.Fake <IProductRepository>();
     _pricingStrategy   = new ApplySauceStrategy(_productRepository);
 }
 public void SetPricingStrategy(IPricingStrategy pricingStrategy)
 {
     _pricingStrategy = pricingStrategy;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Konstruktor kontrolera przesyłek.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="pricingStrategy"></param>
 public PackagesController(InstantDeliveryContext context, IPricingStrategy pricingStrategy)
 {
     this.context = context;
     this.pricingStrategy = pricingStrategy;
 }