Exemplo n.º 1
0
        public async Task <ActionResult <ProblemMetadata> > Create([FromBody] ProblemData data)
        {
            IProblemProvider res = await _workspace.Problems.Create(data.Metadata);

            await res.SetDescription(data.Description);

            if (data.Samples != null)
            {
                foreach (TestCaseData v in data.Samples)
                {
                    ITestCaseProvider item = await res.Samples.Create(v.Metadata);
                    await UpdateIOData(v, item);
                }
            }

            if (data.Tests != null)
            {
                foreach (TestCaseData v in data.Tests)
                {
                    ITestCaseProvider item = await res.Tests.Create(v.Metadata);
                    await UpdateIOData(v, item);
                }
            }

            return(Created($"problems/{res.Id}", await res.GetMetadata()));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ProblemMetadata> > Import([FromBody] ProblemPackage data)
        {
            IProblemProvider res = await _workspace.Problems.Create(data.Metadata);

            await res.SetDescription(data.Description);

            if (data.Samples != null)
            {
                foreach (ProblemPackage.TestCasePackage v in data.Samples)
                {
                    ITestCaseProvider item = await res.Samples.Create(v.Metadata);
                    await UpdateIOData(new TestCaseData
                    {
                        Input  = v.Input,
                        Output = v.Output
                    }, item);
                }
            }

            if (data.Tests != null)
            {
                foreach (ProblemPackage.TestCasePackage v in data.Tests)
                {
                    ITestCaseProvider item = await res.Tests.Create(v.Metadata);
                    await UpdateIOData(new TestCaseData
                    {
                        Input  = v.Input,
                        Output = v.Output
                    }, item);
                }
            }

            return(Created($"problems/{res.Id}", await res.GetMetadata()));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> UpdateDescription(string id, [FromBody] ProblemDescription data)
        {
            IProblemProvider res = await _workspace.Problems.Get(id);

            if (res == null)
            {
                return(NotFound());
            }

            await res.SetDescription(data);

            return(Accepted());
        }