2025-02-06 02:56:19 +04:00

32 lines
1.1 KiB
C#

using AndDietCokeContract.Exceptions;
using AndDietCokeContract.Extensions;
using AndDietCokeContract.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeContract.DataModels;
public class SaleDishDataModel(string saleId, string dishId, int count) :
IValidation
{
public string SaleId { get; private set; } = saleId;
public string DishId { get; private set; } = dishId;
public int Count { get; private set; } = count;
public void Validate()
{
if (SaleId.IsEmpty())
throw new ValidationException("Field SaleId is empty");
if (!SaleId.IsGuid())
throw new ValidationException("The value in the field SaleId is not a unique identifier");
if (DishId.IsEmpty())
throw new ValidationException("Field DishId is empty");
if (!DishId.IsGuid())
throw new ValidationException("The value in the field DishId is not a unique identifier");
if (Count <= 0)
throw new ValidationException("Field Count is less than or equal to 0");
}
}