Skip to content

Commit

Permalink
fix: crash with unknown products
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Jan 27, 2024
1 parent bccb271 commit 397ce64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public BestProductValueCalculator(IValueCalculator valueCalculator)
_valueCalculator = valueCalculator;
}

public Product GetProductWithMostValue(IEnumerable<Product> products)
public Product? GetProductWithMostValue(IEnumerable<Product> products)
{
return products.OrderByDescending(product => _valueCalculator.CalculateValue(product)).First();
return products.MaxBy(product => _valueCalculator.CalculateValue(product));
}
}
2 changes: 1 addition & 1 deletion GrocyScanner.Core/ValueCalculator/IBestValueCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace GrocyScanner.Core.ValueCalculator;

public interface IBestValueCalculator
{
public Product GetProductWithMostValue(IEnumerable<Product> products);
public Product? GetProductWithMostValue(IEnumerable<Product> products);
}

0 comments on commit 397ce64

Please sign in to comment.