public async Task <IActionResult> Home(int cid, [FromServices] ISubmissionStore submits, [FromServices] IClarificationStore clars) { int teamid = Team.TeamId; var board = await FindScoreboardAsync(teamid); ViewBag.Clarifications = await clars.ListAsync(cid, c => (c.Sender == null && c.Recipient == null) || c.Recipient == teamid || c.Sender == teamid); ViewBag.Submissions = await submits.ListWithJudgingAsync( predicate : s => s.ContestId == cid && s.Author == teamid, selector : (s, j) => new SubmissionViewModel { Grade = j.TotalScore ?? 0, Language = Languages[s.Language], SubmissionId = s.SubmissionId, Time = s.Time, Verdict = j.Status, Problem = Problems.Find(s.ProblemId), }); return(View(board)); }
public async Task <IActionResult> Clarification( [FromServices] IClarificationStore claris, int cid, int clarid, bool needMore = true) { var toSee = await claris.FindAsync(cid, clarid); var clars = Enumerable.Empty <Clarification>(); if (toSee?.CheckPermission(Team.TeamId) ?? true) { clars = clars.Append(toSee); if (needMore && toSee.ResponseToId.HasValue) { int respid = toSee.ResponseToId.Value; var toSee2 = await claris.FindAsync(cid, respid); if (toSee2 != null) { clars = clars.Prepend(toSee2); } } } if (!clars.Any()) { return(NotFound()); } ViewData["TeamName"] = Team.TeamName; return(Window(clars)); }
public async Task <IActionResult> Clarification( string op, AddClarificationModel model, [FromServices] IClarificationStore clars) { var(cid, teamid) = (Contest.ContestId, Team.TeamId); int repl = 0; if (op != "add" && !int.TryParse(op, out repl)) { return(NotFound()); } var replit = await clars.FindAsync(cid, repl); if (repl != 0 && replit == null) { ModelState.AddModelError("xys::replyto", "The clarification replied to is not found."); } if (string.IsNullOrWhiteSpace(model.Body)) { ModelState.AddModelError("xys::empty", "No empty clarification"); } var usage = ClarCategories.SingleOrDefault(cp => model.Type == cp.Item1); if (usage.Item1 == null) { ModelState.AddModelError("xys::error_cate", "The category specified is wrong."); } if (!ModelState.IsValid) { StatusMessage = string.Join('\n', ModelState.Values .SelectMany(m => m.Errors) .Select(e => e.ErrorMessage)); } else { int id = await clars.SendAsync( new Clarification { Body = model.Body, SubmitTime = DateTimeOffset.Now, ContestId = cid, Sender = teamid, ResponseToId = model.ReplyTo, ProblemId = usage.Item3, Category = usage.Item2, }); await HttpContext.AuditAsync("added", $"{id}"); StatusMessage = "Clarification sent to the jury."; } return(RedirectToAction(nameof(Home))); }
public async Task <IActionResult> Updates(int cid, [FromServices] IClarificationStore clars, [FromServices] ITeamStore teams, [FromServices] IRejudgingStore rejs) { return(Json(new { clarifications = await clars.GetJuryStatusAsync(cid), teams = await teams.GetJuryStatusAsync(cid), rejudgings = await rejs.GetJuryStatusAsync(cid) })); }
public async Task <IActionResult> Home(int cid, [FromServices] IProblemFileRepository io, [FromServices] IClarificationStore clars) { ViewBag.Statistics = await Facade.StatisticAcceptedAsync(cid); int?teamid = Team?.TeamId; ViewBag.Clarifications = await clars.ListAsync(cid, c => c.Recipient == null && c.Sender == null); var readme = io.GetFileInfo($"c{cid}/readme.html"); ViewBag.Markdown = await readme.ReadAsync(); return(View()); }
public ClarificationsController(IClarificationStore store) => Store = store;