lab1hard-to-lab2hard #6
@ -119,12 +119,12 @@ namespace MotorPlantBusinessLogic.BusinessLogic
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool MakeSupply(ShopSearchModel model, IEngineModel dress, int count)
|
||||
public bool MakeSupply(ShopSearchModel model, IEngineModel engine, int count)
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
if (dress == null)
|
||||
throw new ArgumentNullException(nameof(dress));
|
||||
if (engine == null)
|
||||
throw new ArgumentNullException(nameof(engine));
|
||||
if (count <= 0)
|
||||
throw new ArgumentNullException("Количество должно быть положительным числом");
|
||||
|
||||
@ -132,15 +132,15 @@ namespace MotorPlantBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name);
|
||||
if (curModel == null)
|
||||
throw new ArgumentNullException(nameof(curModel));
|
||||
if (curModel.ShopEngines.TryGetValue(dress.Id, out var pair))
|
||||
if (curModel.ShopEngines.TryGetValue(engine.Id, out var pair))
|
||||
{
|
||||
curModel.ShopEngines[dress.Id] = (pair.Item1, pair.Item2 + count);
|
||||
_logger.LogInformation("Make Supply. Add Dress. DressName: {Name}. Count: {Count}", pair.Item1, count + pair.Item2);
|
||||
curModel.ShopEngines[engine.Id] = (pair.Item1, pair.Item2 + count);
|
||||
_logger.LogInformation("Make Supply. Add Engine. EngineName: {Name}. Count: {Count}", pair.Item1, count + pair.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
curModel.ShopEngines.Add(dress.Id, (dress, count));
|
||||
_logger.LogInformation("Make Supply. Add new Dress. DressName: {Name}. Count: {Count}", pair.Item1, count);
|
||||
curModel.ShopEngines.Add(engine.Id, (engine, count));
|
||||
_logger.LogInformation("Make Supply. Add new Engine. EngineName: {Name}. Count: {Count}", pair.Item1, count);
|
||||
}
|
||||
|
||||
return Update(new()
|
||||
|
Loading…
Reference in New Issue
Block a user