using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.ViewModels; using EmployeeManagmentContracts.StoragesContracts; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class VacationLogic : IVacationLogic { private readonly ILogger _logger; private readonly IVacationStorage _vacationStorage; public VacationLogic(ILogger logger, IVacationStorage vacationStorage) { _logger = logger; _vacationStorage = vacationStorage; } public List GetFullList() { return _vacationStorage.GetFullList(); } public List GetFilteredList(VacationSearchModel model) { return _vacationStorage.GetFilteredList(model); } public VacationViewModel? GetElement(int id) { return _vacationStorage.GetElement(id); } public void Insert(VacationViewModel model) { if (model.EmployeeId == null) { throw new ArgumentException("Сотрудник обязательно должен быть указан."); } _vacationStorage.Insert(model); } public void Update(VacationViewModel model) { var element = _vacationStorage.GetElement(model.Id); if (element == null) { throw new ArgumentException("Отпуск не найден."); } _vacationStorage.Update(model); } public void Delete(int id) { var element = _vacationStorage.GetElement(id); if (element == null) { throw new ArgumentException("Отпуск не найден."); } _vacationStorage.Delete(id); } } }