public GameAnswer(Answer answer) { Usable = true; ; AnswerString = answer.AnswerString; using (Repos repo = new Repos()) { answer.Pictures = repo.GetPicturesByAnswerID(answer.AnswerID).ToList(); } Pictures = ConvertPictures(answer.Pictures); }
public ActionResult AdminDeleteConfirmed(int id) { using (Repos repo = new Repos()) { if (!repo.DeleteModule(id)) { //ERROR DELETING MODULE } } return RedirectToAction("Index", new { controller = "Profile" }); }
public GameModule(Module module) { ModuleID = module.ModuleID; Name = module.Name; DefaultNumAnswers = module.DefaultNumAnswers; DefaultNumQuestions = module.DefaultNumQuestions; DefaultTime = module.DefaultTime; using (Repos repo = new Repos()) { module.Answers = repo.GetAnswerList(module.ModuleID).ToList(); } Answers = ConvertAnswers(module.Answers); rightAnswerString = module.rightAnswerString; wrongAnswerString = module.wrongAnswerString; }
public ActionResult Create([Bind(Include = "AnswerID,AnswerString,ModuleID,PictureCount")] Answer answer) { try { if (ModelState.IsValid) { using (Repos repo = new Repos()) { repo.AddAnswer(answer); } return RedirectToAction("Create", new { id = answer.ModuleID }); } } catch (Exception) { } return RedirectToAction("Create", new { error = "You cannot add duplicate answers" }); }
public ActionResult Delete(int? id) { int ID = id ?? 0; if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Category category; using (Repos repo = new Repos()) { category = repo.GetCategoryByID(ID); } if (category == null) { return HttpNotFound(); } return View(category); }
public ActionResult Delete(int? id) { int ID = id ?? 0; if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Answer answer; using (Repos repo = new Repos()) { answer = repo.GetAnswerByID(ID); } if (answer == null) { return HttpNotFound(); } return View(answer); }
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(); }
public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] Category category) { try { if (ModelState.IsValid) { using (Repos repo = new Repos()) { repo.AddCategory(category); } return RedirectToAction("Index"); } return View(category); } catch (Exception) { } //TODO - error when adding new category //return RedirectToAction("Create", new { error = "You cannot add duplicate answers" }); return RedirectToAction("Create"); }
public ActionResult AdminDelete(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(); } return View(module); }
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); }
public ActionResult Index() { IEnumerable<Category> cats; using (Repos repo = new Repos()) { cats = repo.GetCategoryList(); } return View(cats); }
public ActionResult Edit([Bind(Include = "CategoryID,CategoryName")] Category category) { try { if (ModelState.IsValid) { using (Repos repo = new Repos()) { repo.AddCategory(category); } return View(category); } } catch (Exception) { } return RedirectToAction("Index"); }
public ActionResult Create([Bind(Include = "ModuleID,Name,CategoryId,Description,DefaultNumAnswers,DefaultTime,DefaultNumQuestions,isPrivate")] Module module) { if (ModelState.IsValid) { //**********NOTE****************// //Make sure that a user is logged in to access this page if (((User.IsInRole("Learner")) || (User.IsInRole("Admin")))) { var userID = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.Single(x => x.Id == userID); module.User = currentUser; } using (Repos repo = new Repos()) { if (!repo.AddModule(module)) { //ERROR SAVING TO DATABASE } } PopulateCategoryDropDownList(module.CategoryId); return RedirectToAction("Index", "Profile"); } return View(module); }
public ActionResult EditPictureView(int? id) { int ID = id ?? 0; Picture picture; using (Repos repo = new Repos()) { picture = repo.GetPictureByID(ID); } return View(picture); }
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); }
public ActionResult DeleteConfirmed(int id) { Category category; using (Repos repo = new Repos()) { category = repo.GetCategoryByID(id); repo.DeleteCategory(category.CategoryID); } return RedirectToAction("Index"); }
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 Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } int ID = id ?? 0; Picture picture; using (Repos repo = new Repos()) { picture = repo.GetPictureByID(ID); } if (picture == null) { return HttpNotFound(); } ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", picture.AnswerID); return View(picture); }
public ActionResult Create(int? id) { ViewBag.AnswerID = id; Picture picture = new Picture(); int ID = id ?? 0; using (Repos repo = new Repos()) { picture.Answer = repo.GetAnswerByID(ID); } return View(picture); }
public ActionResult Index() { //ConvertAllPicturesToStringData(); IEnumerable<Picture> pictures; using (Repos repo = new Repos()) { pictures = repo.GetAllPictures(); } return View(pictures); }
public ActionResult ImageEditor(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } int ID = id ?? 0; Picture picture; using (Repos repo = new Repos()) { picture = repo.GetPictureByID(ID); } if (picture == null) { return HttpNotFound(); } return View(picture); }
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); }
public ActionResult DeleteConfirmed(int id) { int answerID; using (Repos repo = new Repos()) { answerID = repo.GetPictureByID(id).AnswerID; repo.DeletePicture(id); } return RedirectToAction("edit", new { controller = "Answers", id = answerID }); }
// GET: /Answers/ public ActionResult Index(int id = 0) { IEnumerable<Answer> answers; using (Repos repos = new Repos()) { answers = repos.GetAnswerList(id); } return View(answers); }
public ActionResult Create([Bind(Include = "Attribution,PictureID")] Picture picture, int? id) { int ID = id ?? 0; pictureToSave = new Picture(); pictureToSave.AnswerID = ID; pictureToSave.Location = "NotYetConstructed"; if (picture.Attribution == null) pictureToSave.Attribution = ""; else pictureToSave.Attribution = picture.Attribution; ConvertImageToDataString(pictureToSave, Request.Files[0].InputStream); ViewBag.AnswerID = ID; if (ModelState.IsValid) { using (Repos repo = new Repos()) { if (!repo.AddPicture(pictureToSave)) { //ERROR SAVING TO DATABASE } } return RedirectToAction("edit", new { controller = "Answers", id = pictureToSave.AnswerID }); } ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", pictureToSave.AnswerID); return View(pictureToSave); }
public ActionResult Index(string sortOrder, string searchString, string userSearchString) { ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_asc" : ""; IEnumerable<Module> modules; using (Repos repo = new Repos()) { modules = repo.GetModuleList(); } if (!String.IsNullOrEmpty(searchString)) { modules = modules.Where(m => m.Name.Contains(searchString)); } if (!String.IsNullOrEmpty(userSearchString)) { modules = modules.Where(m => m.User.UserName.Contains(searchString)); } switch (sortOrder) { case "name_asc": modules = modules.OrderBy(m => m.Name); break; } return View(modules); }
public ActionResult Edit([Bind(Include = "PictureID,AnswerID,Attribution,PictureData")] Picture picture) { if (ModelState.IsValid) { using (Repos repo = new Repos()) { if (!repo.UpdatePicture(picture)) { //ERROR UPDATING DATABASE } } return RedirectToAction("edit", new { controller = "Answers", id = picture.AnswerID }); } ViewBag.AnswerID = new SelectList(db.Answers, "AnswerID", "AnswerString", picture.AnswerID); return View(picture); }
public ActionResult DeleteConfirmed(int id) { Answer answer; using (Repos repo = new Repos()) { answer = repo.GetAnswerByID(id); repo.DeleteAnswer(answer.AnswerID); } return RedirectToAction("Create", new { id = answer.ModuleID }); }
private void PopulateCategoryDropDownList(object selectedCategory = null) { IEnumerable<Category> categoryQuery; using (Repos repo = new Repos()) { categoryQuery = repo.GetCategoryList(); } ViewBag.CategoryId = new SelectList(categoryQuery.Distinct().ToList(), "CategoryId", "CategoryName", selectedCategory); }