コード例 #1
0
        public ActionResult Create(UBOnlineExam ubonlineexam)
        {
            ubonlineexam.titleId = "title_" + GenerateID();
            //if (ModelState.IsValid)
            if (ubonlineexam != null)
            {
                db.UBOnlineExam.Add(ubonlineexam);
                db.SaveChanges();
                currentQuestionId++;
                if (currentQuestionId > 3)
                    return RedirectToAction("Index");
                else
                    return RedirectToAction("Create", new { id = currentQuestionId });
            }
            var errors = ModelState.Values.SelectMany(v => v.Errors);
            Console.WriteLine(errors.ToString());

            return View(ubonlineexam);
        }
コード例 #2
0
 public ActionResult Edit(UBOnlineExam ubonlineexam)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ubonlineexam).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(ubonlineexam);
 }