public ActionResult Preview(string id, ContestDescriptionModel model) { if (!ModelState.IsValid) return View(model); switch (model.Action) { case ContestDescriptionModel.ActionType.Preview: return View(model); case ContestDescriptionModel.ActionType.Next: try { Contest contest = Contest.ByName(id); contest.Description = model.Description; contest.Change(); } catch (ContestNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" }); } catch (UserNotLoginException) { throw; } catch (PermissionDeniedException) { return RedirectToAction("Error", "Shared", new { msg = "没有修改比赛预告的相关权限" }); } catch (ContestNameExistedException) { throw; } return RedirectToAction("Problems", new { id = id }); } throw new NotImplementedException(); }
public ActionResult Preview(string id) { ContestDescriptionModel model = new ContestDescriptionModel { Contest = id }; try { Contest contest = Contest.ByName(id); model.Description = contest.Description; } catch (ContestNotFoundException) { return RedirectToAction("Error", "Shared", new { msg = "没有找到相关比赛" }); } return View(model); }