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

            if (group is null)
            {
                errors.Add("Рецепт должен содержать категорию");
            }
            ;
            if (string.IsNullOrEmpty(description))
            {
                errors.Add("Описание не может быть пустым");
            }
            if (string.IsNullOrEmpty(recipeSteps))
            {
                errors.Add("Укажите шаги рецепта");
            }
            if (ingredients.Count() == 0)
            {
                errors.Add("Рецепт должен содержать ингредиенты");
            }

            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)));
        }
Beispiel #2
0
 private void ListOutput(IngredientStorage container)
 {
     for (int i = 0; i < container.Count(); i++)
     {
         listView1.Items.Add(container[i].Name);
     }
 }
        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 }));
            }
        }