This commit is contained in:
Salikh 2024-04-03 14:12:16 +04:00
parent ea5ba3cf1b
commit 071e0a01fc

View File

@ -119,12 +119,12 @@ namespace MotorPlantBusinessLogic.BusinessLogic
throw new InvalidOperationException("Магазин с таким названием уже есть"); throw new InvalidOperationException("Магазин с таким названием уже есть");
} }
} }
public bool MakeSupply(ShopSearchModel model, IEngineModel dress, int count) public bool MakeSupply(ShopSearchModel model, IEngineModel engine, int count)
{ {
if (model == null) if (model == null)
throw new ArgumentNullException(nameof(model)); throw new ArgumentNullException(nameof(model));
if (dress == null) if (engine == null)
throw new ArgumentNullException(nameof(dress)); throw new ArgumentNullException(nameof(engine));
if (count <= 0) if (count <= 0)
throw new ArgumentNullException("Количество должно быть положительным числом"); throw new ArgumentNullException("Количество должно быть положительным числом");
@ -132,15 +132,15 @@ namespace MotorPlantBusinessLogic.BusinessLogic
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name); _logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name);
if (curModel == null) if (curModel == null)
throw new ArgumentNullException(nameof(curModel)); 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); curModel.ShopEngines[engine.Id] = (pair.Item1, pair.Item2 + count);
_logger.LogInformation("Make Supply. Add Dress. DressName: {Name}. Count: {Count}", pair.Item1, count + pair.Item2); _logger.LogInformation("Make Supply. Add Engine. EngineName: {Name}. Count: {Count}", pair.Item1, count + pair.Item2);
} }
else else
{ {
curModel.ShopEngines.Add(dress.Id, (dress, count)); curModel.ShopEngines.Add(engine.Id, (engine, count));
_logger.LogInformation("Make Supply. Add new Dress. DressName: {Name}. Count: {Count}", pair.Item1, count); _logger.LogInformation("Make Supply. Add new Engine. EngineName: {Name}. Count: {Count}", pair.Item1, count);
} }
return Update(new() return Update(new()