コード例 #1
0
        public IActionResult GenerateAllergenTag([FromBody] List <RecipeIngredient> recipeIngredients)
        {
            GenerateTag trial = new GenerateTag(_recipesService, _context);

            string allergens = trial.GetAllergenTag(recipeIngredients);

            List <RecipeTag> tags = new List <RecipeTag>();

            tempAllergenTags tempAlTags = JsonConvert.DeserializeObject <tempAllergenTags>(allergens);

            if (tempAlTags.allergens != null)
            {
/*                Debug.WriteLine(tempAlTags.allergens[0]);
 */
                for (int i = 0; i < tempAlTags.allergens.Count; i++)
                {
                    tags.Add(new RecipeTag
                    {
                        IsAllergenTag = true,
                        Tag           = new Tag
                        {
                            TagName = tempAlTags.allergens[i],
                            Warning = tempAlTags.allergens[i]
                        }
                    });
                }
            }

            string json = JsonConvert.SerializeObject(tags, Formatting.Indented);

            return(Json(new { tags = json }));
        }
コード例 #2
0
        public async Task <ActionResult <List <RecipeTag> > > GenerateAllergenTags([FromBody] List <RecipeIngredient> recipeIngredients)
        {
            Debug.Write("Reached generate A Tags");

            GenerateTag trial = new GenerateTag(_recipesService);

            string allergens = trial.GetAllergenTag(recipeIngredients);

            List <RecipeTag> tags = new List <RecipeTag>();

            tempAllergenTags tempAlTags = JsonConvert.DeserializeObject <tempAllergenTags>(allergens);

            if (tempAlTags.allergens != null)
            {
                Debug.WriteLine(tempAlTags.allergens[0]);
                for (int i = 0; i < tempAlTags.allergens.Count; i++)
                {
                    tags.Add(new RecipeTag
                    {
                        IsAllergenTag = true,
                        Tag           = new Tag
                        {
                            TagName = tempAlTags.allergens[i],
                            Warning = tempAlTags.allergens[i]
                        }
                    });
                }
            }

            return(tags);
        }