Compare commits

..

7 Commits

Author SHA1 Message Date
726036b570 Merge branch 'LabWork02Hard' into LabWork03Hard 2023-03-19 12:39:55 +04:00
f6e1a161e0 Ошибка 2023-03-19 12:38:29 +04:00
f1f1d11272 Ошибка 2023-03-19 12:37:08 +04:00
eb48ee2c52 Ошибка 2023-03-19 12:35:15 +04:00
90dd93ef7a Модель 2023-03-19 12:23:06 +04:00
f997e6fc06 Модель 2023-03-19 12:20:57 +04:00
50c0cdc17e Штуки 2023-03-19 12:15:43 +04:00
4 changed files with 2 additions and 57 deletions

View File

@ -1,7 +1,6 @@
using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
namespace SushiBarContracts.StoragesContracts
{
@ -13,7 +12,5 @@ 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);
}
}

View File

@ -41,14 +41,8 @@ namespace SushiBarFileImplement.Implements
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var sushi in source.ListSushi)
{
if (sushi.Id == order.SushiId)
{
viewModel.SushiName = sushi.SushiName;
break;
}
}
var sushi = source.ListSushi.FirstOrDefault(x => x.Id == order.SushiId);
if (sushi != null) viewModel.SushiName = sushi.SushiName;
return viewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)

View File

@ -72,40 +72,5 @@ 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))
{
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;
}
}
}

View File

@ -2,7 +2,6 @@
using SushiBarContracts.SearchModels;
using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
using SushiBarListImplement.Models;
namespace SushiBarListImplement.Implements
@ -99,15 +98,5 @@ 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();
}
}
}