using MagicCarpetContracts.Enums; 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; using static System.Runtime.InteropServices.JavaScript.JSType; namespace MagicCarpetContracts.DataModels; public class SuppliesDataModel(string id, TourType tourType, DateTime date, int count, List tours) : IValidation { public string Id { get; private set; } = id; public TourType Type { get; private set; } = tourType; public DateTime ProductuionDate { get; private set; } = date; public int Count { get; private set; } = count; public List Tours { get; private set; } = tours; 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 (Type == TourType.None) throw new ValidationException("Field Type is empty"); if (Count <= 0) throw new ValidationException("Field Count is less than or equal to 0"); if ((Tours?.Count ?? 0) == 0) throw new ValidationException("The sale must include tours"); } }