Exemple #1
0
        public async Task <IActionResult> OnPostCreateSampleAsync()
        {
            if ((await GetModifyAuthorization()) == false)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                ShowId = PostData.TestCaseId;
                if (await GetData(PostData.ProblemId))
                {
                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }

            HttpClient     httpclient = clientFactory.CreateClient();
            ProblemsClient client     = new ProblemsClient(httpclient);

            try
            {
                TestCaseMetadata tmeta = await client.CreateSampleAsync(PostData.ProblemId, PostData.TestCase);

                return(RedirectToPage(new { id = PostData.ProblemId, showId = tmeta.Id }));
            }
            catch
            {
                return(NotFound());
            }
        }
Exemple #2
0
        public async Task <ITestCaseProvider> Create(TestCaseMetadata metadata)
        {
            TestCase empty = new TestCase {
                ProblemId = _problemId, IsSample = _isSample
            };

            _context.Tests.Add(empty);
            await _context.SaveChangesAsync();

            TestCaseProvider res = new TestCaseProvider(_workspace, _context, empty);

            Directory.CreateDirectory(res.GetRoot());
            await res.SetMetadata(metadata);

            return(res);
        }
 public async Task SetMetadata(TestCaseMetadata value)
 {
     _testcase.MemoryLimit = value.MemoryLimit;
     _testcase.TimeLimit   = value.TimeLimit;
     await _context.SaveChangesAsync();
 }