public ActionResult Add(string contest)
 {
     ProblemBasicInfoModel model = new ProblemBasicInfoModel
     {
         Contest = contest
     };
     try
     {
         Contest con = Contest.ByName(contest);
         model.ContestType = con.Type;
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有这场比赛" });
     }
     return View(model);
 }
 public ActionResult Add(string contest, ProblemBasicInfoModel model)
 {
     if (!ModelState.IsValid) return View(model);
     try
     {
         Contest con = Contest.ByName(contest);
         con.AddProblem(new Problem
         {
             Content = System.IO.File.ReadAllText(Server.MapPath("~/Content/ProblemTemplate.html")),
             Name = model.Name,
             Comparer = "",
             DataChecker = "",
             ComparerLanguage = Record.LanguageType.CPP,
             DataCheckerLanguage = Record.LanguageType.CPP,
             OriginRating = model.OriginalRating,
             Owner = model.Owner
         });
     }
     catch (ProblemNameExistedException)
     {
         ModelState.AddModelError("Name", "题目名已存在");
         return View(model);
     }
     catch (UserNotFoundException)
     {
         ModelState.AddModelError("Owner", "没有这个用户");
         return View(model);
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没找到相应比赛" });
     }
     catch (PermissionDeniedException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有添加比赛权限" });
     }
     catch (UserNotLoginException)
     {
         throw;
     }
     return RedirectToAction("Description", new { id = model.Name, contest = contest });
 }
 public ActionResult Edit(string id, string contest, ProblemBasicInfoModel model)
 {
     if (!ModelState.IsValid) return View(model);
     try
     {
         Contest con = Contest.ByName(contest);
         Problem problem = con.ProblemByName(id);
         problem.Name = model.Name;
         problem.OriginRating = model.OriginalRating;
         problem.Owner = model.Owner;
         problem.Change();
         model.Name = problem.Name;
     }
     catch (ProblemNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有这个题目" });
     }
     catch (ProblemNameExistedException)
     {
         ModelState.AddModelError("Name", "题目名已存在");
         return View(model);
     }
     catch (UserNotFoundException)
     {
         ModelState.AddModelError("Owner", "没有这个用户");
         return View(model);
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没找到相应比赛" });
     }
     catch (PermissionDeniedException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有添加比赛权限" });
     }
     catch (UserNotLoginException)
     {
         throw;
     }
     return RedirectToAction("Description", new { id = model.Name, contest = contest });
 }
 public ActionResult Edit(string id, string contest)
 {
     ProblemBasicInfoModel model = new ProblemBasicInfoModel
     {
         Contest = contest,
         Problem = id
     };
     try
     {
         Contest con = Contest.ByName(contest);
         Problem problem = con.ProblemByName(id);
         model.Owner = problem.Owner;
         model.OriginalRating = problem.OriginRating.Value;
         model.ContestType = con.Type;
         model.Name = problem.Name;
     }
     catch (ContestNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有找到相应的比赛" });
     }
     catch (ProblemNotFoundException)
     {
         return RedirectToAction("Error", "Shared", new { msg = "没有这个题目" });
     }
     return View(model);
 }