Beispiel #1
0
        public async Task <IActionResult> List(
            [FromServices] ITestcaseStore tcs,
            int pid, bool all = false, int page = 1)
        {
            if (page < 0)
            {
                return(NotFound());
            }

            Expression <Func <Submission, bool> > cond =
                s => s.ProblemId == pid;

            if (!all)
            {
                cond = cond.Combine(s => s.ExpectedResult != null);
            }

            var(result, totPage) = await Submissions.ListWithJudgingAsync((page, 30), cond, true);

            totPage = (totPage - 1) / 30 + 1;

            if (result.Any())
            {
                var id1 = result.First().SubmissionId;
                var id2 = result.Last().SubmissionId;
                if (id1 > id2)
                {
                    (id1, id2) = (id2, id1);
                }
                var cond2 = cond.Combine(s => s.SubmissionId >= id1 && s.SubmissionId <= id2);
                var names = await Submissions.GetAuthorNamesAsync(cond2);

                foreach (var item in result)
                {
                    item.AuthorName = names.GetValueOrDefault(item.SubmissionId, "SYSTEM");
                }
            }

            ViewBag.TotalPage = totPage;
            ViewBag.Page      = page;
            ViewBag.AllSub    = all;
            ViewBag.Testcase  = await tcs.ListAsync(pid);

            return(View(result));
        }