using PipingHotContrast.Enums; using PipingHotContrast.Exceptions; using PipingHotContrast.Extensions; using PipingHotContrast.Infrastructure; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PipingHotContrast.DataModels; public class ProductDataModel(string id, string productName, ProductType productType, string restaurantId, double price, bool isDeleted) : IValidation { public string Id { get; private set; } = id; public string ProductName { get; private set; } = productName; public ProductType ProductType { get; private set; } = productType; public string RestaurantId { get; private set; } = restaurantId; 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 (ProductName.IsEmpty()) throw new ValidationException("Field ProductName is empty"); if (ProductType == ProductType.None) throw new ValidationException("Field ProductType is empty"); if (RestaurantId.IsEmpty()) throw new ValidationException("Field RestaurantId is empty"); if (!RestaurantId.IsGuid()) throw new ValidationException("The value in the field RestaurantId is not a unique identifier"); if (Price <= 0) throw new ValidationException("Field Price is empty"); } }