diff --git a/PimpMyRideProject/PimpMyRideContracts/DataModels/WorkerDataModel.cs b/PimpMyRideProject/PimpMyRideContracts/DataModels/WorkerDataModel.cs
index b9c1e7d..abab213 100644
--- a/PimpMyRideProject/PimpMyRideContracts/DataModels/WorkerDataModel.cs
+++ b/PimpMyRideProject/PimpMyRideContracts/DataModels/WorkerDataModel.cs
@@ -5,11 +5,14 @@ using PimpMyRideContracts.Infrastructure;
namespace PimpMyRideContracts.DataModels;
-public class WorkerDataModel(string workerId, string workerFIO, PostType postType) : IValidation
+public class WorkerDataModel(string workerId, string workerFIO, PostType postType, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
{
public string WorkerId { get; private set; } = workerId;
public string WorkerFIO { get; private set; } = workerFIO;
public PostType PostType { get; private set; } = postType;
+ public DateTime BirthDate { get; private set; } = birthDate;
+ public DateTime EmploymentDate { get; private set; } = employmentDate;
+ public bool IsDeleted { get; private set; } = isDeleted;
public void Validate()
{
@@ -24,5 +27,11 @@ public class WorkerDataModel(string workerId, string workerFIO, PostType postTyp
if (PostType == PostType.None)
throw new ValidationException("Field PostType is empty");
+
+ if (BirthDate.Date > DateTime.Now.AddYears(-16).Date)
+ throw new ValidationException("The date of employment cannot be less than the date of birth");
+
+ if ((EmploymentDate - BirthDate).TotalDays / 365 < 16)
+ throw new ValidationException($"Minors cannot be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})");
}
}
diff --git a/PimpMyRideProject/PimpMyRideContracts/PimpMyRideContracts.csproj b/PimpMyRideProject/PimpMyRideContracts/PimpMyRideContracts.csproj
index fa71b7a..ff4dbd8 100644
--- a/PimpMyRideProject/PimpMyRideContracts/PimpMyRideContracts.csproj
+++ b/PimpMyRideProject/PimpMyRideContracts/PimpMyRideContracts.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/PimpMyRideProject/PimpMyRideProject.sln b/PimpMyRideProject/PimpMyRideProject.sln
index 56e5c7e..8051701 100644
--- a/PimpMyRideProject/PimpMyRideProject.sln
+++ b/PimpMyRideProject/PimpMyRideProject.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35013.160
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PimpMyRideContracts", "PimpMyRideContracts\PimpMyRideContracts.csproj", "{DEFE53D7-DCB1-482C-8881-180886CEE5DB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PimpMyRideContracts", "PimpMyRideContracts\PimpMyRideContracts.csproj", "{DEFE53D7-DCB1-482C-8881-180886CEE5DB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PimpMyRideTests", "PimpMyRideTests\PimpMyRideTests.csproj", "{4ECD058E-8F44-452B-B9E0-7536CB42C98F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/PimpMyRideProject/PimpMyRideTests/DataModelsTests/CarDataModelTest.cs b/PimpMyRideProject/PimpMyRideTests/DataModelsTests/CarDataModelTest.cs
new file mode 100644
index 0000000..da219ab
--- /dev/null
+++ b/PimpMyRideProject/PimpMyRideTests/DataModelsTests/CarDataModelTest.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PimpMyRideTests.DataModelsTests;
+
+[TestFixture]
+internal class CarDataModelTest
+{
+ [Test]
+ public void Test()
+ {
+ var model = new { test = "sfdg" };
+ Assert.That(model, Is.Not.Null);
+ Assert.That(model.test, Is.EqualTo("sfdg"));
+ }
+}
diff --git a/PimpMyRideProject/PimpMyRideTests/PimpMyRideTests.csproj b/PimpMyRideProject/PimpMyRideTests/PimpMyRideTests.csproj
new file mode 100644
index 0000000..bc27194
--- /dev/null
+++ b/PimpMyRideProject/PimpMyRideTests/PimpMyRideTests.csproj
@@ -0,0 +1,28 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+