예제 #1
0
        public ActionResult DisableModule(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int    ID = id ?? 0;
            Module module;

            using (Repos repo = new Repos())
            {
                module         = repo.GetModuleByID(ID);
                module.Answers = repo.GetAnswerList(ID).ToList();
                foreach (Answer answer in module.Answers)
                {
                    answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
                }
            }
            var model = new DisableModuleViewModel(module);

            if (module == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
예제 #2
0
        public ActionResult DisableModule([Bind(Include = "Name, isDisabled, DisableModuleNote, DisableReason")] DisableModuleViewModel userModule)
        {
            if (ModelState.IsValid)
            {
                Module module;
                using (Repos repo = new Repos())
                {
                    module         = repo.GetModuleByID(userModule.ModuleID);
                    module.Answers = repo.GetAnswerList(userModule.ModuleID).ToList();
                    foreach (Answer answer in module.Answers)
                    {
                        answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
                    }
                }

                module.isDisabled        = userModule.isDisabled;
                module.DisableModuleNote = userModule.DisableModuleNote;
                module.DisableReason     = userModule.DisableReason;

                using (Repos repo = new Repos())
                {
                    if (!repo.UpdateModule(module))
                    {
                        //ERROR SAVING TO DATABASE
                    }
                }
                return(RedirectToAction("Index", new { controller = "ModulesEdit" }));
            }
            return(View(userModule));
        }
예제 #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int    ID = id ?? 0;
            Module module;

            using (Repos repo = new Repos())
            {
                module         = repo.GetModuleByID(ID);
                module.Answers = repo.GetAnswerList(ID).ToList();
                foreach (Answer answer in module.Answers)
                {
                    answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList();
                }
            }
            if (module == null)
            {
                return(HttpNotFound());
            }
            PopulateCategoryDropDownList(module.CategoryId);
            return(View(module));
        }