public ActionResult DeleteConfirmed(int id) { TournamentQuestion tournamentQuestion = db.TournamentQuestions.Find(id); db.TournamentQuestions.Remove(tournamentQuestion); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(TournamentQuestion tournamentQuestion) { if (ModelState.IsValid) { db.Entry(tournamentQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", tournamentQuestion.PredictionCategoryId); ViewBag.QuestionId = new SelectList(db.Questions.Where(x => x.IsForMatch != true), "QuestionId", "Text", tournamentQuestion.QuestionId); ViewBag.TournamentId = new SelectList(db.Tournaments, "TournamentId", "Name", tournamentQuestion.TournamentId); return(View(tournamentQuestion)); }
// GET: TournamentQuestion/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TournamentQuestion tournamentQuestion = db.TournamentQuestions.Find(id); if (tournamentQuestion == null) { return(HttpNotFound()); } return(View(tournamentQuestion)); }
public ActionResult Answer(TournamentQuestion tournamentQuestion, int answerId) { if (ModelState.IsValid) { tournamentQuestion.Answer = answerId; db.Entry(tournamentQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", tournamentQuestion.PredictionCategoryId); ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "Text", tournamentQuestion.QuestionId); ViewBag.TournamentId = new SelectList(db.Tournaments, "TournamentId", "Name", tournamentQuestion.TournamentId); return(View(tournamentQuestion)); }
// GET: TournamentQuestion/Answer/5 public ActionResult Answer(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TournamentQuestion tournamentQuestion = db.TournamentQuestions.Find(id); if (tournamentQuestion == null) { return(HttpNotFound()); } var question = tournamentQuestion.Question; var teams = db.TournamentTeams .Where(y => y.TournamentId == tournamentQuestion.TournamentId) .Select(yy => yy.TeamId).ToList(); switch (question.OptionsTypeId) { case (int)Lookups.QuestionOptionsType.Team: ViewBag.answerId = new SelectList(db.Teams .Where(x => teams.Contains(x.TeamId)), "TeamId", "Name"); break; case (int)Lookups.QuestionOptionsType.Player: var players = db.TeamPlayers.Where(x => teams.Contains(x.TeamId)).Select(x => x.PlayerId).ToList(); ViewBag.answerId = new SelectList(db.Players.Where(x => players.Contains(x.PlayerId)), "PlayerId", "Name"); break; case (int)Lookups.QuestionOptionsType.Lookup: ViewBag.answerId = new SelectList(db.LookUpValues.Where(x => x.ParentId == question.LookupParentId), "LookupValueId", "Name"); break; default: break; } ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", tournamentQuestion.PredictionCategoryId); ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "Text", tournamentQuestion.QuestionId); ViewBag.TournamentId = new SelectList(db.Tournaments, "TournamentId", "Name", tournamentQuestion.TournamentId); return(View(tournamentQuestion)); }
// GET: TournamentQuestion/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TournamentQuestion tournamentQuestion = db.TournamentQuestions.Find(id); if (tournamentQuestion == null) { return(HttpNotFound()); } ViewBag.PredictionCategoryId = new SelectList(db.PredictionCategories, "PredictionCategoryId", "Name", tournamentQuestion.PredictionCategoryId); ViewBag.QuestionId = new SelectList(db.Questions.Where(x => x.IsForMatch != true), "QuestionId", "Text", tournamentQuestion.QuestionId); ViewBag.TournamentId = new SelectList(db.Tournaments, "TournamentId", "Name", tournamentQuestion.TournamentId); return(View(tournamentQuestion)); }