Изменена логика пополнения магазина с учетом его максимальной вместимости
This commit is contained in:
parent
35ee01f552
commit
de6f3af8df
@ -82,26 +82,37 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
|
_logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
|
||||||
|
|
||||||
if (shopElement.ShopDocuments.TryGetValue(document.Id, out var sameDocument))
|
var countDocs = 0;
|
||||||
|
foreach (var doc in shopElement.ShopDocuments)
|
||||||
{
|
{
|
||||||
shopElement.ShopDocuments[document.Id] = (document, sameDocument.Item2 + count);
|
countDocs += doc.Value.Item2;
|
||||||
_logger.LogInformation("Same document found by supply. Added {0} of {1} in {2} shop", count, document.DocumentName, shopElement.Name);
|
}
|
||||||
|
if (shopElement.MaxCountDocuments - countDocs >= count)
|
||||||
|
{
|
||||||
|
if (shopElement.ShopDocuments.TryGetValue(document.Id, out var sameDocument))
|
||||||
|
{
|
||||||
|
shopElement.ShopDocuments[document.Id] = (document, sameDocument.Item2 + count);
|
||||||
|
_logger.LogInformation("Same document found by supply. Added {0} of {1} in {2} shop", count, document.DocumentName, shopElement.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shopElement.ShopDocuments[document.Id] = (document, count);
|
||||||
|
_logger.LogInformation("New document added by supply. Added {0} of {1} in {2} shop", count, document.DocumentName, shopElement.Name);
|
||||||
|
}
|
||||||
|
_shopStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = shopElement.Id,
|
||||||
|
Name = shopElement.Name,
|
||||||
|
Adress = shopElement.Adress,
|
||||||
|
OpeningDate = shopElement.OpeningDate,
|
||||||
|
ShopDocuments = shopElement.ShopDocuments
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shopElement.ShopDocuments[document.Id] = (document, count);
|
_logger.LogWarning("Required shop is overflowed");
|
||||||
_logger.LogInformation("New document added by supply. Added {0} of {1} in {2} shop", count, document.DocumentName, shopElement.Name);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_shopStorage.Update(new()
|
|
||||||
{
|
|
||||||
Id = shopElement.Id,
|
|
||||||
Name = shopElement.Name,
|
|
||||||
Adress = shopElement.Adress,
|
|
||||||
OpeningDate = shopElement.OpeningDate,
|
|
||||||
ShopDocuments = shopElement.ShopDocuments
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user