Пример #1
0
        public static Aggregation ToWebModel(this VirtoCommerceCatalogModuleWebModelAggregation aggregation, string currentLanguage)
        {
            var result = new Aggregation();
            result.InjectFrom<NullableAndEnumValueInjecter>(aggregation);

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

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

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

            return result;
        }
        public static Aggregation ToWebModel(this VirtoCommerceCatalogModuleWebModelAggregation aggregation)
        {
            var result = new Aggregation();
            result.InjectFrom<NullableAndEnumValueInjecter>(aggregation);

            if (aggregation.Items != null)
            {
                result.Items = aggregation.Items.Select(i => i.ToWebModel()).ToArray();
            }

            return result;
        }