public ActionResult Edit(int id) { TextChallenge tc = db.TextChallenges.Find(id); ViewBag.Challenge = tc; return(View(tc)); }
public ActionResult Edit(int id, TextChallenge requestChallenge) { try { if (ModelState.IsValid) { TextChallenge tc = db.TextChallenges.Find(id); if (TryUpdateModel(tc)) { tc.ChallengeScore = requestChallenge.ChallengeScore; tc.Question = requestChallenge.Question; db.SaveChanges(); TempData["message"] = "Problema a fost modificata!"; } return(RedirectToAction("Index")); } else { return(View()); } } catch (Exception e) { return(View()); } }
public ActionResult Delete(int id) { TextChallenge tc = db.TextChallenges.Find(id); db.TextChallenges.Remove(tc); db.SaveChanges(); TempData["message"] = "Problema a fost stearsa"; return(RedirectToAction("Index")); }
public ActionResult Details(int id) { TextChallenge tc = db.TextChallenges.Find(id); ViewBag.Challenge = tc; Teacher teacher = db.Teachers.Find(tc.TeacherId); ViewBag.Teacher = teacher; return(View(tc)); }
public ActionResult Create(int id) { TextSolution solution = new TextSolution(); Student student = db.Students.Find(3); solution.StudentId = student.StudentId; TextChallenge challenge = db.TextChallenges.Find(id); //challenge.TextSolutions.Add(solution); //solution.TextChallenge = challenge; solution.ChallengeId = challenge.ChallengeId; // ViewBag.Solution = solution; return(View(solution)); }
public ActionResult Create(TextChallenge tc) { try { if (ModelState.IsValid) { Teacher teacher = db.Teachers.Find(2); tc.TeacherId = teacher.TeacherId; db.TextChallenges.Add(tc); db.SaveChanges(); TempData["message"] = "Problema a fost adaugata!"; return(RedirectToAction("Index")); } else { return(View(tc)); } } catch (Exception e) { return(View(tc)); } }
public ActionResult Create() { TextChallenge tc = new TextChallenge(); return(View(tc)); }