public IActionResult AddRecipe() { var recipeName = Request.Form["recipeName"]; var recipeDescription = Request.Form["recipeDescription"]; var steps = Request.Form["recipeSteps"]; var ingredients = Request.Form["recipeIngredients"]; var userID = Convert.ToInt32(HttpContext.User.FindFirst("Id").Value); string jsonString = $"{{\"RecipeID\":0,\"RecipeName\":\"{recipeName}\", \"Description\":\"{recipeDescription}\", \"UserID\":{userID}," + $"\"Steps\": {steps} ," + $"\"Ingredients\": {ingredients}}}"; _recipesService.AddRecipe(jsonString); return(Json("OK")); }
private void AddRecipe() { var category = ChooseCategory(); var name = _getDataFromUser.GetData("Give name: "); var listOfIngredients = SetIngredients(); var directions = _getDataFromUser.GetData("Give directions: "); var newRecipe = new RecipeDto { Name = name, Category = category, ListOfIngredients = listOfIngredients, Directions = directions }; var result = _recipesService.AddRecipe(newRecipe); ShowResult(result); }
public ActionResult <Recipe> AddRecipe(Recipe recipe) { _service.AddRecipe(recipe); return(recipe); }
public ActionResult <Recipe> PostRecipe([FromBody] Recipe recipe) { recipe.UserId = GetUserId(); _recipesService.AddRecipe(recipe); return(CreatedAtAction("GetRecipe", new { id = recipe.Id }, recipe)); }
public RecipeDto AddRecipe(RecipeDto recipe) { return(_recipesService.AddRecipe(recipe)); }
public void AddRecipeTest() { recipe = new Recipe(); _recipesService.AddRecipe(recipe); _recipesRepository.Verify(r => r.PostRecipe(recipe), Times.Once); }
public IActionResult Post([FromBody] Recipe recipe) { var addedRecipe = _recipeService.AddRecipe(recipe, GetUserId()); return(Ok(addedRecipe)); }