Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public ActionResult <Recipe> AddRecipe(Recipe recipe)
 {
     _service.AddRecipe(recipe);
     return(recipe);
 }
Exemplo n.º 4
0
 public ActionResult <Recipe> PostRecipe([FromBody] Recipe recipe)
 {
     recipe.UserId = GetUserId();
     _recipesService.AddRecipe(recipe);
     return(CreatedAtAction("GetRecipe", new { id = recipe.Id }, recipe));
 }
Exemplo n.º 5
0
 public RecipeDto AddRecipe(RecipeDto recipe)
 {
     return(_recipesService.AddRecipe(recipe));
 }
Exemplo n.º 6
0
 public void AddRecipeTest()
 {
     recipe = new Recipe();
     _recipesService.AddRecipe(recipe);
     _recipesRepository.Verify(r => r.PostRecipe(recipe), Times.Once);
 }
Exemplo n.º 7
0
        public IActionResult Post([FromBody] Recipe recipe)
        {
            var addedRecipe = _recipeService.AddRecipe(recipe, GetUserId());

            return(Ok(addedRecipe));
        }