Example #1
0
        public ActionResult Delete(
            [Bind("UserId, IngredientId")] UserUnwantedIngredient userUnwantedIngredient,
            int?pageNumber)
        {
            _context.Remove(userUnwantedIngredient);
            _context.SaveChanges();

            return(RedirectToAction("Index", "ConfigurationIngredients", new { pageNumber }));
        }
Example #2
0
        public ActionResult Store(
            [Bind("UserId, IngredientId")] UserUnwantedIngredient userUnwantedIngredient,
            int?pageNumber)
        {
            var isAFavouriteIngredient =
                _context.UserFavouriteIngredients.Find(
                    userUnwantedIngredient.UserId, userUnwantedIngredient.IngredientId) != null;

            if (!isAFavouriteIngredient)
            {
                _context.Add(userUnwantedIngredient);
                _context.SaveChanges();
            }

            return(RedirectToAction("Index", "ConfigurationIngredients", new { pageNumber }));
        }