Ejemplo n.º 1
0
 private void PerformSizeAndColorSearch(Shirt shirt, SearchOptions options, List <Shirt> foundShirts)
 {
     foreach (var size in options.Sizes)
     {
         if (size == shirt.Size)
         {
             PerformColorSearch(shirt, options, foundShirts);
         }
     }
 }
Ejemplo n.º 2
0
 private void ProcessShirt(SearchOptions options, Shirt shirt)
 {
     if (options.Sizes == null || options.Sizes.Count == 0)
     {
         FilterWhenNoSizesGiven(options, shirt);
     }
     else
     {
         Filter(options, shirt);
     }
 }
Ejemplo n.º 3
0
 private IndexDocument ToIndexDocument(Shirt shirt)
 {
     return(new IndexDocument()
     {
         Id = shirt.Id,
         Fields =
         {
             { nameof(shirt.Color), shirt.Color?.Id.ToString() },
             { nameof(shirt.Size),  shirt.Size?.Id.ToString()  }
         }
     });
 }
Ejemplo n.º 4
0
        private void PerformSizeSearch(Shirt shirt, SearchOptions options, List <Shirt> foundShirts)
        {
            foreach (var size in options.Sizes)
            {
                if (size == shirt.Size)
                {
                    foundShirts.Add(shirt);

                    _sizeCounts[shirt.Size].Count++;
                    _colorCounts[shirt.Color].Count++;
                }
            }
        }
Ejemplo n.º 5
0
        private void PerformColorSearch(Shirt shirt, SearchOptions options, List <Shirt> foundShirts)
        {
            foreach (var color in options.Colors)
            {
                if (color == shirt.Color)
                {
                    foundShirts.Add(shirt);

                    _sizeCounts[shirt.Size].Count++;
                    _colorCounts[shirt.Color].Count++;
                }
            }
        }
Ejemplo n.º 6
0
        private void FilterWhenNoSizesGiven(SearchOptions options, Shirt shirt)
        {
            if (options.Colors.Contains(shirt.Color))
            {
                _resultsShirts.Add(shirt);

                _sizes.TryGetValue(shirt.Size, out var currentCount);
                _sizes[shirt.Size] = currentCount + 1;
            }

            _colors.TryGetValue(shirt.Color, out var currentColorCount);
            _colors[shirt.Color] = currentColorCount + 1;
        }
 private void UpdateMatchedShirtSizeCount(SearchResults results, Shirt shirt)
 {
     results.SizeCounts.Single(x => x.Size == shirt.Size).Count += 1;
 }
 private void UpdateMatchedShirtColorCount(SearchResults results, Shirt shirt)
 {
     results.ColorCounts.Single(x => x.Color == shirt.Color).Count += 1;
 }
Ejemplo n.º 9
0
 private ShirtKey CreateKey(Shirt shirt)
 {
     return(ShirtKey.Create(shirt.Size, shirt.Color));
 }
Ejemplo n.º 10
0
 private static bool ShirtColorMatches(Shirt shirt, IReadOnlyCollection <Color> optionsColors)
 {
     return(!FilterByColor(optionsColors) || optionsColors.SingleOrDefault(color => shirt.Color == color) != null);
 }
Ejemplo n.º 11
0
 private static bool ShirtSizeMatches(Shirt shirt, IReadOnlyCollection <Size> optionsSizes)
 {
     return(!FilterBySize(optionsSizes) || optionsSizes.SingleOrDefault(size => shirt.Size == size) != null);
 }