ПИбд-23 Салин Олег Алексеевич Лабораторная работа №2 (Усложненная) #8

Closed
Oleja123 wants to merge 14 commits from Lab2_Hard into Lab2
Showing only changes of commit dc0f2d7346 - Show all commits

View File

@ -108,21 +108,8 @@ namespace IceCreamShopListImplement.Implements
public bool CheckAvailability(int iceCreamId, int count)
{
foreach (var shop in _source.Shops)
{
foreach (var icecream in shop.ShopIceCreams)
{
if (icecream.Value.Item1.Id == iceCreamId)
{
count -= icecream.Value.Item2;
}
if (count <= 0)
{
break;
}
}
}
int minus = _source.Shops.Select(x => x.ShopIceCreams.Select(y => (y.Value.Item1.Id == iceCreamId ? y.Value.Item2 : 0)).Sum()).Sum();
count -= minus;
return count <= 0;
}