From b05f91020bd00d9a0cc23f913e7f469080ef52a8 Mon Sep 17 00:00:00 2001 From: Ivan Gutorov Date: Mon, 17 Feb 2025 17:13:35 +0400 Subject: [PATCH] add getting employee by email in data --- .../Implementations/EmployeeBusinessLogicContract.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TheCyclopsProject/TheCyclopsBusinessLogic/Implementations/EmployeeBusinessLogicContract.cs b/TheCyclopsProject/TheCyclopsBusinessLogic/Implementations/EmployeeBusinessLogicContract.cs index d6545da..d275d3c 100644 --- a/TheCyclopsProject/TheCyclopsBusinessLogic/Implementations/EmployeeBusinessLogicContract.cs +++ b/TheCyclopsProject/TheCyclopsBusinessLogic/Implementations/EmployeeBusinessLogicContract.cs @@ -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); }