public GenericRepository(IOjsDbContext context) { if (context == null) { throw new ArgumentException("An instance of DbContext is required to use this repository.", nameof(context)); } this.Context = context; this.DbSet = this.Context.Set <T>(); }
public OjsData(IOjsDbContext context) { this.context = context; }
private void SeedCategoryContestProblem(IOjsDbContext context) { foreach (var categoryToBeDeleted in context.ContestCategories) { context.ContestCategories.Remove(categoryToBeDeleted); } foreach (var contestToBeDeleted in context.Contests) { context.Contests.Remove(contestToBeDeleted); } foreach (var problemToBeDeleted in context.Problems) { context.Problems.Remove(problemToBeDeleted); } var category = new ContestCategory { Name = "Category", OrderBy = 1, IsVisible = true, IsDeleted = false, }; var otherCategory = new ContestCategory { Name = "Other Category", OrderBy = 1, IsVisible = true, IsDeleted = false, }; var contest = new Contest { Name = "Contest", OrderBy = 1, PracticeStartTime = DateTime.Now.AddDays(-2), StartTime = DateTime.Now.AddDays(-2), IsVisible = true, IsDeleted = false, Category = category }; var otherContest = new Contest { Name = "Other Contest", OrderBy = 2, PracticeStartTime = DateTime.Now.AddDays(-2), StartTime = DateTime.Now.AddDays(-2), IsVisible = true, IsDeleted = false, Category = category }; var problemGroup1 = new ProblemGroup { OrderBy = 0, Contest = contest }; var problemGroup2 = new ProblemGroup { OrderBy = 1, Contest = contest }; var problem = new Problem { Name = "Problem", MaximumPoints = 100, TimeLimit = 10, MemoryLimit = 10, OrderBy = 1, ShowResults = true, IsDeleted = false, ProblemGroup = problemGroup1 }; var otherProblem = new Problem { Name = "Other Problem", MaximumPoints = 100, TimeLimit = 10, MemoryLimit = 10, OrderBy = 1, ShowResults = true, IsDeleted = false, ProblemGroup = problemGroup2 }; var test = new Test { InputDataAsString = "Input", OutputDataAsString = "Output", OrderBy = 0, IsTrialTest = false, Problem = problem, }; var user = new UserProfile { UserName = "******", Email = "*****@*****.**" }; var participant = new Participant { Contest = contest, IsOfficial = false, User = user }; var submission = new Submission { Problem = problem, Participant = participant, CreatedOn = DateTime.Now }; for (int i = 0; i < 10; i++) { test.TestRuns.Add(new TestRun { MemoryUsed = 100, TimeUsed = 100, CheckerComment = "Checked!", ExecutionComment = "Executed!", ResultType = TestRunResultType.CorrectAnswer, Submission = submission }); } context.Problems.Add(problem); context.Problems.Add(otherProblem); context.Contests.Add(otherContest); context.ContestCategories.Add(otherCategory); context.Tests.Add(test); }
public ValidateRemoteDataApiKeyFilter(IOjsDbContext context) => this.userManager = new OjsUserManager <UserProfile>(new UserStore <UserProfile>(context.DbContext));
public DeletableEntityRepository(IOjsDbContext context) : base(context) { }
public TestRunsRepository(IOjsDbContext context) : base(context) { }
public ParticipantsRepository(IOjsDbContext context) : base(context) { }
public SubmissionsRepository(IOjsDbContext context) : base(context) { }
private void SeedContests(IOjsDbContext context) { // active contests var visibleActiveContest = new Contest { Name = "Active-Visible", IsVisible = true, IsDeleted = false, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(2), }; var nonVisibleActiveContest = new Contest { Name = "Active-Non-Visible", IsVisible = false, IsDeleted = false, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(2) }; var visibleDeletedActiveContest = new Contest { Name = "Active-Visible-Deleted", IsVisible = true, IsDeleted = true, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(2) }; var nonVisibleDeletedActiveContest = new Contest { Name = "Active-Non-Visible-Deleted", IsVisible = false, IsDeleted = true, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(2) }; // past contests var visiblePastContest = new Contest { Name = "Past-Visible", IsVisible = true, IsDeleted = false, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(-1) }; var nonVisiblePastContest = new Contest { Name = "Past-Non-Visible", IsVisible = false, IsDeleted = false, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(-1) }; var visiblePastDeletedContest = new Contest { Name = "Past-Visible-Deleted", IsVisible = true, IsDeleted = true, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(-1) }; var nonVisiblePastDeletedContest = new Contest { Name = "Past-Non-Visible-Deleted", IsVisible = false, IsDeleted = true, StartTime = DateTime.Now.AddHours(-2), EndTime = DateTime.Now.AddHours(-1) }; // future contests var visibleFutureContest = new Contest { Name = "Future-Visible", IsVisible = true, IsDeleted = false, StartTime = DateTime.Now.AddHours(1), EndTime = DateTime.Now.AddHours(2) }; var nonVisibleFutureContest = new Contest { Name = "Future-Non-Visible", IsVisible = false, IsDeleted = false, StartTime = DateTime.Now.AddHours(1), EndTime = DateTime.Now.AddHours(2) }; var visibleFutureDeletedContest = new Contest { Name = "Future-Visible-Deleted", IsVisible = true, IsDeleted = true, StartTime = DateTime.Now.AddHours(1), EndTime = DateTime.Now.AddHours(2) }; var nonVisibleFutureDeletedContest = new Contest { Name = "Future-Non-Visible-Deleted", IsVisible = false, IsDeleted = true, StartTime = DateTime.Now.AddHours(1), EndTime = DateTime.Now.AddHours(2) }; var contests = new List <Contest>() { // active contests in list (Contest)visibleActiveContest.ObjectClone(), (Contest)visibleActiveContest.ObjectClone(), (Contest)nonVisibleActiveContest.ObjectClone(), (Contest)nonVisibleActiveContest.ObjectClone(), (Contest)nonVisibleActiveContest.ObjectClone(), (Contest)visibleDeletedActiveContest.ObjectClone(), (Contest)visibleDeletedActiveContest.ObjectClone(), (Contest)visibleDeletedActiveContest.ObjectClone(), (Contest)visibleDeletedActiveContest.ObjectClone(), (Contest)nonVisibleDeletedActiveContest.ObjectClone(), // past contest in list (Contest)visiblePastContest.ObjectClone(), (Contest)visiblePastContest.ObjectClone(), (Contest)visiblePastContest.ObjectClone(), (Contest)nonVisiblePastContest.ObjectClone(), (Contest)nonVisiblePastContest.ObjectClone(), (Contest)nonVisiblePastContest.ObjectClone(), (Contest)nonVisiblePastContest.ObjectClone(), (Contest)visiblePastDeletedContest.ObjectClone(), (Contest)visiblePastDeletedContest.ObjectClone(), (Contest)visiblePastDeletedContest.ObjectClone(), (Contest)visiblePastDeletedContest.ObjectClone(), (Contest)nonVisiblePastDeletedContest.ObjectClone(), // future contests in list (Contest)visibleFutureContest.ObjectClone(), (Contest)visibleFutureContest.ObjectClone(), (Contest)visibleFutureContest.ObjectClone(), (Contest)visibleFutureContest.ObjectClone(), (Contest)nonVisibleFutureContest.ObjectClone(), (Contest)nonVisibleFutureContest.ObjectClone(), (Contest)nonVisibleFutureContest.ObjectClone(), (Contest)visibleFutureDeletedContest.ObjectClone(), (Contest)visibleFutureDeletedContest.ObjectClone(), (Contest)visibleFutureDeletedContest.ObjectClone(), (Contest)visibleFutureDeletedContest.ObjectClone(), (Contest)visibleFutureDeletedContest.ObjectClone(), (Contest)nonVisibleFutureDeletedContest.ObjectClone(), }; foreach (var contest in contests) { context.Contests.Add(contest); } context.SaveChanges(); }
protected OjsData(IOjsDbContext context) => this.context = context;
public UsersRepository(IOjsDbContext context) : base(context) { }
public ProblemsRepository(IOjsDbContext context) : base(context) { }
public FakeOjsData(IOjsDbContext context) : base(context) { }
public ContestsRepository(IOjsDbContext context) : base(context) { }