Beispiel #1
0
        private static void Initialize(SuccubusContext context)
        {
            var content = File.ReadAllText($"Resources/Cosplayers.json");

            var cosplayers = JsonConvert.DeserializeObject <List <Cosplayer> >(content);

            foreach (var cp in cosplayers.Where(cp => !context.Cosplayers.Any(x => x.Name == cp.Keywords.FirstOrDefault())).ToList())
            {
                var c = context.Add(new Cosplayer
                {
                    Name     = cp.Keywords[0],
                    Keywords = cp.Keywords,
                    Socials  = cp.Socials
                });

                context.SaveChanges();

                foreach (var set in cp.Sets.Where(set => !context.Sets.Any(x => x.Name == set.Keywords.FirstOrDefault())).ToList())
                {
                    context.Add(new Set
                    {
                        Name      = set.Keywords[0],
                        Keywords  = set.Keywords,
                        Cosplayer = c.Entity,
                        Folder    = set.Folder,
                        Prefix    = set.Prefix,
                        Size      = set.Size
                    });

                    context.SaveChanges();
                }
            }
        }
Beispiel #2
0
        public DatabaseService()
        {
            using var context = new SuccubusContext();
            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
                context.SaveChanges();
            }

            context.Database.ExecuteSqlRaw("PRAGMA journal_mode=WAL; PRAGMA synchronous=OFF");
            context.SaveChanges();
            Initialize(context);
            context.SaveChanges();
        }