Ejemplo n.º 1
0
 //AddNewIngredient is currently not being used in the project, just to test
 public void AddNewIngredient(Ingredient ingredient)
 {
     if (ingredient != null)
     {
         _serv.AddNewIngredient(ingredient);
     }
 }
Ejemplo n.º 2
0
 public IActionResult AddNewIngredient(IngredientForViewVm ingredient)
 {
     if (ingredient.Btn == "Submit")
     {
         _ingredientService.AddNewIngredient(ingredient);
     }
     return(RedirectToAction("EditIngredientsList"));
 }
Ejemplo n.º 3
0
        public ActionResult AddIngredient(string ingredientName)
        {
            ingredientService.AddNewIngredient(new IngredientDto()
            {
                Name = ingredientName
            });

            return(RedirectToAction("IngredientsIndex", "KitchenChef"));
        }
Ejemplo n.º 4
0
        public IActionResult PostIngredient([FromBody] PostIngredientDTO ingredientDTO)
        {
            _requestLogService.SaveRequest(User.Identity.GetUserId(), "POST", "api/v1/ingredients", "PostIngredient");
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid fields provided, please double check the parameters"));
            }

            var newIngredient = _ingredientService.AddNewIngredient(ingredientDTO, User.Identity.GetUserId());

            return(CreatedAtAction(nameof(GetIngredient), new { id = newIngredient.IngredientId }, newIngredient));
        }
 public void AddIngredientFromViewModel(IngredientViewModel vm)
 {
     _serv.AddNewIngredient(ConvertViewModelToIngredient(vm));
 }