public ActionResult CreateTestCase(int ProblemID) { string name=HttpContext.User.Identity.Name; if(name!=null) { if (checkRole.IsLecturer(name)) { ViewBag.MaDB = ProblemID; Problem p=db.Problems.FirstOrDefault(m=>m.ID==ProblemID); TestCaseModels testcaseModel = new TestCaseModels(); testcaseModel.problem = p; return View(testcaseModel); } else return RedirectToAction("Index", "Home"); } else return RedirectToAction("Index", "Home"); }
public ActionResult CreateTestCase(TestCaseModels testcaseModel ) { string name=HttpContext.User.Identity.Name; if(name!=null) { if (checkRole.IsLecturer(name)) { TestCas testcase = new TestCas(); testcase.MaDB = testcaseModel.MaDB; testcase.Input = testcaseModel.Input; testcase.Output = testcaseModel.Output; testcase.Diem = testcaseModel.Diem; testcase.MoTa = testcaseModel.MoTa; db.TestCases.AddObject(testcase); db.SaveChanges(); return RedirectToAction("CreateTestCase", new { ProblemID = testcase.MaDB }); } else return RedirectToAction("Index", "Home"); } else return RedirectToAction("Index", "Home"); }