Ошибка

This commit is contained in:
dasha 2023-03-19 12:35:15 +04:00
parent 90dd93ef7a
commit eb48ee2c52
2 changed files with 0 additions and 33 deletions

View File

@ -1,7 +1,6 @@
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels; using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
namespace SushiBarContracts.StoragesContracts namespace SushiBarContracts.StoragesContracts
{ {
@ -13,6 +12,5 @@ namespace SushiBarContracts.StoragesContracts
SushiViewModel? Insert(SushiBindingModel model); SushiViewModel? Insert(SushiBindingModel model);
SushiViewModel? Update(SushiBindingModel model); SushiViewModel? Update(SushiBindingModel model);
SushiViewModel? Delete(SushiBindingModel model); SushiViewModel? Delete(SushiBindingModel model);
bool SellSushi(ISushiModel model, int count);
} }
} }

View File

@ -72,36 +72,5 @@ namespace SushiBarFileImplement.Implements
} }
return null; return null;
} }
public bool SellSushi(ISushiModel model, int count)
{
var temp = source.Shops
.Select(x => x.ListSushi
.FirstOrDefault(x => x.Key == model.Id).Value.Item2).Sum();
if (temp < count)
{
return false;
}
foreach (var shop in source.Shops.Where(x => x.ListSushi.ContainsKey(model.Id)))
{
if (shop.ListSushi[model.Id].Item2 < count)
{
shop.ListSushi[model.Id] = (shop.ListSushi[model.Id].Item1, 0);
count -= shop.ListSushi[model.Id].Item2;
}
else
{
shop.ListSushi[model.Id] = (shop.ListSushi[model.Id].Item1,
shop.ListSushi[model.Id].Item2 - count);
count -= count;
}
if (count <= 0)
{
return true;
}
}
return true;
}
} }
} }