70 lines
1.6 KiB
C#
70 lines
1.6 KiB
C#
using SushiBarContracts.BindingModels;
|
|
using SushiBarContracts.SearchModels;
|
|
using SushiBarContracts.ViewModels;
|
|
using SushiBarDatabaseImplement.Storages;
|
|
|
|
namespace SushiBarBusinessLogic
|
|
{
|
|
public class CookLogic
|
|
{
|
|
private readonly CookStorage _cookStorage;
|
|
|
|
public CookLogic(CookStorage CookStorage)
|
|
{
|
|
_cookStorage = CookStorage;
|
|
}
|
|
|
|
public List<CookViewModel>? ReadList(CookSearchModel? Model)
|
|
{
|
|
var List = Model is null ? _cookStorage.GetFullList() : _cookStorage.GetFilteredList(Model);
|
|
|
|
if (List is null)
|
|
{
|
|
return null;
|
|
}
|
|
return List;
|
|
}
|
|
|
|
public CookViewModel? ReadElement(CookSearchModel? Model)
|
|
{
|
|
if (Model is null)
|
|
throw new ArgumentNullException(nameof(Model));
|
|
|
|
var Element = _cookStorage.GetElement(Model);
|
|
|
|
if (Element is null)
|
|
{
|
|
return null;
|
|
}
|
|
return Element;
|
|
}
|
|
|
|
public bool Create(CookBindingModel Model)
|
|
{
|
|
if (_cookStorage.Insert(Model) is null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool Update(CookBindingModel Model)
|
|
{
|
|
if (_cookStorage.Update(Model) is null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool Delete(CookBindingModel Model)
|
|
{
|
|
if (_cookStorage.Delete(Model) is null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|