public void SetAccount(long accountId, long providerId, string accountName, int?priorityOrder) { var autoFixture = new Fixture(); if (!Db.Accounts.Any(p => p.Id == accountId)) { var account = new Account( accountId, autoFixture.Create <string>(), autoFixture.Create <string>(), accountName, DateTime.UtcNow); Db.Accounts.Add(account); Db.SaveChanges(); } if (priorityOrder.HasValue) { if (!Db.CustomProviderPaymentPriorities.Any(p => p.EmployerAccountId == accountId && p.ProviderId == providerId)) { var customProviderPaymentPriority = new CustomProviderPaymentPriority { ProviderId = providerId, EmployerAccountId = accountId, PriorityOrder = priorityOrder.Value }; Db.CustomProviderPaymentPriorities.Add(customProviderPaymentPriority); Db.SaveChanges(); } } }
public void SetCohort(long accountId, long providerId, string providerName, DateTime?agreedOn, DateTime?approvedOn, bool cohortApproved, int?priorityOrder) { // This line is required. // ReSharper disable once ObjectCreationAsStatement new UnitOfWorkContext(); var autoFixture = new Fixture(); var commitment = new Cohort( providerId, accountId, autoFixture.Create <long>(), Party.Employer, new UserInfo()); commitment.EmployerAndProviderApprovedOn = approvedOn; Db.Cohorts.Add(commitment); Db.SaveChanges(); if (cohortApproved) { commitment.EditStatus = EditStatus.Both; commitment.TransferSenderId = null; commitment.TransferApprovalStatus = TransferApprovalStatus.Approved; Db.SaveChanges(); } var apprenticeship = new Apprenticeship { CommitmentId = commitment.Id, AgreedOn = agreedOn }; Db.Apprenticeships.Add(apprenticeship); Db.SaveChanges(); if (!Db.Providers.Any(p => p.UkPrn == providerId)) { var provider = new Provider() { UkPrn = providerId, Name = providerName }; Db.Providers.Add(provider); Db.SaveChanges(); } if (priorityOrder.HasValue) { if (!Db.CustomProviderPaymentPriorities.Any(p => p.EmployerAccountId == accountId && p.ProviderId == providerId)) { var customProviderPaymentPriority = new CustomProviderPaymentPriority { ProviderId = providerId, EmployerAccountId = accountId, PriorityOrder = priorityOrder.Value }; Db.CustomProviderPaymentPriorities.Add(customProviderPaymentPriority); Db.SaveChanges(); } } }