public ActionResult Create(Quiz quiz) { if (ModelState.IsValid) { quiz.CreatedDate = DateTime.Now; quiz.LastModifiedDate = DateTime.Now; db.Quizes.Add(quiz); db.SaveChanges(); return RedirectToAction("Quizes", "Dashboard", new { id = quiz.CourseId}); } ViewBag.CourseId = quiz.Id; return View(quiz); }
public ActionResult Edit(Quiz editedQuiz) { if (ModelState.IsValid) { var quiz = db.Quizes.Find(editedQuiz.Id); quiz.Name = editedQuiz.Name; quiz.Order = editedQuiz.Order; quiz.QuestionAmount = editedQuiz.QuestionAmount; quiz.Description = editedQuiz.Description; quiz.Attempts = editedQuiz.Attempts; quiz.LastModifiedDate = DateTime.Now; db.SaveChanges(); return RedirectToAction("Quizes", "Dashboard", new { id = editedQuiz.Id}); } return View(editedQuiz); }