using BitterlyAndExclamationMarkContracts.Enums; using BitterlyAndExclamationMarkContracts.Exceptions; using BitterlyAndExclamationMarkContracts.Extensions; using BitterlyAndExclamationMarkContracts.Infrastructure; public class DishDataModel(string id, string dishName, DishType dishType, Ingredients ingredients, double price, bool isDeleted) : IValidation { public string Id { get; private set; } = id; public string DishName { get; private set; } = dishName; public DishType DishType { get; private set; } = dishType; public Ingredients Ingredients { get; private set; } = ingredients; public double Price { get; private set; } = price; 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 (Ingredients == Ingredients.None) throw new ValidationException("Field Ingredients is empty"); if (Price <= 0) throw new ValidationException("Field Price is less than or equal to 0"); } }