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); }
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); }
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); }
public SellSignupCreated(string productSellId, ProductCombination productCombination, SellSignup signup) { ProductSellId = productSellId; ProductCombination = productCombination; Signup = signup; }