コード例 #1
0
        public ActionResult Add(InstructionsListViewModel data)
        {
            var instructionListModel = new InstructionsListViewModel()
            {
                RecipeID         = data.RecipeID,
                NrOfInstructions = data.NrOfInstructions,
            };

            for (int i = 0; i < instructionListModel.NrOfInstructions; i++)
            {
                instructionListModel.ListOfInstructions.Add(new InstructionViewModel());
            }

            return(View(instructionListModel));
        }
コード例 #2
0
        public ActionResult Update(InstructionsListViewModel instructions)
        {
            var instructionsBL = instructionsService.GetAllInstructionsForRecipe(instructions.RecipeID);


            foreach (var i in instructionsBL)
            {
                instructions.ListOfInstructions.Add(new InstructionViewModel()
                {
                    InstructionID   = i.InstructionID,
                    InstructionText = i.InstructionText
                });
            }
            instructions.NrOfInstructions = instructionsBL.Count();
            instructions.RecipeID         = instructions.RecipeID;
            return(View(instructions));
        }
コード例 #3
0
        public ActionResult AddInstructions(InstructionsListViewModel instructions)
        {
            List <InstructionsBL> instructionsList = new List <InstructionsBL>();

            foreach (var i in instructions.ListOfInstructions)
            {
                instructionsList.Add(new InstructionsBL()
                {
                    InstructionText = i.InstructionText,
                    RecipeID        = instructions.RecipeID
                });
            }

            foreach (var i in instructionsList)
            {
                instructionsService.InsertInstructionForRecipe(i);
            }

            return(RedirectToAction("Index", "Home"));
        }