Exemple #1
0
        private async Task AssignAssetToRuntime(Extract extracted, Asset asset)
        {
            EcosystemVersion runtime = await GetOrCreateRuntime(extracted);

            context.AssetEcoSystems.Add(new AssetEcosystem {
                Asset = asset, AssetId = asset.Id, EcosystemVersion = runtime, EcosystemVersionId = runtime.Id
            });

            await context.SaveChangesAsync();
        }
Exemple #2
0
        private async Task <EcosystemVersion> GetOrCreateRuntime(Extract extract)
        {
            Ecosystem runtime = await context.Ecosystems.FirstAsync(r => r.Name == extract.EcosystemIdentifier);

            EcosystemVersion version = runtime.EcosystemVersions.FirstOrDefault(d => d.Version == extract.EcosystemVersion) ?? new EcosystemVersion {
                Id = Guid.NewGuid(), Ecosystem = runtime, Version = extract.EcosystemVersion
            };

            if (context.Entry(version).State == EntityState.Detached)
            {
                context.EcosystemVersions.Add(version);
                await context.SaveChangesAsync();
            }

            return(version);
        }
Exemple #3
0
        private async Task PopulateAssetEcosystems()
        {
            foreach (Asset asset in context.Assets)
            {
                foreach (Ecosystem ecosystem in context.Ecosystems)
                {
                    if (OnRuntime(asset, ecosystem))
                    {
                        EcosystemVersion ecosystemVersion = Pick <EcosystemVersion> .RandomItemFrom(ecosystem.EcosystemVersions.ToList());

                        AssetEcosystem assetEcoSystem = GetAssetEcosystem(asset, ecosystemVersion);
                        context.AssetEcoSystems.Add(assetEcoSystem);
                        break;
                    }
                }
            }

            await context.SaveChangesAsync();
        }