Beispiel #1
0
        public ActionResult Update(QAModel model)
        {
            //try
            //{
            Question question = model.question;

            QuestionWS Qws       = new QuestionWS();
            DBUtil     objDBUtil = new DBUtil(3);

            DataSet AddQuestion = Qws.WriteQuestion(question, 2, this);

            if (AddQuestion.RowsExists())
            {
                //taking from 0th table because it will accomodate updates from other users as well

                if (int.Parse(AddQuestion.Tables[0].Rows[0]["StatusCode"].ToString()) == 1)
                {
                    TempData["StatusMsg"] = AddQuestion.Tables[0].Rows[0]["StatusMsg"].ToString();
                }

                return(RedirectToActionPermanent("Details", "Questions", new { QuestionId = model.question.QuestionId }));
            }
            //}
            //catch { }

            ModelState.AddModelError("", "An error occured while updating the question");
            return(RedirectPermanent(this.GetRequestReferrer()));
        }
Beispiel #2
0
        public ActionResult Create(QAModel model)
        {
            Question question = model.question;

            try
            {
                QuestionWS Qws       = new QuestionWS();
                DBUtil     objDBUtil = new DBUtil(3);

                DataSet AddQuestion = Qws.WriteQuestion(question, 1, this);
                if (AddQuestion.RowsExists())
                {
                    int resTbl = AddQuestion.Tables.Count - 1;
                    TempData["StatusMsg"] = AddQuestion.Tables[resTbl].Rows[0]["StatusMsg"].ToString();
                    if (int.Parse(AddQuestion.Tables[resTbl].Rows[0]["StatusCode"].ToString()) == 1)
                    {
                        question.QuestionId = int.Parse(AddQuestion.Tables[resTbl].Rows[0]["QuestionId"].ToString());
                    }
                    else if (int.Parse(AddQuestion.Tables[resTbl].Rows[0]["StatusCode"].ToString()) == 9)
                    {
                        question.QuestionId = int.Parse(AddQuestion.Tables[resTbl].Rows[0]["Duplicate QuestionId"].ToString());
                    }

                    return(RedirectToActionPermanent("Details", "Questions", new { QuestionId = model.question.QuestionId }));
                }
            }
            catch { }

            ModelState.AddModelError("", "An error occured while adding the question");
            return(View(model));
        }