Пример #1
0
        public virtual Aggregation ToAggregation(catalogDto.Aggregation aggregationDto, string currentLanguage)
        {
            var result = new Aggregation
            {
                AggregationType = aggregationDto.AggregationType,
                Field           = aggregationDto.Field
            };

            if (aggregationDto.Items != null)
            {
                result.Items = aggregationDto.Items
                               .Select(i => i.ToAggregationItem(currentLanguage))
                               .ToArray();
            }

            if (aggregationDto.Labels != null)
            {
                result.Label =
                    aggregationDto.Labels.Where(l => string.Equals(l.Language, currentLanguage, StringComparison.OrdinalIgnoreCase))
                    .Select(l => l.Label)
                    .FirstOrDefault();
            }

            if (string.IsNullOrEmpty(result.Label))
            {
                result.Label = aggregationDto.Field;
            }

            return(result);
        }
        public static Aggregation ToAggregation(this catalogDto.Aggregation aggregationDto, string currentLanguage)
        {
            var result = new Aggregation
            {
                AggregationType = aggregationDto.AggregationType,
                Field           = aggregationDto.Field
            };

            var aggrItemIsVisbileSpec = new AggregationItemIsVisibleSpecification();

            if (aggregationDto.Items != null)
            {
                result.Items = aggregationDto.Items.Select(i => i.ToAggregationItem(result, currentLanguage))
                               .Where(x => aggrItemIsVisbileSpec.IsSatisfiedBy(x))
                               .Distinct().ToArray();
            }
            if (aggregationDto.Labels != null)
            {
                result.Label =
                    aggregationDto.Labels.Where(l => string.Equals(l.Language, currentLanguage, StringComparison.OrdinalIgnoreCase))
                    .Select(l => l.Label)
                    .FirstOrDefault();
            }

            if (string.IsNullOrEmpty(result.Label))
            {
                result.Label = aggregationDto.Field;
            }

            return(result);
        }
Пример #3
0
 public static Aggregation ToAggregation(this catalogDto.Aggregation aggregationDto, string currentLanguage)
 {
     return(CatalogConverterInstance.ToAggregation(aggregationDto, currentLanguage));
 }