Методы переделаны в метод

This commit is contained in:
Павел Сорокин 2023-03-09 14:38:11 +04:00
parent bf9de0295a
commit c1075ad46a
3 changed files with 1 additions and 12 deletions

View File

@ -18,7 +18,6 @@ namespace ShipyardContracts.StoragesContracts
ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model);
bool ShipsAreAvailable(IShipModel model, int requiredQuantity);
bool SellShips(IShipModel model, int count);
}
}

View File

@ -83,14 +83,9 @@ namespace ShipyardFileImplement.Implements
source.SaveShops();
return shop.GetViewModel;
}
public bool ShipsAreAvailable(IShipModel model, int requiredQuantity)
{
int availableQuantity = source.Shops.Select(x => x.Ships.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum();
return availableQuantity >= requiredQuantity;
}
public bool SellShips(IShipModel model, int count)
{
if (!ShipsAreAvailable(model, count))
if (source.Shops.Select(x => x.Ships.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum()<count)
{
return false;
}

View File

@ -110,11 +110,6 @@ namespace ShipyardListImplement.Implements
}
return null;
}
public bool ShipsAreAvailable(IShipModel model, int requiredQuantity)
{
throw new NotImplementedException();
}
public bool SellShips(IShipModel model, int count)
{
throw new NotImplementedException();