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)); }
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)); }
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)); }
public ActionResult Create(int ID, string error) { Module module; try { using (Repos repo = new Repos()) { module = repo.GetModuleByID(ID); ViewBag.ModuleID = module.ModuleID; ViewBag.ModuleName = module.Name; ViewBag.ModuleAnsList = repo.GetAnswerList(module.ModuleID); } } catch (Exception) { ViewBag.Error = error; } return(View()); }
private void GenerateModule(int PLMid) { ((UserGameSession)Session["userGameSession"]).gameModule = null; using (Repos repo = new Repos()) { ((UserGameSession)Session["userGameSession"]).gameModule = new GameModule(repo.GetModuleByID(PLMid)); } }