Exemplo n.º 1
0
        public ActionResult EditQuestion(int id, string text, string inactive)
        {
            ViewBag.error = "";
            if (id > 0) {
                Boolean inActive = false;
                inActive = (inactive == "on") ? true : false;

                // retrieve the question with the id
                try {
                    B2BDataContext db = new B2BDataContext();
                    B2BQuestion question = new B2BQuestion();
                    question = db.B2BQuestions.Where(x => x.id == id).FirstOrDefault<B2BQuestion>();
                    question.text = text;
                    question.inactive = inActive;
                    db.SubmitChanges();

                    ViewBag.question = question;
                    ViewBag.msg = "The question has been changed.";
                } catch (Exception e) {
                    ViewBag.error = e.Message;
                }
            } else {
                return RedirectToAction("Index");
            }
            return View();
        }
Exemplo n.º 2
0
 public static string DeleteQuestion(int id)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BQuestion question = new B2BQuestion();
         question = db.B2BQuestions.Where(x => x.id == id).FirstOrDefault<B2BQuestion>();
         db.B2BQuestions.DeleteOnSubmit(question);
         db.SubmitChanges();
         return "";
     } catch (Exception) {
         return "Error while deleting";
     }
 }
Exemplo n.º 3
0
 public static B2BQuestion getQuestion(int questionID)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BQuestion question = new B2BQuestion();
         question = db.B2BQuestions.Where(x => x.id == questionID).Select(x => x).FirstOrDefault<B2BQuestion>();
         return question;
     } catch (Exception e) {
         throw new Exception("Could not load the question: " + e.Message);
     }
 }
Exemplo n.º 4
0
 public static void addQuestion(int testID, string text, bool inActive)
 {
     try {
         B2BDataContext db = new B2BDataContext();
         B2BQuestion newQuestion = new B2BQuestion();
         newQuestion.testID = testID;
         newQuestion.text = text;
         newQuestion.date_added = DateTime.Now;
         newQuestion.date_modified = DateTime.Now;
         newQuestion.sort = 1;
         newQuestion.inactive = inActive;
         db.B2BQuestions.InsertOnSubmit(newQuestion);
         db.SubmitChanges();
     } catch (Exception e) {
         throw new Exception("Could not add Question: " + e.Message);
     }
 }