public JsonResult SaveData() { if (IsPreview == false) { List <QuestionAnswerViewModel> q = AccountController.GetQuestionAnswer(); RespondentViewModel r = AccountController.GetRespondent(); if (q != null) { foreach (var item in q) { item.AddQuestionAnswer(item); } } if (r != null) { r.AddRespondent(r); foreach (var item in r.Responses) { item.AddResponse(item); } } } AccountController.ClearQuestionAnswer(); AccountController.ClearQuestion(); return(Json(true, JsonRequestBehavior.AllowGet)); }
//public ActionResult Index(Guid id) //{ // if (id != null) // { // UpdateList(); // SurveyViewModel s = listSurvey.Find(l => l.Id == id); // if (s != null) // { // IsPreview = false; // ViewBag.Survey = id; // } // } // return View(); //} //-------------------------ajax called------------------------ public JsonResult Initialization(string id) { List <QuestionViewModel> q = new List <QuestionViewModel>(); AccountController.ClearRespondent(); AccountController.ClearQuestionAnswer(); var questions = db.Questions.Where(x => x.SurveyId == new Guid(id)).ToList(); if (questions != null) { foreach (var item in questions) { q.Add(new QuestionViewModel(item)); } foreach (var item in q) { item.GetAnimateViewList(); item.GetQuestionAnswerViewList(); } } return(Json(q.OrderBy(x => x.Number), JsonRequestBehavior.AllowGet)); }