public ActionResult getdata() { try { using (HapinessSurveyEntities entities = new HapinessSurveyEntities()) { var listvalue = (from q in entities.questiontbls select q).ToList(); List <Questionmodel> questions = new List <Questionmodel>(); foreach (var item in listvalue) { Questionmodel question = new Questionmodel(); question.q_id = item.q_id; question.questions = item.question; questions.Add(question); } // List<questiontbl> listvalue = entities.questiontbls.ToList<questiontbl>(); return(Json(new { data = questions }, JsonRequestBehavior.AllowGet)); } }catch (Exception ex) { throw; } }
public ActionResult Create() { var addque = new Questionmodel(); addque.questions = ""; return(View("Create")); }
public ActionResult Edit(Questionmodel questionmodel) { try { using (HapinessSurveyEntities entities = new HapinessSurveyEntities()) { var modiques = entities.questiontbls.Where(a => a.q_id.Equals(questionmodel.q_id)).First(); // questionmodel.q_id = modiques.q_id; // List < Questionmodel > qlist = new List<Questionmodel>(); modiques.question = questionmodel.questions; entities.SaveChanges(); return(View("question")); } } catch (Exception) { throw; } //eturn View("Edit", questionmodel); }
public ActionResult Edit(int?ID) { try { using (HapinessSurveyEntities entities = new HapinessSurveyEntities()) { Questionmodel questionmodel = new Questionmodel(); List <Questionmodel> qlist = new List <Questionmodel>(); var question = (from q in entities.questiontbls where q.q_id == ID select q).FirstOrDefault(); questionmodel.q_id = question.q_id; questionmodel.questions = question.question; return(View("Edit", questionmodel)); } } catch (Exception) { throw; } }
public ActionResult Create(Questionmodel questionmodel) { try { using (HapinessSurveyEntities entities = new HapinessSurveyEntities()) { //var addques = entities.questiontbls.Where(a => a.q_id.Equals(questionmodel.q_id)).First(); questiontbl ques = new questiontbl(); // List < Questionmodel > qlist = new List<Questionmodel>(); ques.question = questionmodel.questions; entities.questiontbls.Add(ques); entities.SaveChanges(); return(View("question")); } } catch (Exception) { throw; } // return View("Edit"); }