2 лаба усл правки

This commit is contained in:
a.puchkina 2024-05-23 22:48:05 +04:00
parent 8a96f638b3
commit fdce636b56
2 changed files with 8 additions and 1 deletions

5
.gitignore vendored
View File

@ -14,6 +14,11 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# dll файлы
*.dll
/TravelCompany/ImplementationExtensions
# Mono auto generated files
mono_crash.*

View File

@ -88,7 +88,9 @@ namespace TravelCompanyFileImplement.Implements
public bool MakeSale(ITravelModel model, int count)
{
var travel = source.Travels.FirstOrDefault(x => x.Id == model.Id);
int countInShops = source.Shops.SelectMany(x => x.ShopTravels).Sum(y => y.Key == model.Id ? y.Value.Item2 : 0);
int countInShops = source.Shops.SelectMany(x => x.ShopTravels)
.Where(y => y.Value.Item1.Id == model.Id)
.Sum(y => y.Value.Item2);
if (travel == null || countInShops < count)
{