PIbd-21. Rodionov I.A. Lab work 05. Hard #13

Closed
ILRodionov wants to merge 19 commits from lab5_hard into lab5_base
Showing only changes of commit d7ecf984f1 - Show all commits

View File

@ -88,9 +88,8 @@ namespace IceCreamShopFileImplement.Implements
public bool MakeSale(IIceCreamModel model, int count)
{
var iceCream = source.IceCreams.FirstOrDefault(x => x.Id == model.Id);
int countInShops = source.Shops.Select(x => x.ShopIceCreams.Any(y => y.Key == model.Id)
? x.ShopIceCreams.Where(y => y.Key == model.Id).First().Value.Item2 : 0).Sum();
int countInShops = source.Shops.SelectMany(x => x.ShopIceCreams).Sum(y => y.Key == model.Id ? y.Value.Item2 : 0);
if (iceCream == null || countInShops < count)
{
return false;