Пример #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 = dto.Values.IsNullOrWhiteSpace()
                             ? Enumerable.Empty <KeyValuePair <string, string> >()
                             : JsonConvert.DeserializeObject <IEnumerable <KeyValuePair <string, string> > >(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);
        }
Пример #2
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);
        }