27 lines
845 B
C#
27 lines
845 B
C#
using TwoFromTheCaseContracts.Exceptions;
|
|
using TwoFromTheCaseContracts.Extensions;
|
|
using TwoFromTheCaseContracts.Infrastructure;
|
|
|
|
namespace TwoFromTheCaseContracts.DataModels;
|
|
|
|
public class WorkHistoryDataModel(string WorkId, double oldPrice) : IValidation
|
|
{
|
|
public string WorkId { get; private set; } = WorkId;
|
|
|
|
public double OldPrice { get; private set; } = oldPrice;
|
|
|
|
public DateTime ChangeDate { get; private set; } = DateTime.UtcNow;
|
|
|
|
public void Validate()
|
|
{
|
|
if (WorkId.IsEmpty())
|
|
throw new ValidationException("Field WorkId is empty");
|
|
|
|
if (!WorkId.IsGuid())
|
|
throw new ValidationException("The value in the field WorkId is not a unique identifier");
|
|
|
|
if (OldPrice <= 0)
|
|
throw new ValidationException("Field OldPrice is less than or equal to 0");
|
|
}
|
|
}
|