public ActionResult TestCase(string id, string contest, TestCaseUploadModel model)
 {
     if (model.TestCases == null)
     {
         model.TestCases = new List<TestCaseInfo>();
     }
     if (!ModelState.IsValid) return View(model);
     ModelState.Clear();
     try
     {
         Contest con = Contest.ByName(contest);
         Problem problem = con.ProblemByName(id);
         foreach (var testCase in model.TestCases)
         {
             if (con.Type == Contest.ContestType.CF)
             {
                 ContestHunter.Models.Domain.TestCase.Change(testCase.ID, (int)(testCase.Time * 1000), (int)(testCase.Memory * 1024 * 1024), testCase.Enabled);
             }
             else
             {
                 ContestHunter.Models.Domain.TestCase.Change(testCase.ID, (int)(testCase.Time * 1000), (int)(testCase.Memory * 1024 * 1024), true);
             }
         }
         switch (model.Action)
         {
             case TestCaseUploadModel.ActionType.Upload:
                 var newCases = AddTestCase(con, problem, model.File);
                 if (newCases != null)
                 {
                     foreach (var t in newCases.Select(TestCase2Info))
                     {
                         model.TestCases.Add(t);
                     }
                 }
                 break;
             case TestCaseUploadModel.ActionType.Next:
                 return RedirectToAction("Program", new { id = id, contest = contest });
             case TestCaseUploadModel.ActionType.Delete:
                 problem.RemoveTestCase(model.TestCases[model.TestCaseIndex].ID);
                 model.TestCases.RemoveAt(model.TestCaseIndex);
                 break;
         }
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" });
     }
     catch (ProblemNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有找到相关题目" });
     }
     catch (PermissionDeniedException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "您不具备维护此题测试数据的相关权限" });
     }
     catch (UserNotLoginException)
     {
         throw;
     }
     return View(model);
 }
 public ActionResult TestCase(string id, string contest)
 {
     TestCaseUploadModel model = new TestCaseUploadModel
     {
         Contest = contest,
         Problem = id
     };
     try
     {
         Contest con = Contest.ByName(contest);
         Problem problem = con.ProblemByName(id);
         model.TestCases = (from t in problem.TestCases()
                            select TestCase2Info(problem.TestCaseByID(t))).ToList();
         model.ShowEnabled = con.Type == Contest.ContestType.CF;
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" });
     }
     catch (ProblemNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有找到相关题目" });
     }
     return View(model);
 }