Exemplo n.º 1
0
        public ActionResult EditCourse()
        {
            ViewBag.Result = new List <Term>();
            QuizDAO quizDao = new QuizDAOImpl();
            string  user    = Request.Cookies["user"] == null ? "" : Request.Cookies["user"].Value;

            try
            {
                if (!String.IsNullOrEmpty(Request["id"]) && quizDao.CanAccess(user, Convert.ToInt32(Request["id"])))
                {
                    ViewBag.Result = new TermDAOImpl().GetTermsByQuizID(int.Parse(Request["id"]));
                    List <Term> lst  = ViewBag.Result;
                    Quiz        quiz = new QuizDAOImpl().getQuizByQuizId(int.Parse(Request["id"]));
                    ViewBag.quiz = quiz;
                    return(View());
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                return(Redirect("/error/404"));
            }
        }
Exemplo n.º 2
0
        public ActionResult DeleteQuiz()
        {
            QuizDAO quizDao = new QuizDAOImpl();
            string  user    = Request.Cookies["user"] == null ? "" : Request.Cookies["user"].Value;

            try
            {
                if (!String.IsNullOrEmpty(Request["id"]) && quizDao.CanAccess(user, Convert.ToInt32(Request["id"])))
                {
                    ViewBag.user = Request.Cookies["user"];

                    if (quizDao.DeleteQuiz(int.Parse(Request["id"])))
                    {
                        return(Redirect("/quiz/course"));
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                return(Redirect("/error/404"));
            }
        }
Exemplo n.º 3
0
        public List <Term> Get(string name, int id)
        {
            QuizDAO quizDAO = new QuizDAOImpl();

            if (quizDAO.CanAccess(name, id))
            {
                return(new TermDAOImpl().GetTermsByQuizID(id));
            }
            else
            {
                return(new List <Term>());
            }
        }