77 lines
2.5 KiB
C#
77 lines
2.5 KiB
C#
using EmployeeManagmentContracts.BindingModels;
|
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
|
using EmployeeManagmentContracts.SearchModels;
|
|
using EmployeeManagmentContracts.ViewModels;
|
|
using EmployeeManagmentDataBaseImplement.Models;
|
|
using EmployeeManagmentDataBaseImplement;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using EmployeeManagmentContracts.StoragesContracts;
|
|
using Microsoft.Extensions.Logging;
|
|
using EmployeeManagmentDataBaseImplement.Implements;
|
|
|
|
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
|
{
|
|
public class PhisicalPersonLogic : IPhisicalPersonLogic
|
|
{
|
|
private readonly ILogger<PhisicalPersonLogic> _logger;
|
|
private readonly IPhisicalPersonStorage _phisicalPersonStorage;
|
|
|
|
public PhisicalPersonLogic(ILogger<PhisicalPersonLogic> logger, IPhisicalPersonStorage phisicalPersonStorage)
|
|
{
|
|
_logger = logger;
|
|
_phisicalPersonStorage = phisicalPersonStorage;
|
|
}
|
|
|
|
public List<PhisicalPersonViewModel> GetFullList()
|
|
{
|
|
return _phisicalPersonStorage.GetFullList();
|
|
}
|
|
|
|
public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model)
|
|
{
|
|
return _phisicalPersonStorage.GetFilteredList(model);
|
|
}
|
|
|
|
public PhisicalPersonViewModel? GetElement(int id)
|
|
{
|
|
return _phisicalPersonStorage.GetElement(id);
|
|
}
|
|
|
|
public void Insert(PhisicalPersonViewModel model)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Surname))
|
|
{
|
|
throw new ArgumentException("Имя и фамилия обязательны для заполнения.");
|
|
}
|
|
|
|
_phisicalPersonStorage.Insert(model);
|
|
}
|
|
|
|
public void Update(PhisicalPersonViewModel model)
|
|
{
|
|
var element = _phisicalPersonStorage.GetElement(model.Id);
|
|
if (element == null)
|
|
{
|
|
throw new ArgumentException("Элемент не найден.");
|
|
}
|
|
|
|
_phisicalPersonStorage.Update(model);
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
var element = _phisicalPersonStorage.GetElement(id);
|
|
if (element == null)
|
|
{
|
|
throw new ArgumentException("Элемент не найден.");
|
|
}
|
|
|
|
_phisicalPersonStorage.Delete(id);
|
|
}
|
|
}
|
|
}
|