Mochalov D.V. LabWork05_Hard #13
@ -119,33 +119,15 @@ namespace LawFirmFileImplement.Implements
|
||||
var shop = source.Shops[i];
|
||||
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)
|
||||
{
|
||||
while (documents[j].Item2 > 0 && count > 0)
|
||||
{
|
||||
int tempItem2 = documents[j].Item2;
|
||||
tempItem2--;
|
||||
count--;
|
||||
documents[j] = (documents[j].Item1, tempItem2);
|
||||
}
|
||||
}
|
||||
|
||||
var min = Math.Min(doc.Value.Item2, count);
|
||||
documents[doc.Value.Item1.Id] = (doc.Value.Item1, doc.Value.Item2 - min);
|
||||
count -= min;
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
shop.Update(new ShopBindingModel
|
||||
{
|
||||
Id = shop.Id,
|
||||
Name = shop.Name,
|
||||
Adress = shop.Adress,
|
||||
OpeningDate = shop.OpeningDate,
|
||||
MaxCountDocuments = shop.MaxCountDocuments,
|
||||
ShopDocuments = documents
|
||||
});
|
||||
source.SaveShops();
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user