Отрефакторено пополнение магазина

This commit is contained in:
Данияр Аглиуллов 2023-02-20 20:37:47 +04:00
parent 680fd6b501
commit ddd14fe064

View File

@ -133,21 +133,13 @@ namespace ConfectioneryBusinessLogic
}
_logger.LogInformation("AddPastryInShop find. Id:{Id}", element.Id);
if (element.Pastries.TryGetValue(pastry.Id, out var pair))
{
element.Pastries[pastry.Id] = (pastry, count + pair.Item2);
_logger.LogInformation(
"AddPastryInShop. Has been added {count} {pastry} in {ShopName}",
var prevCount = element.Pastries.GetValueOrDefault(pastry.Id, (pastry, 0)).Item2;
element.Pastries[pastry.Id] = (pastry, prevCount + 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);
}
_shopStorage.Update(new()
{
Id = element.Id,