Ejemplo n.º 1
0
        public ActionResult Create(SupplyListAndSupplyViewModel PostSupply)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Create"));
            }

            var ingredientNum      = int.Parse(PostSupply.PostIngredient);
            var selectedIngredient = MealHelper.GetAllIngredients().Where(x => x.Id == ingredientNum).FirstOrDefault();

            PostSupply.Supply.Ingredient = selectedIngredient;

            PostSupply.Supply.Id = SupplyHelper.GetSupplyNextId();

            SupplyHelper.AddSupply(PostSupply.Supply);

            return(RedirectToAction("Index"));
        }