Добавлена возможность добавлять изделия в магазин
This commit is contained in:
parent
fccf69ebd2
commit
475face563
@ -115,6 +115,10 @@ namespace ConfectioneryBusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddPastryInShop. ShopName:{ShopName}.Id:{ Id}",
|
||||
model.Name, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
@ -125,7 +129,22 @@ namespace ConfectioneryBusinessLogic
|
||||
}
|
||||
_logger.LogInformation("AddPastryInShop find. Id:{Id}", element.Id);
|
||||
|
||||
return element.Pastries.TryAdd(pastry.Id, (pastry, count));
|
||||
|
||||
if (element.Pastries.TryGetValue(pastry.Id, out var pair))
|
||||
{
|
||||
pair.Item2 += count;
|
||||
_logger.LogInformation(
|
||||
"AddPastryInShop. Has been added {count} {pastry} in {ShopName}",
|
||||
count, pastry.PastryName, element.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.Pastries[pastry.Id] = (pastry, count);
|
||||
_logger.LogInformation(
|
||||
"AddPastryInShop. Has been added {count} new Pastry {pastry} in {ShopName}",
|
||||
count, pastry.PastryName, element.Name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user