Esempio n. 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new LangDbContext(
                       serviceProvider.GetRequiredService <DbContextOptions <LangDbContext> >()))
            {
                // Look for any movies.
                if (context.Langs.Any())
                {
                    return;   // DB has been seeded
                }

                context.Langs.AddRange(
                    new Lang
                {
                    ID    = "ru",
                    Title = "Русский",
                },
                    new Lang
                {
                    ID    = "en",
                    Title = "Английский",
                },
                    new Lang
                {
                    ID    = "sl",
                    Title = "Словенский",
                }
                    );
                context.SaveChanges();
            }
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var db = new LangDbContext();

            ViewBag.langs = db.Langs.ToList();
            return(View());
        }
Esempio n. 3
0
 public Startup()
 {
     using (var client = new LangDbContext())
     {
         //Create the database file at a path defined in SimpleDataStorage
         client.Database.EnsureCreated();
         //Create the database tables defined in SimpleDataStorage
         //client.Database.Migrate();
     }
 }
Esempio n. 4
0
 public LocalizationContext(LangDbContext db, RequestContext requestContext)
 {
     _db             = db;
     _requestContext = requestContext;
 }