using ElectricalRepairServiceContract.Exceptions; using ElectricalRepairServiceContract.Extensions; using ElectricalRepairServiceContract.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace ElectricalRepairServiceContract.DataModels { public class DetailsDataModel : IValidation { public string Id { get; private set; } public string Name { get; private set; } public int Count { get; private set; } public int OldCount { get; private set; } public DateTime UpdateDate { get; private set; } public List? DetailsDelivery { get; private set; } public List? DetailsUses { get; private set; } public DetailsDataModel(string id, string name, int count, int oldCount, DateTime updateDate, List? detailsDelivery, List? detailsUses) { Id = id; Name = name; Count = count; OldCount = oldCount; UpdateDate = updateDate; DetailsDelivery = detailsDelivery; DetailsUses = detailsUses; } 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 (Name.IsEmpty()) throw new ValidationException("Field Description is empty"); if (Count < 0) throw new ValidationException("The count must be positive"); if (OldCount < 0) throw new ValidationException("The count must be positive"); } } }