コード例 #1
0
        public IActionResult UpdateDishIngredient(int baseDishId, int ingredientId, bool addIngredient, bool isOrderedDish)
        {
            var IngredientsList = addIngredient
                ? _ingredientService.AddIngredientToList(ingredientId)
                : _ingredientService.RemoveIngredientFromList(ingredientId);

            HttpContext.Session.SetString(Constants.IngredientsSession, JsonConvert.SerializeObject(IngredientsList));

            return(PartialView("_IngredientPartial", new IngedientDishViewModel
            {
                BaseDishId = baseDishId,
                Ingredients = IngredientsList,
                IsOrderedDish = isOrderedDish
            }));
        }