From 50c0cdc17eb75b703eac7a8a10dfdb1fb78577ae Mon Sep 17 00:00:00 2001 From: dasha Date: Sun, 19 Mar 2023 12:15:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A8=D1=82=D1=83=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoragesContracts/ISushiStorage.cs | 1 - .../SushiBarFileImplement/Implements/SushiStorage.cs | 12 ++++-------- .../SushiBarListImplement/Implements/SushiStorage.cs | 5 ----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs index f968fb1..38370ea 100644 --- a/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs +++ b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs @@ -13,7 +13,6 @@ namespace SushiBarContracts.StoragesContracts SushiViewModel? Insert(SushiBindingModel model); SushiViewModel? Update(SushiBindingModel model); SushiViewModel? Delete(SushiBindingModel model); - bool HasSushi(ISushiModel model, int needCount); bool SellSushi(ISushiModel model, int count); } } diff --git a/SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs b/SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs index 04399ba..522b360 100644 --- a/SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs +++ b/SushiBar/SushiBarFileImplement/Implements/SushiStorage.cs @@ -72,17 +72,13 @@ namespace SushiBarFileImplement.Implements } return null; } - public bool HasSushi(ISushiModel sushi, int needCount) - { - var temp = source.Shops - .Select(x => x.ListSushi - .FirstOrDefault(x => x.Key == sushi.Id).Value.Item2).Sum(); - return temp >= needCount; - } public bool SellSushi(ISushiModel model, int count) { - if (!HasSushi(model, count)) + var temp = source.Shops + .Select(x => x.ListSushi + .FirstOrDefault(x => x.Key == model.Id).Value.Item2).Sum(); + if (temp < count) { return false; } diff --git a/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs b/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs index a57a5f8..a2bd782 100644 --- a/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/SushiStorage.cs @@ -100,11 +100,6 @@ namespace SushiBarListImplement.Implements return null; } - public bool HasSushi(ISushiModel model, int needCount) - { - throw new NotImplementedException(); - } - public bool SellSushi(ISushiModel model, int count) { throw new NotImplementedException();