示例#1
0
        public ActionResult AddInstructions(Instructions ins)
        {
            //create new ingredient
            ins.RecipeID = ViewBag.id;
            Instructions newIns = new Instructions();
            //assign id from previous instruction
            newIns.RecipeID = ins.RecipeID;

            //Add Finish button to redirect to add instructions controller action
            ViewBag.theMessage = "Add your instructions.";
            //recipe id persists to here
            ;

            return View(newIns);
        }
示例#2
0
        public ActionResult AddInstructionsPost(Instructions ins)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add ingredient

                    db.Instructions.Add(ins);
                    db.SaveChanges();
                    //add ingredient to list
                    //myIngredients.Add(ins);
                    //when finshed is called iterate over list and add to database

                    //return to add ingredients view
                    //recipeid persists first time to here
                    int recipeid = ins.RecipeID;
                    return RedirectToAction("AddIngredients", ins);
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists call Niall.");
            }

            return View(ins);
        }