public Product(Decimal basePrice, List <ProductAttribute> attributes, IList <ProductSell> productSells) { AssertionConcerns.AssertArgumentRange(basePrice, 0, Decimal.MaxValue, "Product Base Price Cannot be Negative"); BasePrice = basePrice; Attributes = attributes ?? new List <ProductAttribute>(); ProductSells = productSells ?? new List <ProductSell>(); }
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 ProductPrice(decimal discount, decimal price, decimal lowestPrice) { AssertionConcerns.AssertArgumentRange(discount, 0, Decimal.MaxValue, "Discount cannot be negative"); AssertionConcerns.AssertArgumentRange(price, 0, Decimal.MaxValue, "Price cannot be negative"); AssertionConcerns.AssertArgumentRange(lowestPrice, 0, Decimal.MaxValue, "LowestPrice cannot be negative"); Discount = discount; Price = price; LowestPrice = lowestPrice; }
public override bool checkIsValidOption(AttributeOption option) { AssertionConcerns.AssertArgumentCanBeDouble(option.Value, $"{Reasons.UNPARSEABLE}: Value is not parseable as double {option}"); var val = Double.Parse(option.Value); return(val >= MinValue && val <= MaxValue); }
public ProductAttributeWithContinousValue(string name, AttributeOption valueIsAny) : base(name) { AssertionConcerns.AssertArgumentIs <AttributeOption>(valueIsAny, AttributeOption.AnyValue, $"{Reasons.UNEXPECTED_VALUE}: Value can only be ANY cannot be anything else"); AttributeOptions = new List <AttributeOption>() { valueIsAny }; }
public ProductAttributeWithContinousValue(string name, AttributeOption minValue, AttributeOption maxValue) : base(name) { AssertionConcerns.AssertArgumentCanBeDouble(minValue.Value, $"{Reasons.UNPARSEABLE}: Value is not parseable as double {minValue}"); AssertionConcerns.AssertArgumentCanBeDouble(maxValue.Value, $"{Reasons.UNPARSEABLE}: Value is not parseable as double {maxValue}"); AttributeOptions = new List <AttributeOption>() { minValue, maxValue }; }
public ProductAttribute Create(string name, AttributeType type, AttributeOption[] values) { switch (type) { case AttributeType.Discrete: return(new ProductAttributeWithDiscreteValue(name, values.ToList())); case AttributeType.Continuous: AssertionConcerns.AssertArgumentLength(values, 2, $"{Reasons.WRONG_LENGTH}: Given length is not 2, Name: {name}, Values: {values}"); return(new ProductAttributeWithContinousValue(name, values[0], values[1])); default: throw new DomainException($"{Reasons.AttributeTypeError}: No Such AttributeType"); } }
public ProductAttribute(string name) { AssertionConcerns.AssertArgumentNotEmpty(name, "ProductAttribute Name cannot be Empty"); Name = name; }
public void AddProductSellSignup(ActiveSignup signup) { AssertionConcerns.AssertArgumentNotIn(signup, ActiveSignups, $"{Reasons.DUPLICATE}: Cannot add a duplicate ActiveSignups"); ActiveSignups.Add(signup); }
public void AddAttribute(ProductAttribute productAttribute) { AssertionConcerns.AssertArgumentNotIn(productAttribute, Attributes, $"Product Attribute Already Exists: {productAttribute}"); Attributes.Add(productAttribute); }
public void SetProductDiscountAndPrice(ProductPrice price) { AssertionConcerns.AssertArugmentNotNull(price, $"{Reasons.NotNullable}: ProductPrice cannot be set to null"); ProductPrice = price; }