public ActionResult Edit(Questions Sessions) { Sessions.QuestionID = (int)Session["ID"]; if (ModelState.IsValid) { db.Entry(Sessions).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Overview"); } return View(Sessions); }
public ActionResult SessionCreate(Questions Sessions) { int gen; while (true) { gen = numGen.Gen(4); var result = (from s in db.Questions where s.code == gen select s).Any(); if (!result) break; } Sessions.code = gen; db.Questions.Add(Sessions); db.SaveChanges(); return RedirectToAction("Overview", new { code = Sessions.code }); }