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

70 lines
1.7 KiB
C#

using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.ViewModels;
using SushiBarDatabaseImplement.Storages;
namespace SushiBarBusinessLogic
{
public class PromotionLogic
{
private readonly PromotionStorage _promotionStorage;
public PromotionLogic(PromotionStorage PromotionStorage)
{
_promotionStorage = PromotionStorage;
}
public List<PromotionViewModel>? ReadList(PromotionSearchModel? Model)
{
var List = Model is null ? _promotionStorage.GetFullList() : _promotionStorage.GetFilteredList(Model);
if (List is null)
{
return null;
}
return List;
}
public PromotionViewModel? ReadElement(PromotionSearchModel? Model)
{
if (Model is null)
throw new ArgumentNullException(nameof(Model));
var Element = _promotionStorage.GetElement(Model);
if (Element is null)
{
return null;
}
return Element;
}
public bool Create(PromotionBindingModel Model)
{
if (_promotionStorage.Insert(Model) is null)
{
return false;
}
return true;
}
public bool Update(PromotionBindingModel Model)
{
if (_promotionStorage.Update(Model) is null)
{
return false;
}
return true;
}
public bool Delete(PromotionBindingModel Model)
{
if (_promotionStorage.Delete(Model) is null)
{
return false;
}
return true;
}
}
}