getAnswer() public method

Rereives detailes about a specific answer
public getAnswer ( int answerid ) : answerModel
answerid int ID of the requested answer
return answerModel
Esempio n. 1
0
        public ActionResult Revert(int answerid, String answer, int correct, String weight, string ansnum)
        {
            if (Session["uid"] == null || Session["uid"].ToString().Equals(""))
            {
                return RedirectToAction("Index", "Home");
            }
            if ((int)Session["user_type"] < User_Type.POLL_MASTER)
            {
                return RedirectToAction("Invalid", "Home");
            }

            answerModel a = new answerModel();
            a = a.getAnswer(answerid);

            /* Create a record of the old answer in the Answer History table */
            new answerHistoryModel(answerid).createAnswerHistory(a.answerid, a.answer, a.correct, a.weight, a.ansnum);

            /* Update the answer*/
            a.updateAnswer(answerid, answer, correct, int.Parse(weight), int.Parse(ansnum));
            a = a.getAnswer(answerid);
            return RedirectToAction("Index", "answerHistory", new { id = a.answerid, name = a.answer } );
        }
Esempio n. 2
0
        public ActionResult Delete(int aid, int ahid)
        {
            if (Session["uid"] == null || Session["uid"].ToString().Equals(""))
            {
                return RedirectToAction("Index", "Home");
            }
            if ((int)Session["user_type"] < User_Type.POLL_MASTER)
            {
                return RedirectToAction("Invalid", "Home");
            }

            new answerHistoryModel(ahid).deleteAnswerHistory();

            answerModel a = new answerModel();
            a = a.getAnswer(aid);
            return RedirectToAction("Index", "answerHistory", new { id = a.answerid, name = a.answer });
        }
Esempio n. 3
0
        public ActionResult Edit(int answerid, String answer, int correct, String weight, int questionid, String ansnum)
        {
            if (Session["uid"] == null || Session["uid"].ToString().Equals(""))
            {
                return RedirectToAction("Index", "Home");
            }
            if ((int)Session["user_type"] < User_Type.POLL_CREATOR)
            {
                return RedirectToAction("Invalid", "Home");
            }
            int weightInt = 0;
            int ansnumInt = 0;
            if (!int.TryParse(weight, out weightInt) || weight == null)
            {
                ViewData["weighterror"] = "Above field must contain a number!";
                //errorspresent = true;
            }

            if (answer == "")
            {
                ViewData["answererror"] = "Above field must contain an answer!";
            }

            if (!int.TryParse(ansnum, out ansnumInt))
            {
                ViewData["ansnumerror"] = "Answer Number must contain a number!";
            }

            CultureInfo culture = new CultureInfo("en-AU");
            culture.DateTimeFormat.ShortDatePattern = "d/M/yyyy";
            culture.DateTimeFormat.ShortTimePattern = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;

            try
            {
               answerModel a = new answerModel();
               a = a.getAnswer(answerid);

               /* Create a record of the old answer in the Answer History table */
               new answerHistoryModel(answerid).createAnswerHistory(a.answerid, a.answer, a.correct, a.weight, a.ansnum);

               /* Update the answer*/
               a.updateAnswer(answerid, answer, correct, int.Parse(weight), int.Parse(ansnum));

               ViewData["questionid"] = questionid;

               ViewData["edited"] = "Updated Answer: " + answer;
               return View(a);
            }
            catch(Exception e)
            {
                ViewData["weighterror"] = "OMG THERE IS AN ERROR "+ e.Message;
                answerModel a = new answerModel().getAnswer(answerid);
                ViewData["questionid"] = questionid;
                return View(a);
            }
        }