Ejemplo n.º 1
0
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            var context = new survey_dbContext();
            var model   = new cmSurveyList(context.SurveyQuestions);
            var result  = View(model);

            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult DeleteQuestion(string data)
        {
            var question = new JavaScriptSerializer().Deserialize <SurveyQuestion>(data);

            var context          = new survey_dbContext();
            var questionToDelete = context.SurveyQuestions.Find(question.Id);

            context.SurveyQuestions.Remove(questionToDelete);
            context.SaveChanges();
            var result = Json(question, JsonRequestBehavior.AllowGet);

            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult SaveQuestion(string data)
        {
            var question         = new JavaScriptSerializer().Deserialize <SurveyQuestion>(data);
            var context          = new survey_dbContext();
            var questionToDelete = context.SurveyQuestions.Find(question.Id);

            if (questionToDelete == null)
            {
                context.SurveyQuestions.Add(question);
            }
            else
            {
                questionToDelete.Question = question.Question;
            }
            context.SaveChanges();
            var result = Json(question, JsonRequestBehavior.AllowGet);

            return(result);
        }