Esempio n. 1
0
        public ActionResult Edit(int?id)
        {
            int ID = id ?? 0;

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
            Response.AppendHeader("Expires", "-1");      // Proxies.
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Answer answer;

            using (Repos repo = new Repos())
            {
                answer           = repo.GetAnswerByID(ID);
                ViewBag.Pictures = repo.GetViewBagPictureList(answer.AnswerID);
            }
            if (answer == null)
            {
                return(HttpNotFound());
            }

            ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "Name");
            return(View(answer));
        }
Esempio n. 2
0
        public ActionResult Edit([Bind(Include = "AnswerID,AnswerString,ModuleID,PictureCount")] Answer answer, int?ModuleID)
        {
            if (ModelState.IsValid)
            {
                using (Repos repo = new Repos())
                {
                    repo.UpdateAnswer(answer);
                    ViewBag.Pictures = repo.GetViewBagPictureList(answer.AnswerID);
                }

                return(RedirectToAction("Create", new { controller = "Answers", id = answer.ModuleID }));
            }
            ViewBag.ModuleID = new SelectList(db.Modules, "ModuleID", "Name");
            return(View(answer));
        }