private static async Task InsertSupplierAsync(SupplierTable supplierTable) { var organisations = (await OrganisationEntity.FetchAllAsync().ConfigureAwait(false)).ToList(); await SupplierEntityBuilder.Create() .WithId(supplierTable.Id) .WithOrganisation(organisations.First(o => o.Name == supplierTable.OrganisationName).Id) .WithName(supplierTable.Id) .Build() .InsertAsync() .ConfigureAwait(false); }
public static async Task GivenSolutionsExist(Table table) { var organisations = await OrganisationEntity.FetchAllAsync().ConfigureAwait(false); foreach (var solutionTable in table.CreateSet <SolutionTable>()) { await SolutionEntityBuilder.Create() .WithName(solutionTable.SolutionName) .WithId(solutionTable.SolutionID) .WithOnLastUpdated(solutionTable.LastUpdated) .WithOrganisationId(organisations.First(o => o.Name == solutionTable.OrganisationName).Id) .WithSupplierStatusId(solutionTable.SupplierStatusId) .WithPublishedStatusId(solutionTable.PublishedStatusId) .WithOnLastUpdated(solutionTable.LastUpdated != DateTime.MinValue ? solutionTable.LastUpdated : DateTime.UtcNow) .Build() .InsertAsync() .ConfigureAwait(false); } }