public Task Seed() { var unity2018Min = _context.UnityVersions.FindExactVersion((VersionNumber)"2018.1.0").Single(); var unity2018Max = _context.UnityVersions.FindExactVersion((VersionNumber)"2018.4.4").Single(); for (var i = 0; i < 10; i++) { var displayName = _unparser.Generate("#display_name.title#"); var slug = _slugifier.Slugify(displayName); var iconUrl = _iconRandomizer.GetIconUrl(); var description = _unparser.Generate("#description#"); var targetVersion = new TargetVersion() { Description = description, Hash = $"0123456789abcdef-{i}", DisplayName = displayName, IconUrl = iconUrl, WebsiteUrl = "", VersionNumber = "1", DisunityCompatibility = new TargetVersionCompatibility() { MinCompatibleVersion = unity2018Min, MaxCompatibleVersion = unity2018Max } }; var target = new Target() { Slug = slug, Versions = new List <TargetVersion>() { targetVersion } }; _context.Targets.Add(target); } return(_context.SaveChangesAsync()); }
public async Task Seed() { var random = new Random(); var orgs = _context.Orgs.ToList(); var targets = await _context.Targets.ToListAsync(); var names = new HashSet <string>(); var disunityVersion = await _context.DisunityVersions.FirstOrDefaultAsync(); for (var i = 0; i < 45; i++) { var org = orgs.PickRandom(); var target = targets.PickRandom(); var version = new VersionNumber(random.Next(3), random.Next(3), random.Next(3)); var attachedVersion = await _versionNumberFactory.FindOrCreateVersionNumber(version); var displayName = _unparser.Generate("#display_name.title#"); while (names.Contains(displayName)) { displayName = _unparser.Generate("#display_name.title#"); } names.Add(displayName); var slug = _slugifier.Slugify(displayName); var description = _unparser.Generate("#description.capitalize#"); var iconUrl = _iconRandomizer.GetIconUrl(); var website = _unparser.Generate("http://#adjective##noun.s#.#tld#"); var readme = displayName + "\n=====\n\n" + _unparser.Generate("#readme#"); var modVersion = new ModVersion() { Description = description, Readme = readme, DisplayName = displayName, FileId = "", IconUrl = iconUrl, VersionNumber = attachedVersion, WebsiteUrl = website, IsActive = true, TargetCompatibilities = new List <ModTargetCompatibility> { new ModTargetCompatibility() { Target = target } }, DisunityCompatibilities = new List <ModDisunityCompatibility> { new ModDisunityCompatibility() { MinCompatibleVersion = disunityVersion } } }; var mod = new Mod() { Owner = org, Slug = slug, Versions = new List <ModVersion>() { modVersion }, }; _context.Mods.Add(mod); } await _context.SaveChangesAsync(); }