diff --git a/ConfectionaryBusinessLogic/ShopLogic.cs b/ConfectionaryBusinessLogic/ShopLogic.cs index 36d618a..b6fb992 100644 --- a/ConfectionaryBusinessLogic/ShopLogic.cs +++ b/ConfectionaryBusinessLogic/ShopLogic.cs @@ -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,