using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class EmployeeLogic : IEmployeeLogic { private readonly ILogger _logger; private readonly IEmployeeStorage _employeeStorage; public EmployeeLogic(ILogger logger, IEmployeeStorage employeeStorage) { _logger = logger; _employeeStorage = employeeStorage; } public List GetFullList() { return _employeeStorage.GetFullList(); } public List GetFilteredList(EmployeeSearchModel model) { return _employeeStorage.GetFilteredList(model); } public EmployeeViewModel? GetElement(int id) { return _employeeStorage.GetElement(id); } public void Insert(EmployeeViewModel model) { if (string.IsNullOrWhiteSpace(model.NameJob)) { throw new ArgumentException("Название должности обязательно для заполнения."); } _employeeStorage.Insert(model); } public void Update(EmployeeViewModel model) { var element = _employeeStorage.GetElement(model.Id); if (element == null) { throw new ArgumentException("Сотрудник не найден."); } _employeeStorage.Update(model); } public void Delete(int id) { var element = _employeeStorage.GetElement(id); if (element == null) { throw new ArgumentException("Сотрудник не найден."); } _employeeStorage.Delete(id); } } }