/// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
                return null;

            var collectionKey = source.ToString();

            if (collectionKey.IsNullOrWhiteSpace())
            {

                var defaultCollection = merchello.Query.Product.Search(1, 10)
                    .Items.Select(x => merchello.TypedProductContent(((ProductDisplay)x).Key));

                return new ProductContentListView(Guid.Empty, defaultCollection);
            }

            try
            {
                var key = new Guid(collectionKey);
                return new ProductContentListView(key, merchello.TypedProductContentFromCollection(key));
            }
            catch (Exception ex)
            {
                MultiLogHelper.Error<ProductDisplayValueConverter>("Failed to Convert ProductDisplay property", ex);
                return null;
            }
        }
示例#2
0
        /// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
            {
                return(null);
            }

            var collectionKey = source.ToString();

            if (collectionKey.IsNullOrWhiteSpace())
            {
                var defaultCollection = merchello.Query.Product.TypedProductContentSearch(1, 10);

                return(new ProductContentListView(Guid.Empty, defaultCollection));
            }

            try
            {
                var key = new Guid(collectionKey);
                return(new ProductContentListView(key, merchello.TypedProductContentFromCollection(key)));
            }
            catch (Exception ex)
            {
                MultiLogHelper.Error <ProductDisplayValueConverter>("Failed to Convert ProductDisplay property", ex);
                return(null);
            }
        }
 /// <summary>
 /// Gets the collection of all products in the collection.
 /// </summary>
 /// <param name="value">
 /// The <see cref="ProductCollection"/>.
 /// </param>
 /// <param name="merchelloHelper">
 /// The <see cref="MerchelloHelper"/>.
 /// </param>
 /// <param name="page">
 /// The page.
 /// </param>
 /// <param name="itemsPerPage">
 /// Number of items per page.
 /// </param>
 /// <param name="sortBy">
 /// The sort field.
 /// </param>
 /// <param name="sortDirection">
 /// The sort direction.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IProductContent}"/>.
 /// </returns>
 internal static IEnumerable <IProductContent> GetProducts(
     this ProductCollection value,
     MerchelloHelper merchelloHelper,
     long page,
     long itemsPerPage,
     string sortBy = "",
     SortDirection sortDirection = SortDirection.Ascending)
 {
     return(merchelloHelper.TypedProductContentFromCollection(
                value.CollectionKey,
                page,
                itemsPerPage,
                sortBy,
                sortDirection));
 }
        /// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
                return null;

            var collectionKey = source.ToString();

            try
            {
                var key = new Guid(collectionKey);
                return merchello.TypedProductContentFromCollection(key);
            }
            catch (Exception ex)
            {
                LogHelper.Error<ProductDisplayValueConverter>("Failed to Convert ProductDisplay property", ex);
                return null;
            }
        }
示例#5
0
        /// <summary>
        /// The convert data to source.
        /// </summary>
        /// <param name="propertyType">
        /// The property type.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
        {
            var merchello = new MerchelloHelper();

            if (source == null)
            {
                return(null);
            }

            var collectionKey = source.ToString();

            try
            {
                var key = new Guid(collectionKey);
                return(merchello.TypedProductContentFromCollection(key));
            }
            catch (Exception ex)
            {
                LogHelper.Error <ProductDisplayValueConverter>("Failed to Convert ProductDisplay property", ex);
                return(null);
            }
        }
 /// <summary>
 /// Gets the collection of all products in the collection.
 /// </summary>
 /// <param name="value">
 /// The <see cref="ProductCollection"/>.
 /// </param>
 /// <param name="merchelloHelper">
 /// The <see cref="MerchelloHelper"/>.
 /// </param>
 /// <param name="page">
 /// The page.
 /// </param>
 /// <param name="itemsPerPage">
 /// Number of items per page.
 /// </param>
 /// <param name="sortBy">
 /// The sort field.
 /// </param>
 /// <param name="sortDirection">
 /// The sort direction.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IProductContent}"/>.
 /// </returns>
 internal static IEnumerable<IProductContent> GetProducts(
     this ProductCollection value,
     MerchelloHelper merchelloHelper,
     long page,
     long itemsPerPage,
     string sortBy = "",
     SortDirection sortDirection = SortDirection.Ascending)
 {
     return merchelloHelper.TypedProductContentFromCollection(
         value.CollectionKey,
         page,
         itemsPerPage,
         sortBy,
         sortDirection);
 }