Ошибка
This commit is contained in:
parent
90dd93ef7a
commit
eb48ee2c52
@ -1,7 +1,6 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.StoragesContracts
|
||||
{
|
||||
@ -13,6 +12,5 @@ namespace SushiBarContracts.StoragesContracts
|
||||
SushiViewModel? Insert(SushiBindingModel model);
|
||||
SushiViewModel? Update(SushiBindingModel model);
|
||||
SushiViewModel? Delete(SushiBindingModel model);
|
||||
bool SellSushi(ISushiModel model, int count);
|
||||
}
|
||||
}
|
||||
|
@ -72,36 +72,5 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user