64 lines
1.4 KiB
C#
64 lines
1.4 KiB
C#
using SchoolScheduleContracts.BindingModels;
|
|
using SchoolScheduleContracts.BusinessLogicsContracts;
|
|
using SchoolScheduleContracts.SearchModels;
|
|
using SchoolScheduleContracts.StoragesContracts;
|
|
using SchoolScheduleContracts.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SchoolScheduleBusinessLogic
|
|
{
|
|
public class StudentLogic : IStudentLogic
|
|
{
|
|
private readonly IStudentStorage _studentStorage;
|
|
public StudentLogic(IStudentStorage studentStorage)
|
|
{
|
|
_studentStorage = studentStorage;
|
|
}
|
|
|
|
public List<StudentViewModel> ReadList(StudentSearchModel? model)
|
|
{
|
|
var list = model == null ? _studentStorage.GetFullList() :
|
|
_studentStorage.GetFilteredList(model);
|
|
return list;
|
|
}
|
|
|
|
public StudentViewModel? ReadElement(StudentSearchModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(model));
|
|
}
|
|
var element = _studentStorage.GetElement(model);
|
|
return element;
|
|
}
|
|
public bool Create(StudentBindingModel model)
|
|
{
|
|
if (_studentStorage.Insert(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public bool Update(StudentBindingModel model)
|
|
{
|
|
if (_studentStorage.Update(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public bool Delete(StudentBindingModel model)
|
|
{
|
|
if (_studentStorage.Delete(model) == null)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|