Ejemplo n.º 1
0
        public async Task Delete(string id)
        {
            int     _id  = int.Parse(id);
            Problem item = await _context.Problems.FindAsync(_id);

            if (item != null)
            {
                ProblemProvider prov = new ProblemProvider(_workspace, _context, item);

                await prov.Samples.Clear();

                await prov.Tests.Clear();

                {
                    int[] submis = (from x in _context.Submissions where x.ProblemId == item.Id select x.Id).ToArray();

                    foreach (int s in submis)
                    {
                        await _workspace.Submissions.Delete(s.ToString());
                    }
                }

                _context.Problems.Remove(item);

                await _context.SaveChangesAsync();
            }
        }
Ejemplo n.º 2
0
        public async Task <IProblemProvider> Create(ProblemMetadata metadata)
        {
            Problem empty = new Problem();

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

            ProblemProvider res = new ProblemProvider(_workspace, _context, empty);
            await res.SetMetadata(metadata);

            return(res);
        }