public Ingredient Create(IngredientType ingredientType, QuantityMeasurementType quantityMeasurementType, int quantity)
        {
            if (ingredientType == null)
            {
                throw new ArgumentNullException(nameof(ingredientType));
            }

            if (quantity <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity));
            }

            var ingredient = new Ingredient()
            {
                IngredientType          = ingredientType,
                QuantityMeasurementType = quantityMeasurementType,
                Quantity = quantity
            };

            this.Set.Add(ingredient);
            this.SaveChanges();

            return(ingredient);
        }
Esempio n. 2
0
 public static string TranslateQuantityMeasurementTypes(this HtmlHelper htmlHelper, QuantityMeasurementType quantityMeasurementType)
 {
     return(transations[quantityMeasurementType]);
 }