/// <summary> /// Validates the constraint against the <see cref="ILineItemContainer"/> /// </summary> /// <param name="value"> /// The value to object to which the constraint is to be applied. /// </param> /// <param name="customer"> /// The <see cref="ICustomerBase"/>. /// </param> /// <returns> /// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced. /// </returns> public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer) { var visitor = new MaximumQuantityConstraintVisitor(MaximumQuantity); value.Items.Accept(visitor); return this.Success(this.CreateNewLineContainer(visitor.ModifiedItems)); }
/// <summary> /// Validates the constraint against the <see cref="ILineItemContainer"/> /// </summary> /// <param name="value"> /// The value to object to which the constraint is to be applied. /// </param> /// <param name="customer"> /// The <see cref="ICustomerBase"/>. /// </param> /// <returns> /// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced. /// </returns> public override Attempt <ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer) { var visitor = new MaximumQuantityConstraintVisitor(MaximumQuantity); value.Items.Accept(visitor); return(this.Success(this.CreateNewLineContainer(visitor.ModifiedItems))); }