コード例 #1
0
 /// <summary>
 /// Gets the <see cref="ProductVariantDisplay"/> with matching with attributes from the product.
 /// </summary>
 /// <param name="product">
 /// The product.
 /// </param>
 /// <param name="optionChoices">
 /// The option choices.
 /// </param>
 /// <returns>
 /// The <see cref="ProductVariantDisplay"/>.
 /// </returns>        
 public static ProductVariantDisplay GetProductVariantDisplayWithAttributes(this ProductDisplay product, Guid[] optionChoices)
 {
     return
         product.ProductVariants.FirstOrDefault(
             x =>
             x.Attributes.Count() == optionChoices.Count()
             && optionChoices.All(key => x.Attributes.FirstOrDefault(att => att.Key == key) != null));
 }
コード例 #2
0
 public void SendMessage(string subject, string body, Guid authorID, Guid[] recipientIDs)
 {
     var recipients = _repository.FindAllBy<Traveler>(t => recipientIDs.Contains(t.TravelerID));
     if (recipients == null || recipients.Count() != recipientIDs.Count()) throw new TravelerNotFoundException();
     Traveler author = _repository.FindBy<Traveler>(r => r.TravelerID == authorID);
     if (author == null) throw new TravelerNotFoundException();
     Message message = MessageFactory.CreateMessageFrom(subject, body, author, recipients);
     _repository.Add<Message>(message);
     _repository.Commit();
 }
コード例 #3
0
 private IEnumerable<Shipment> GetDummyShipments(Guid[] keys)
 {
     var shipmentKeys = new[] {Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()};
     for (int i = 0; i < keys.Count(); i++)
     {
         yield return new Shipment
         {
             Key = keys[i],
             AffiliateKey = Guid.NewGuid(),
             ShipmentTypeKey = shipmentKeys[i],
             Price = 12.23M*(i + 1),
             ReceiverFirstName = string.Format("Receiver {0} FirstName", i),
             ReceiverLastName = string.Format("Receiver {0} Lastname", i),
             ReceiverAddress = string.Format("Receiver {0} Address", i),
             ReceiverCity = string.Format("Receiver {0} City", i),
             ReceiverCountry = string.Format("Receiver {0} Country", i),
             ReceiverPhone = string.Format("Receiver {0} Phone", i),
             ReceiverZipCode = "12345",
             ReceiverEmail = "*****@*****.**",
             CreatedOn = DateTime.Now,
             ShipmentType = new ShipmentType
             {
                 Key = shipmentKeys[i],
                 CompanyName = "Nile",
                 Price = 4.19M,
                 CreatedOn = DateTime.Now,
             },
             ShipmentStates = new List<ShipmentState>
             {
                 new ShipmentState
                 {
                     Key = Guid.NewGuid(),
                     ShipmentKey = keys[i],
                     Status = ShipmentStatus.Ordered
                 },
                 new ShipmentState
                 {
                     Key = Guid.NewGuid(),
                     ShipmentKey = keys[i],
                     Status = ShipmentStatus.Scheduled
                 }
             }
         };
     }
 }
コード例 #4
0
ファイル: MerchelloHelper.cs プロジェクト: EricMunn/Merchello
 /// <summary>
 /// Get a product variant from a product by it's collection of attributes
 /// </summary>
 /// <param name="productKey">The product key</param>
 /// <param name="attributeKeys">The option choices (attributeKeys)</param>
 /// <returns>The <see cref="ProductVariantDisplay"/></returns>
 public ProductVariantDisplay GetProductVariantWithAttributes(Guid productKey, Guid[] attributeKeys)
 {
     var product = Query.Product.GetByKey(productKey);
     return product.ProductVariants.FirstOrDefault(x => x.Attributes.Count() == attributeKeys.Count() && attributeKeys.All(key => x.Attributes.FirstOrDefault(att => att.Key == key) != null));
 }
コード例 #5
0
        /// <summary>
        /// Gets the <see cref="ProductVariantDisplay"/> with matching with attributes from the product.
        /// </summary>
        /// <param name="product">
        /// The product.
        /// </param>
        /// <param name="optionChoices">
        /// The option choices.
        /// </param>
        /// <returns>
        /// The <see cref="ProductVariantDisplay"/>.
        /// </returns>        
        public static IProductVariantContent GetProductVariantDisplayWithAttributes(this IProductContent product, Guid[] optionChoices)
        {
            var variant =
                product.ProductVariants.FirstOrDefault(
                    x =>
                    x.Attributes.Count() == optionChoices.Count()
                    && optionChoices.All(key => x.Attributes.FirstOrDefault(att => att.Key == key) != null));

            if (variant == null)
            {
                MultiLogHelper.Debug(typeof(ProductContentExtensions), "Could not find IProductVariantContent with keys matching choices in optionChoices array.");
            }

            return variant;
        }