add getting employee by email in data

This commit is contained in:
Ivan Gutorov 2025-02-17 17:13:35 +04:00
parent 49eb971b5c
commit b05f91020b

View File

@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using System.Text.Json;
using System.Text.RegularExpressions;
using TheCyclopsContracts.BusinessLogicContracts;
using TheCyclopsContracts.DataModels;
using TheCyclopsContracts.Exceptions;
@ -64,6 +65,10 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
{
return _employeeStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
}
if (Regex.IsMatch(data, @"^\S+@\S+\.\S+$"))
{
return _employeeStorageContract.GetElementByEmail(data) ?? throw new ElementNotFoundException(data);
}
return _employeeStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data);
}