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 TourHistoryDataModel(string tourId, double oldPrice) : IValidation { public string TourId { get; private set; } = tourId; public double OldPrice { get; private set; } = oldPrice; public DateTime ChangeDate { get; private set; } = DateTime.UtcNow; public void Validate() { if (TourId.IsEmpty()) throw new ValidationException("Field TourId is empty"); if (!TourId.IsGuid()) throw new ValidationException("The value in the field TourId is not a unique identifier"); if (OldPrice <= 0) throw new ValidationException("Field OldPrice is less than or equal to 0"); } }