Esempio n. 1
0
        public virtual CustomerRequiredProduct GetReplacementForRequiredProduct(CustomerRequiredProduct oldProduct)
        {
            if (CustomerRequiredProducts == null)
            {
                _logger.LogWarning($"{GetType().Name}: _customerRequiredProducts is null while trying to replace its product");
                return(null);
            }

            if (CustomerRequiredProducts.Count == 0)
            {
                _logger.LogWarning($"{GetType().Name}: _customerRequiredProducts is empty while trying to replace its product");
                return(null);
            }

            if (CustomerRequiredProducts.All(x => x != oldProduct))
            {
                _logger.LogWarning($"{GetType().Name}: _customerRequiredProducts cannot find product that is being replaced");
                return(null);
            }

            return(_requiredProductStrategy.ReplaceProduct(oldProduct, ShopsData));
        }
 public decimal GetCurrentPrice(CustomerRequiredProduct customerNeededProduct)
 {
     return(Math.Min(
                customerNeededProduct.StartingPrice +
                customerNeededProduct.ShopsVisited * customerNeededProduct.StartingPrice / 10, _maxPriceToPay));
 }