public UcasDataMigrator(ManageCoursesDbContext manageCoursesDbContext, ILogger logger, UcasPayload payload, IClock clock = null, RecruitmentCycle recruitmentCycle = null) { _context = manageCoursesDbContext; _logger = logger; _clock = clock ?? new Clock(); this.payload = payload; _recruitmentCycle = recruitmentCycle; }
/// <summary> /// setup data so we can test /// </summary> /// <param name="email">email of the selected user</param> /// <param name="numOrgs">number og oganisation records to generate</param> /// <param name="numCourses">number of course records to generate</param> private void LoadData(string email, int numOrgs, int numCourses) { Context.Subjects.RemoveRange(Context.Subjects); Context.Save(); int numSubjects = 3; User user = new User { FirstName = "fname", LastName = "lname", Email = email }; Context.Users.Add(user); var recruitmentCycle = new RecruitmentCycle { Year = RecruitmentCycle.CurrentYear }; LoadSubjects(numSubjects); for (var counter = 1; counter <= numOrgs; counter++) { var orgId = "org" + counter; var providerCode = "AB" + counter; Organisation org = new Organisation { Id = counter, OrgId = orgId, Name = "Organisation " + counter }; Context.Organisations.Add(org); Provider provider = new Provider() { Address1 = "add2", Address2 = "add2", Address3 = "add3", Address4 = "add4", Postcode = "AB1 CD2", ProviderCode = providerCode, ProviderName = "Intitution " + counter, RecruitmentCycle = recruitmentCycle }; Context.Providers.Add(provider); LoadCourses(provider, numCourses, Context.Subjects); Context.OrganisationUsers.Add(new OrganisationUser { User = user, Organisation = org }); Context.OrganisationProviders.Add(new OrganisationProvider() { Provider = provider, Organisation = org }); } Context.Save(); }
protected override void Setup() { Service = new TransitionService(Context); var providers = SetupProviders .Select(x => new OrganisationProvider { Provider = x, }).ToList(); var currentRecruitmentCycle = new RecruitmentCycle { Year = RecruitmentCycle.CurrentYear }; foreach (var item in providers) { item.Provider.RecruitmentCycle = currentRecruitmentCycle; } var user = new User { Email = Email, }; Context.Add(user); var org = new Organisation { Name = "Bucks Mega Org", OrgId = "BMO1", OrganisationUsers = new List <OrganisationUser> { new OrganisationUser { User = user, }, }, OrganisationProviders = providers }; Context.Add(org); Context.SaveChanges(); }
public ProviderBuilder WithCycle(RecruitmentCycle recruitmentCycle) { _provider.RecruitmentCycle = recruitmentCycle; return(this); }
public static void AddTestReferenceData(this ManageCoursesDbContext context, string username, RecruitmentCycle recruitmentCycle) { User user = new User { FirstName = "Joe", LastName = "Bloggs", Email = username, AcceptTermsDateUtc = DateTime.UtcNow }; context.Users.Add(user); Organisation organisation = new Organisation { Name = "Joe's school", OrgId = "123" }; context.Organisations.Add(organisation); Provider provider = new Provider { ProviderName = "Joe's school @ UCAS", ProviderCode = "ABC", RecruitmentCycle = recruitmentCycle, }; context.Providers.Add(provider); context.OrganisationUsers.Add(new OrganisationUser { User = user, Organisation = organisation }); context.OrganisationProviders.Add(new OrganisationProvider { Provider = provider, Organisation = organisation }); }