Esempio n. 1
0
        static void InitProjects(TnRContext context)
        {
            if (context.Projects.Any())
            {
                return;
            }

            context.Projects.Add(
                new Project
            {
                Name        = "Secret Project",
                Description = "classified",
                Created     = DateTime.Now,
                Modified    = DateTime.Now,
            });

            context.Projects.Add(
                new Project
            {
                Name        = "Undercover Project",
                Description = "confidential",
                Created     = DateTime.Now,
                Modified    = DateTime.Now,
            });
        }
Esempio n. 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new TnRContext(
                       serviceProvider.GetRequiredService <DbContextOptions <TnRContext> >()))
            {
                if (context.Projects.Any())
                {
                    return;
                }

                context.Projects.Add(
                    new Project
                {
                    Name        = "Daily News",
                    Description = "Newspaper of the day",
                    Created     = DateTime.Now,
                    Modified    = DateTime.Now,
                });

                context.Projects.Add(
                    new Project
                {
                    Name        = "Daily Evening News",
                    Description = "Evening update",
                    Created     = DateTime.Now,
                    Modified    = DateTime.Now,
                });

                context.SaveChanges();
            }
        }
Esempio n. 3
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new TnRContext(
                serviceProvider.GetRequiredService <DbContextOptions <TnRContext> >()))
     {
         InitUsers(context);
         InitProjects(context);
         context.SaveChanges();
     }
 }
Esempio n. 4
0
        static void InitUsers(TnRContext context)
        {
            if (context.Users.Any())
            {
                return;
            }

            context.Users.Add(
                new User
            {
                Name = "Admin",
                Pwd  = "123456"
            });
        }