Ejemplo n.º 1
0
        /// <summary>
        /// Builds <see cref="IProductVariantDetachedContent"/>.
        /// </summary>
        /// <param name="dto">
        /// The dto.
        /// </param>
        /// <returns>
        /// The <see cref="IProductVariantDetachedContent"/>.
        /// </returns>
        public IProductVariantDetachedContent BuildEntity(ProductVariantDetachedContentDto dto)
        {
            var detachedContentType = _detachedContentTypeFactory.Value.BuildEntity(dto.DetachedContentType);

            var values = DetachedContentValuesSerializationHelper.Deserialize(dto.Values);

            var valuesCollection = new DetachedDataValuesCollection(values);

            var detachedContent = new ProductVariantDetachedContent(
                dto.ProductVariantKey,
                detachedContentType,
                dto.CultureName,
                valuesCollection)
            {
                Key           = dto.Key,
                Slug          = dto.Slug ?? string.Empty,
                TemplateId    = dto.TemplateId ?? 0,
                CanBeRendered = dto.CanBeRendered,
                CreateDate    = dto.CreateDate,
                UpdateDate    = dto.UpdateDate
            };

            detachedContent.ResetDirtyProperties();

            return(detachedContent);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Builds the <see cref="IProductAttribute" />.
        /// </summary>
        /// <param name="dto">
        ///     The dto.
        /// </param>
        /// <returns>
        ///     The <see cref="IProductAttribute" />.
        /// </returns>
        public IProductAttribute BuildEntity(ProductAttributeDto dto)
        {
            var values = DetachedContentValuesSerializationHelper.Deserialize(dto.DetachedContentValues);

            var valuesCollection = new DetachedDataValuesCollection(values);

            var attribute = new ProductAttribute(dto.Name, dto.Sku)
            {
                Key                = dto.Key,
                OptionKey          = dto.OptionKey,
                SortOrder          = dto.SortOrder,
                IsDefaultChoice    = dto.IsDefaultChoice,
                DetachedDataValues = valuesCollection,
                UpdateDate         = dto.UpdateDate,
                CreateDate         = dto.CreateDate
            };

            return(attribute);
        }