32 lines
994 B
C#
32 lines
994 B
C#
using MagicCarpetContracts.Exceptions;
|
|
using MagicCarpetContracts.Extensions;
|
|
using MagicCarpetContracts.Infrastructure;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MagicCarpetContracts.DataModels;
|
|
|
|
public class SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary) : IValidation
|
|
{
|
|
public string EmployeeId { get; private set; } = employeeId;
|
|
|
|
public DateTime SalaryDate { get; private set; } = salaryDate;
|
|
|
|
public double Salary { get; private set; } = employeeSalary;
|
|
|
|
public void Validate()
|
|
{
|
|
if (EmployeeId.IsEmpty())
|
|
throw new ValidationException("Field EmployeeId is empty");
|
|
|
|
if (!EmployeeId.IsGuid())
|
|
throw new ValidationException("The value in the field EmployeeId is not a unique identifier");
|
|
|
|
if (Salary <= 0)
|
|
throw new ValidationException("Field Salary is less than or equal to 0");
|
|
}
|
|
}
|