Compare commits
7 Commits
d528524f2c
...
726036b570
Author | SHA1 | Date | |
---|---|---|---|
726036b570 | |||
f6e1a161e0 | |||
f1f1d11272 | |||
eb48ee2c52 | |||
90dd93ef7a | |||
f997e6fc06 | |||
50c0cdc17e |
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user