public static Result <Recipe> Create(string description, Group group, IngredientContainer ingredients, string recipeSteps)
        {
            var errors = new List <string>();

            if (group is null)
            {
                errors.Add("The recipe must contain a group");
            }
            ;
            if (string.IsNullOrEmpty(description))
            {
                errors.Add("Description cannot be empty");
            }
            if (string.IsNullOrEmpty(recipeSteps))
            {
                errors.Add("Recipe steps must be specified");
            }
            if (ingredients.Count() == 0)
            {
                errors.Add("The recipe must contain ingredients");
            }

            if (errors.Any())
            {
                return(Result <Recipe> .Fail(errors));
            }

            var context = Regex.Replace(description, @"\s+", " ").Trim();

            return(Result <Recipe> .Success(new Recipe(context, group, ingredients, recipeSteps)));
        }
 private void ListOutput(IngredientContainer container)
 {
     for (int i = 0; i < container.Count(); i++)
     {
         listView1.Items.Add(container[i].Name);
     }
 }
Ejemplo n.º 3
0
        private void ingredient_Changed(object sender, EventArgs e)
        {
            lvAddIngredients.Items.Clear();

            for (int i = 0; i < _ingredient.Count(); i++)
            {
                lvAddIngredients.Items.Add(new ListViewItem(new string[] { _ingredient[i].Name }));
            }
        }