Пример #1
0
        /// <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 ProductSelectionConstraintVisitor(this.ProductConstraintDataSet);

            value.Items.Accept(visitor);

            return(visitor.FilteredItems.Any()
                       ? this.Success(this.CreateNewLineContainer(visitor.FilteredItems))
                       : this.Fail(value, "No products matched the configured filter."));
        }
        /// <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 ProductSelectionConstraintVisitor(this.ProductConstraintDataSet);
            value.Items.Accept(visitor);

            return visitor.FilteredItems.Any()
                       ? this.Success(this.CreateNewLineContainer(visitor.FilteredItems))
                       : this.Fail(value, "No products matched the configured filter.");
        }