28 lines
880 B
C#
Raw Normal View History

2025-02-17 17:06:55 +04:00
using TheCyclopsContracts.Exceptions;
using TheCyclopsContracts.Extensions;
using TheCyclopsContracts.Infrastructure;
namespace TheCyclopsContracts.DataModels;
public class SupplyDataModel(string id, DateTime supplyDate,
List<SupplyComponentDataModel> components) : IValidation
{
public string Id { get; private set; } = id;
public DateTime SupplyDate { get; private set; } = supplyDate;
public List<SupplyComponentDataModel> Components { get; private set; } = components;
public void Validate()
{
if (Id.IsEmpty())
throw new ValidationException("Field Id is empty");
if (!Id.IsGuid())
throw new ValidationException("The value in the field Id is not a unique identifier");
if ((Components?.Count ?? 0) == 0)
throw new ValidationException("The supply must include components");
}
}