コード例 #1
0
        public ActionResult Edit(int id)
        {
            TextChallenge tc = db.TextChallenges.Find(id);

            ViewBag.Challenge = tc;
            return(View(tc));
        }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 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));
     }
 }
コード例 #7
0
        public ActionResult Create()
        {
            TextChallenge tc = new TextChallenge();

            return(View(tc));
        }