public virtual Aggregation ToAggregation(searchDto.Aggregation aggregationDto, string currentLanguage) { var result = ServiceLocator.Current.GetInstance <CatalogFactory>().CreateAggregation(); result.InjectFrom <NullableAndEnumValueInjecter>(aggregationDto); 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 virtual Aggregation ToAggregation(searchDto.Aggregation aggregationDto, string currentLanguage) { var result = new Aggregation(); result.AggregationType = aggregationDto.AggregationType; result.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 searchDto.Aggregation aggregationDto, string currentLanguage) { return(CatalogConverterInstance.ToAggregation(aggregationDto, currentLanguage)); }