Esempio n. 1
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));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "ModuleID,Name,CategoryId,Description,DefaultNumAnswers,DefaultTime,DefaultNumQuestions,isPrivate")] Module module)
 {
     if (ModelState.IsValid)
     {
         using (Repos repo = new Repos())
         {
             if (!repo.UpdateModule(module))
             {
                 //ERROR SAVING TO DATABASE
             }
         }
         return(RedirectToAction("Index", new { controller = "Profile" }));
     }
     PopulateCategoryDropDownList(module.CategoryId);
     return(View(module));
 }