Exemplo n.º 1
0
            public RecipeIngredient Create(Guid ingredientId, double grams)
            {
                if (grams <= 0)
                {
                    throw new ArgumentException("Cant add ingredients with grams lower than zero.");
                }

                var id = new Identity <Guid>(ingredientId);

                return(_ingredientRepository.ExistById(id.Value)
                                        ? new RecipeIngredient(id, grams)
                                        : throw new ArgumentNullException($"Ingredient with Id:{ingredientId} does not exist."));
            }