using SnowMaidenContracts.Exceptions; using SnowMaidenContracts.Extensions; using SnowMaidenContracts.Infrastructure; namespace SnowMaidenContracts.DataModels; // 3. Каждый продукт связан с продажей промежуточной информацией о количестве данного продукта (4. Product -> SaleProduct) public class SaleProductDataModel(string saleId, string productId, int count) : IValidation { public string SaleId { get; private set; } = saleId; public string ProductId { get; private set; } = productId; public int Count { get; private set; } = count; public void Validate() { if (SaleId.IsEmpty()) throw new ValidationException("Field Sale ID is empty"); if (!SaleId.IsGuid()) throw new ValidationException("The Sale ID value is NOT a unique identifier"); if (ProductId.IsEmpty()) throw new ValidationException("Field Product ID is empty"); if (!ProductId.IsGuid()) throw new ValidationException("The Product ID value is NOT a unique identifier"); if (Count <= 0) throw new ValidationException("Field Count is less than or equal to 0"); } }