доделала 2 усл!!
This commit is contained in:
parent
ff37326332
commit
e1fa07bcb8
@ -97,7 +97,7 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Кол-во изделий должно быть больше 0", nameof(count));
|
||||
throw new ArgumentException("Количество изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddPlaneInShop. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
@ -108,6 +108,13 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
}
|
||||
_logger.LogInformation("AddPlaneInShop find. Id:{Id}", element.Id);
|
||||
|
||||
var countPlanes = element.ShopPlanes.Select(x => x.Value.Item2).Sum();
|
||||
if (element.MaxPlanes - countPlanes < count)
|
||||
{
|
||||
_logger.LogWarning("Shop is overflowed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (element.ShopPlanes.TryGetValue(plane.Id, out var pair))
|
||||
{
|
||||
element.ShopPlanes[plane.Id] = (plane, count + pair.Item2);
|
||||
@ -125,7 +132,8 @@ namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||
Address = element.Address,
|
||||
ShopName = element.ShopName,
|
||||
DateOpening = element.DateOpening,
|
||||
ShopPlanes = element.ShopPlanes
|
||||
ShopPlanes = element.ShopPlanes,
|
||||
MaxPlanes = element.MaxPlanes
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user