public IHttpActionResult Puttbl_Questions(long id, tbl_Questions tbl_Questions) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_Questions.QuestionID) { return(BadRequest()); } db.Entry(tbl_Questions).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbl_QuestionsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult UpdateQuiz(int quizid, tbl_Questions qs, string hid_qids, FormCollection coll) { using (OnlineQuizEntities oq = new OnlineQuizEntities()) { ModelState.Clear(); } return(RedirectToAction("AfterLogin")); }
public IHttpActionResult Gettbl_Questions(long id) { tbl_Questions tbl_Questions = db.tbl_Questions.Find(id); if (tbl_Questions == null) { return(NotFound()); } return(Ok(tbl_Questions)); }
public IHttpActionResult Posttbl_Questions(tbl_Questions tbl_Questions) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbl_Questions.Add(tbl_Questions); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tbl_Questions.QuestionID }, tbl_Questions)); }
public IHttpActionResult Deletetbl_Questions(long id) { tbl_Questions tbl_Questions = db.tbl_Questions.Find(id); if (tbl_Questions == null) { return(NotFound()); } db.tbl_Questions.Remove(tbl_Questions); db.SaveChanges(); return(Ok(tbl_Questions)); }
// GET: Quiz public ActionResult Index(tbl_Questions q, tbl_Quiz qq, QuizQuestions qqq, string QuizId) { QuizQuestions qqs = new QuizQuestions(); if (QuizId != null && QuizId != "") { //qqs = ViewBag.Quiz; using (OnlineQuizEntities oq = new OnlineQuizEntities()) { if (TempData["quizdrpdwn"] as QuizQuestions == null) { var quizdata = oq.tbl_Quiz.ToList(); foreach (var item in quizdata) { qqs.QuizList.Add(new SelectListItem { Text = item.QuizName, Value = item.QuizId.ToString() }); } TempData["quizdrpdwn"] = qq; } else { qqs = TempData["quizdrpdwn"] as QuizQuestions; } var allqs = oq.tbl_Questions.ToList(); var allquizqu = oq.tbl_QuizQuestionRelation.ToList(); var quizqus = allquizqu.Where(a => a.QuizId == Convert.ToInt32(QuizId)).ToList(); List <tbl_Questions> actualqs = new List <tbl_Questions>(); allqs.Intersect <tbl_Questions>(allqs); var resp = from a in allqs join b in quizqus on a.QuestionId equals b.QuestionId select a; foreach (var item in resp) { actualqs.Add(item); } ViewBag.AllQuestions = actualqs; } return(View("Quiz", qqs)); } return(View("Quiz", qqs)); }
public ActionResult Create(tbl_Questions q) { //if (ModelState.IsValid) //{ using (OnlineQuizEntities oq = new OnlineQuizEntities()) { q.IsMultipleChoise = true; oq.tbl_Questions.Add(q); oq.SaveChanges(); } ModelState.Clear(); ViewBag.Message = "Question Added Successfully"; //} return(View("Create")); }
public void PostItemResource(ItemResource item) { using (var context = new SurveyEntities()) { tbl_Questions que = new tbl_Questions { itemScript = item.questionScript, createdBy = "Ravi", createdDate = System.DateTime.Now, state = 1, status = "live" }; context.tbl_Questions.Add(que); context.SaveChanges(); } }
public ActionResult Create(tbl_Questions q) { if (ModelState.IsValid) { using (OnlineQuizEntities oq = new OnlineQuizEntities()) { oq.tbl_Questions.Add(q); oq.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Question Added Successfully"; return(View("Create")); } } else { ViewBag.Message = "Please provide all the values"; return(View(q)); } }
public ActionResult UpdateQuiz(int quizid, tbl_Questions qs, string hid_qids) { using (OnlineQuizEntities oq = new OnlineQuizEntities()) { if (hid_qids == null) { hid_qids = "1,3"; } foreach (var qids in hid_qids.Split(',')) { tbl_QuizQuestionRelation qq = new tbl_QuizQuestionRelation(); qq.QuestionId = Convert.ToInt32(qids); qq.QuizId = quizid; oq.tbl_QuizQuestionRelation.Add(qq); oq.SaveChanges(); } ModelState.Clear(); } return(RedirectToAction("AfterLogin")); }