public ActionResult Problems(string id, ContestProblemsModel model) { if (!ModelState.IsValid) return View(model); ModelState.Clear(); try { Contest contest = Contest.ByName(id); contest.RemoveProblem(model.Problems[model.ProblemIndex].Name); model.Problems.RemoveAt(model.ProblemIndex); } catch (ContestNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" }); } catch (UserNotLoginException) { throw; } catch (ProblemNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到相关题目" }); } return View(model); }
public ActionResult Problems(string id) { ContestProblemsModel model = new ContestProblemsModel { Contest = id }; try { Contest contest = Contest.ByName(id); model.Problems = (from p in contest.Problems().Select(contest.ProblemByName) select new ProblemInfo { Name = p.Name, Owner = p.Owner, TestCaseCount = p.TestCases().Count }).ToList(); } catch (ContestNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" }); } catch (ProblemNotFoundException) { throw; } return View(model); }