Merge branch 'LabWork02_Hard' into LabWork03_Hard
This commit is contained in:
commit
50a53fe8f4
@ -119,33 +119,15 @@ namespace LawFirmFileImplement.Implements
|
|||||||
var shop = source.Shops[i];
|
var shop = source.Shops[i];
|
||||||
var documents = shop.ShopDocuments;
|
var documents = shop.ShopDocuments;
|
||||||
|
|
||||||
for (int j =1; j < documents.Count + 1; j++)
|
foreach (var doc in documents.Where(x => x.Value.Item1.Id == document.Id))
|
||||||
{
|
{
|
||||||
if (documents[j].Item1.Id == document.Id)
|
var min = Math.Min(doc.Value.Item2, count);
|
||||||
{
|
documents[doc.Value.Item1.Id] = (doc.Value.Item1, doc.Value.Item2 - min);
|
||||||
while (documents[j].Item2 > 0 && count > 0)
|
count -= min;
|
||||||
{
|
|
||||||
int tempItem2 = documents[j].Item2;
|
|
||||||
tempItem2--;
|
|
||||||
count--;
|
|
||||||
documents[j] = (documents[j].Item1, tempItem2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
{
|
{
|
||||||
shop.Update(new ShopBindingModel
|
break;
|
||||||
{
|
|
||||||
Id = shop.Id,
|
|
||||||
Name = shop.Name,
|
|
||||||
Adress = shop.Adress,
|
|
||||||
OpeningDate = shop.OpeningDate,
|
|
||||||
MaxCountDocuments = shop.MaxCountDocuments,
|
|
||||||
ShopDocuments = documents
|
|
||||||
});
|
|
||||||
source.SaveShops();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user