34 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using IcecreamVan.Extensions;
using IcecreamVan.Infrastructure;
using IcecreamVan.Exceptions;
namespace IcecreamVan.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");
}
}