using CandyHouseBase.Enums; using CandyHouseBase.Exceptions; using CandyHouseBase.Extensions; using CandyHouseBase.Infrastructure; namespace CandyHouseBase.DataModels { public class SupplyItemDataModel : IValidation { public string SupplyId { get; private set; } public string ItemId { get; private set; } public int Quantity { get; private set; } public ItemType ItemType { get; private set; } // 'ingredient' или 'product' public SupplyItemDataModel(string supplyId, string itemId, int quantity, ItemType itemType) { SupplyId = supplyId; ItemId = itemId; Quantity = quantity; ItemType = itemType; } public void Validate() { if (!SupplyId.IsGuid()) throw new ValidationException("SupplyId must be a GUID"); if (!ItemId.IsGuid()) throw new ValidationException("ItemId must be a GUID"); if (Quantity <= 0) throw new ValidationException("Quantity must be positive"); } } }