/// <summary> /// Creates sample data. /// </summary> public static async Task SeedSampleDataAsync(AppDbContext db) { var ctx = new SeedContext(db); await SeedCatsFoldersAsync(ctx); await SeedTravelFoldersAsync(ctx); // SeedEdgeCaseFolders(ctx); await ctx.ApplyInheritedTagsAsync(); }
/// <summary> /// Creates uncommon folders to test various edge cases. /// </summary> private static async Task SeedEdgeCaseFoldersAsync(SeedContext ctx) { var longFolder = await ctx.AddFolderAsync("Z Long folder", "long"); for (var i = 1; i <= 50; i++) { await ctx.AddFolderAsync("Subfolder " + i, "sub" + i, longFolder); } var deepFolder = await ctx.AddFolderAsync("Z Deep folder", "deep"); var curr = deepFolder; for (var i = 1; i <= 10; i++) { curr = await ctx.AddFolderAsync("Subfolder " + i, "sub" + i, curr); } }
/// <summary> /// Creates folders with cute fluffy kitties :3 /// </summary> private static async Task SeedCatsFoldersAsync(SeedContext ctx) { var catsFolder = await ctx.AddFolderAsync("Cats", "cats"); var britsFolder = await ctx.AddFolderAsync("British", "british", catsFolder); for (var i = 1; i <= 4; i++) { await ctx.AddPhotoAsync($"brit-{i}.jpg", britsFolder); } var cat = await ctx.AddPhotoAsync("brit-5.jpg", britsFolder); var abyFolder = await ctx.AddFolderAsync("Abyssinian", "aby", catsFolder); for (var i = 1; i <= 4; i++) { await ctx.AddPhotoAsync($"aby-{i}.jpg", abyFolder); } var catsTag = await ctx.AddTagAsync("Felines"); var kittyTag = await ctx.AddTagAsync("Kitty", TagType.Person); await ctx.TagFolderAsync(catsFolder, catsTag); await ctx.TagPhotoAsync(cat, kittyTag, TagBindingType.Depicted, "0.2,0.2,0.6,0.7"); var catsPhoto = await ctx.AddPhotoAsync("kittens-1.jpg", catsFolder, descr : "Three kittens on a sleeping mat", date : "2020.10.??"); await ctx.TagPhotoAsync(catsPhoto, await ctx.AddTagAsync("Alpha", TagType.Person), TagBindingType.Depicted, Calc(720, 450, 58, 38, 233, 205)); await ctx.TagPhotoAsync(catsPhoto, await ctx.AddTagAsync("Bravo", TagType.Person), TagBindingType.Depicted, Calc(720, 450, 267, 25, 435, 192)); await ctx.TagPhotoAsync(catsPhoto, await ctx.AddTagAsync("Charlie", TagType.Person), TagBindingType.Depicted, Calc(720, 450, 385, 150, 585, 332)); await ctx.TagPhotoAsync(catsPhoto, await ctx.AddTagAsync("Mutts")); await ctx.AddSharedLink(catsFolder, key : "all-cats", mode : SearchScope.CurrentFolderAndSubfolders); }
/// <summary> /// Creates folders with travel-related pictures. /// </summary> private static async Task SeedTravelFoldersAsync(SeedContext ctx) { var travelFolder = await ctx.AddFolderAsync("Travel", "travel"); var tp1 = await ctx.AddPhotoAsync("travel-1.jpg", travelFolder, "Rodos Island", "2018.09.01"); var tp2 = await ctx.AddPhotoAsync("travel-2.jpg", travelFolder, "Simi Island", "2018.09.04"); var tp3 = await ctx.AddPhotoAsync("travel-3.jpg", travelFolder, "Colosseum", "2018.04.22"); var tp4 = await ctx.AddPhotoAsync("travel-4.jpg", travelFolder, "Trevi Fountain", "2018.04.23"); var tp5 = await ctx.AddPhotoAsync("travel-5.jpg", travelFolder, "Venice", "2018.04.??"); var greeceTag = await ctx.AddTagAsync("Greece"); var italyTag = await ctx.AddTagAsync("Italy"); var sightTag = await ctx.AddTagAsync("Sight-seeing"); await ctx.TagPhotoAsync(tp1, greeceTag); await ctx.TagPhotoAsync(tp1, sightTag); await ctx.TagPhotoAsync(tp2, greeceTag); await ctx.TagPhotoAsync(tp3, italyTag); await ctx.TagPhotoAsync(tp3, sightTag); await ctx.TagPhotoAsync(tp4, italyTag); await ctx.TagPhotoAsync(tp5, italyTag); await ctx.AddSharedLink(travelFolder, new[] { greeceTag.Id }, key : "travel-greece"); }