Ejemplo n.º 1
0
        public ActionResult NewAnswer(AnswerModel amObj)
        {
            if (Session["USER"] != null)
            {
                if (lecturer.IsAdmin == 1)
                {
                    if (lecturer.Priority >= 5)
                    {
                        bool result = amObj.AddAnswer();


                        if (result)
                        {
                            ViewData["result"] = "Successfully Inserted";
                        }
                        else
                        {
                            ViewData["result"] = "Insert Failed";
                        }

                        ModelState.Clear();
                        return(View());
                    }
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds an answer
        /// </summary>
        /// <param name="ans"></param>
        /// <returns></returns>
        public ActionResult AddAnswer(string ans)
        {
            int qid      = 0;
            var question = Session["question"] as QuestionModel;

            qid = question.QuestionId;
            if (ans != "")
            {
                var user = Session["user"] as UserModel;
                if (user == null)
                {
                    return(Json(false));
                }
                else if (user.TypeId == 2)
                {
                    return(Json(false));
                }
                else
                {
                    int uid = user.UserId;
                    if (!(ans == ""))
                    {
                        this.AddNoOfAnswers();
                        AnswerModel.AddAnswer(ans, uid, qid);
                    }
                }
            }
            List <AnswerModel> lis = AnswerModel.GetAnswers(qid);
            QuestionModel      q   = QuestionModel.GetQuestionById(qid);

            ViewBag.S = lis;
            return(View(q));
        }