public ActionResult Description(string id, string contest, ProblemContentModel model) { if (!ModelState.IsValid) return View(model); switch (model.Action) { case ProblemContentModel.ActionType.Preview: return View(model); case ProblemContentModel.ActionType.Modify: try { Problem problem = Contest.ByName(contest).ProblemByName(id); problem.Content = model.Content; problem.Change(); } 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; } catch (UserNotFoundException) { throw; } return RedirectToAction("TestCase", new { id = id, contest = contest }); } throw new NotImplementedException(); }
public ActionResult Description(string contest, string id) { ProblemContentModel model = new ProblemContentModel { Contest = contest, Problem = id }; try { Problem problem = Contest.ByName(contest).ProblemByName(id); if (problem.Content == null) { return RedirectToAction("Error", "Shared", new { msg = "无法查看题目内容" }); } model.Content = problem.Content; model.ProblemOwner = problem.Owner; } catch (ContestNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到所需的比赛" }); } catch (ProblemNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到所需的题目" }); } return View(model); }