2025-02-05 22:40:19 +04:00
|
|
|
|
using AndDietCokeContracts.Enums;
|
|
|
|
|
using AndDietCokeContracts.Extensions;
|
|
|
|
|
using AndDietCokeContracts.Infrastructure;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using AndDietCokeContracts.Exceptions;
|
|
|
|
|
|
|
|
|
|
namespace AndDietCokeContracts.DataModels;
|
|
|
|
|
|
2025-02-11 16:24:28 +04:00
|
|
|
|
public class DishDataModel(string id, string dishName, DishType dishType, double price, IngredientType ingredientType, bool isDeleted) : IValidation
|
2025-02-05 22:40:19 +04:00
|
|
|
|
{
|
|
|
|
|
public string Id { get; private set; } = id;
|
|
|
|
|
public string DishName { get; private set; } = dishName;
|
|
|
|
|
public DishType DishType { get; private set; } = dishType;
|
|
|
|
|
public double Price { get; private set; } = price;
|
2025-02-11 16:24:28 +04:00
|
|
|
|
public IngredientType IngredientType { get; private set; } = ingredientType;
|
2025-02-05 22:40:19 +04:00
|
|
|
|
public bool IsDeleted { get; private set; } = isDeleted;
|
|
|
|
|
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 (DishName.IsEmpty())
|
|
|
|
|
throw new ValidationException("Field DishName is empty");
|
|
|
|
|
if (DishType == DishType.None)
|
|
|
|
|
throw new ValidationException("Field DishType is empty");
|
|
|
|
|
if (Price <= 0)
|
|
|
|
|
throw new ValidationException("Field Price is less than or equal to 0");
|
|
|
|
|
}
|
|
|
|
|
}
|