правки
This commit is contained in:
parent
c94d96c6bc
commit
dc0f2d7346
@ -108,21 +108,8 @@ namespace IceCreamShopListImplement.Implements
|
|||||||
|
|
||||||
public bool CheckAvailability(int iceCreamId, int count)
|
public bool CheckAvailability(int iceCreamId, int count)
|
||||||
{
|
{
|
||||||
foreach (var shop in _source.Shops)
|
int minus = _source.Shops.Select(x => x.ShopIceCreams.Select(y => (y.Value.Item1.Id == iceCreamId ? y.Value.Item2 : 0)).Sum()).Sum();
|
||||||
{
|
count -= minus;
|
||||||
foreach (var icecream in shop.ShopIceCreams)
|
|
||||||
{
|
|
||||||
if (icecream.Value.Item1.Id == iceCreamId)
|
|
||||||
{
|
|
||||||
count -= icecream.Value.Item2;
|
|
||||||
}
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count <= 0;
|
return count <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user