/// <summary> /// Gets a collection of <see cref="OfferSettingsDisplay"/> from an <see cref="ILineItemContainer"/>. /// </summary> /// <param name="container"> /// The container. /// </param> /// <returns> /// The <see cref="IEnumerable{OfferSettingsDisplay}"/>. /// </returns> internal static IEnumerable <OfferSettingsDisplay> GetOfferSettingsDisplays(this ILineItemContainer container) { if (!container.ContainsAnyCoupons()) { return(Enumerable.Empty <OfferSettingsDisplay>()); } return(container.Items.Select(GetOfferSettingsDisplay)); }
/// <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) { return !value.ContainsAnyCoupons() ? this.Success(value) : this.Fail(value, "One or more coupons have already been added."); }
/// <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) { return(!value.ContainsAnyCoupons() ? this.Success(value) : this.Fail(value, "One or more coupons have already been added.")); }