Пример #1
0
        public ProductCombination Create(Product product, ProductPrice price, IList <SelectedAttribute> attributes)
        {
            var productCombination   = new ProductCombination(price, attributes);
            var containsValidOptions = _validator.EnsureCombinationContainsValidOptions(productCombination, product);

            AssertionConcerns.AssertArgumentToBeTrue(containsValidOptions, $"{Reasons.InvalidOptions}: given product {product}");
            return(productCombination);
        }
Пример #2
0
        public bool EnsureCombinationContainsAllAttributes(ProductCombination productCombination, Product product)
        {
            var combinationNames = productCombination.SelectedAttributes.Select(x => x.Name);
            var attributesNames  = product.Attributes.Select(x => x.Name);

            //Are AttributeNames the same
            if (combinationNames.Except(attributesNames).Any() || attributesNames.Except(combinationNames).Any())
            {
                return(false);
            }
            return(true);
        }
Пример #3
0
        public bool EnsureCombinationContainsValidOptions(ProductCombination productCombination, Product product)
        {
            foreach (var selectedAttribute in productCombination.SelectedAttributes)
            {
                var isValidOption = product.Attributes
                                    .Any(x => x.Name == selectedAttribute.Name &&
                                         x.checkIsValidOption(selectedAttribute.SelectedOption));

                if (!isValidOption)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #4
0
 public SellSignupCreated(string productSellId, ProductCombination productCombination, SellSignup signup)
 {
     ProductSellId      = productSellId;
     ProductCombination = productCombination;
     Signup             = signup;
 }