27 lines
918 B
C#
27 lines
918 B
C#
using CandyHouseBase.Exceptions;
|
|
using CandyHouseBase.Extensions;
|
|
using CandyHouseBase.Infrastructure;
|
|
|
|
namespace CandyHouseBase.DataModels
|
|
{
|
|
public class RecipeDataModel : IValidation
|
|
{
|
|
public string ProductId { get; private set; }
|
|
public string IngredientId { get; private set; }
|
|
public int Quantity { get; private set; }
|
|
|
|
public RecipeDataModel(string productId, string ingredientId, int quantity)
|
|
{
|
|
ProductId = productId;
|
|
IngredientId = ingredientId;
|
|
Quantity = quantity;
|
|
}
|
|
|
|
public void Validate()
|
|
{
|
|
if (!ProductId.IsGuid()) throw new ValidationException("ProductId must be a GUID");
|
|
if (!IngredientId.IsGuid()) throw new ValidationException("IngredientId must be a GUID");
|
|
if (Quantity <= 0) throw new ValidationException("Quantity must be positive");
|
|
}
|
|
}
|
|
} |