internal Variant(string barcode, AttributeRef varianterAttribute) { Barcode = barcode; VarianterAttribute = varianterAttribute; Register <ImageAddedToProduct>(Apply); }
public void AssignImage(ImageRef image, AttributeRef varianterAttr) { Should(() => Variants.Any(v => v.HasSameTypeVarianterAttribute(varianterAttr)), $"Product does not have any attribute with given attributeId: {varianterAttr.AttributeId}"); ApplyChange(new ImageAddedToProduct(Id, varianterAttr, image)); }
public void AddAttributeToContent(AttributeRef attribute) { Should(() => _attributes.Any(a => a != attribute), "Given attribute had already been added to the product"); ApplyChange(new AttributeAddedToProduct(Id, attribute)); }
internal Content(string title, string description, AttributeRef slicerAttribute) { Title = title; Description = description; SlicerAttribute = slicerAttribute; Register <VariantAddedToProduct>(Apply); }
public void AddContent(string title, string description, AttributeRef slicerAttribute) { if (_contents.Any()) { Should(() => _contents.Any(c => c.HasSameTypeSlicerAttribute(slicerAttribute)), "Given attribute type should belong to any content of product as slicer"); } Should(() => _contents.All(c => c.SlicerAttribute != slicerAttribute), "Same content already exists with given attribute"); ApplyChange(new ContentAddedToProduct(Id, title, description, slicerAttribute)); }
public void AddVariant(string barcode, AttributeRef slicerAttribute, AttributeRef varianterAttribute) { var content = _contents.SingleOrDefault(c => c.SlicerAttribute == slicerAttribute); Should(() => content != null, "No content found with given slicer attribute."); // ReSharper disable once PossibleNullReferenceException var variantsOfContent = content.Variants; if (variantsOfContent.Any()) { Should(() => variantsOfContent.All(c => c.HasSameTypeVarianterAttribute(varianterAttribute)), "Given attribute type should belong to any variant of product as varianter"); } Should(() => variantsOfContent.All(v => v.VarianterAttribute != varianterAttribute), "Same variant already exists with given attribute"); ApplyChange(new VariantAddedToProduct(Id, barcode, slicerAttribute, varianterAttribute)); }
public bool HasSameTypeSlicerAttribute(AttributeRef attribute) { return(SlicerAttribute.AttributeId == attribute.AttributeId); }
public bool HasSameTypeVarianterAttribute(AttributeRef attribute) { return(VarianterAttribute.AttributeId == attribute.AttributeId); }