70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using Contracts.BindingModels;
|
|
using Contracts.BusinessLogicContracts;
|
|
using Contracts.SearchModels;
|
|
using Contracts.StorageContracts;
|
|
using Contracts.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BusinessLogics.BusinessLogics
|
|
{
|
|
public class CategoryLogic : ICategoryLogic
|
|
{
|
|
private readonly ICategoryStorage _categoryStorage;
|
|
|
|
public CategoryLogic(ICategoryStorage categoryStorage)
|
|
{
|
|
_categoryStorage = categoryStorage;
|
|
}
|
|
|
|
public List<CategoryViewModel> ReadList()
|
|
{
|
|
return _categoryStorage.GetFullList();
|
|
}
|
|
|
|
public bool Create(CategoryBindingModel model)
|
|
{
|
|
CheckModel(model);
|
|
if (_categoryStorage.Insert(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public bool Update(CategoryBindingModel model)
|
|
{
|
|
CheckModel(model);
|
|
if (_categoryStorage.Update(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool Delete(CategoryBindingModel model)
|
|
{
|
|
CheckModel(model, false);
|
|
if (_categoryStorage.Delete(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void CheckModel(CategoryBindingModel model, bool withParams = true)
|
|
{
|
|
if (model == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(model));
|
|
}
|
|
if (!withParams)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|