26 lines
781 B
C#
Raw Normal View History

2025-02-26 17:00:16 +04:00
using SnowMaidenContracts.Exceptions;
using SnowMaidenContracts.Extensions;
using SnowMaidenContracts.Infrastructure;
namespace SnowMaidenContracts.DataModels;
public class SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary) : IValidation
{
public string WorkerId { get; private set; } = workerId;
public DateTime SalaryDate { get; private set; } = salaryDate;
public double Salary { get; private set; } = workerSalary;
public void Validate()
{
if (WorkerId.IsEmpty())
throw new ValidationException("Field Worker ID is empty");
if (!WorkerId.IsGuid())
throw new ValidationException("The Worker ID value is NOT a unique identifier");
if (Salary <= 0)
throw new ValidationException("Field Salary is less than or equal to 0");
}
}