PIbd-22_Shabunov_O.A._SushiBar/SushiBarBusinessLogic/ChequeLogic.cs
2024-05-16 17:26:24 +04:00

52 lines
1.3 KiB
C#

using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels;
using SushiBarDatabaseImplement.Storages;
namespace SushiBarBusinessLogic
{
public class ChequeLogic
{
private readonly ChequeStorage _chequeStorage;
public ChequeLogic(ChequeStorage ChequeStorage)
{
_chequeStorage = ChequeStorage;
}
public List<ChequeViewModel>? ReadList(ChequeSearchModel? Model)
{
var List = Model is null ? _chequeStorage.GetFullList() : _chequeStorage.GetFilteredList(Model);
if (List is null)
{
return null;
}
return List;
}
public ChequeViewModel? ReadElement(ChequeSearchModel? Model)
{
if (Model is null)
throw new ArgumentNullException(nameof(Model));
var Element = _chequeStorage.GetElement(Model);
if (Element is null)
{
return null;
}
return Element;
}
public bool CreateCheque(ChequeBindingModel Model)
{
if (_chequeStorage.Insert(Model) is null)
{
return false;
}
return true;
}
}
}