using IcecreamVan.Extensions; using IcecreamVan.Infrastructure; using IcecreamVan.Exceptions; namespace IcecreamVan.DataModels; public class ProductHistoryDataModel(string productId, double oldPrice) : IValidation { public string ProductId { get; private set; } = productId; public double OldPrice { get; private set; } = oldPrice; public DateTime ChangeDate { get; private set; } = DateTime.UtcNow; public void Validate() { if (ProductId.IsEmpty()) throw new ValidationException("Field Product ID is empty"); if (!ProductId.IsGuid()) throw new ValidationException("The value is NOT a unique identifier"); if (OldPrice <= 0) throw new ValidationException("Field OldPrice is less than or equal to 0"); } }