Ejemplo n.º 1
0
 public DbArtisteRepository(WebzineDbContext webzineDbContext)
 {
     this.context = webzineDbContext;
 }
Ejemplo n.º 2
0
 public DbCommentaireRepository(WebzineDbContext webzineDbContext)
 {
     this.context = webzineDbContext;
 }
Ejemplo n.º 3
0
 public DbStyleRepository(WebzineDbContext webzineDbContext)
 {
     this.context = webzineDbContext;
 }
Ejemplo n.º 4
0
 public HomeController(ITitreRepository titreRepository, IConfiguration configuration)
 {
     _dbContext       = new WebzineDbContext();
     _titreRepository = titreRepository;
     _configuration   = configuration;
 }
Ejemplo n.º 5
0
 public DbTitreRepository(WebzineDbContext webzineDbContext)
 {
     context = webzineDbContext;
 }
Ejemplo n.º 6
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            // Si le fichier de config contient
            if (Configuration["DataSource"] == "factory")
            {
                // StaticFactory
                StaticFactory.UpdateBinavigabilite();
            }

            else if (Configuration["DataSource"] == "local")
            {
                using (var client = new WebzineDbContext())
                {
                    if (Configuration["ResetDb"] == "true")
                    {
                        client.Database.EnsureDeleted();
                        client.Database.EnsureCreated();

                        // Load data in database
                        LocalSeeder seeder = new LocalSeeder(client, StaticFactory.Styles, StaticFactory.Titres, StaticFactory.Artistes, StaticFactory.Commentaires, StaticFactory.LienStyles, StaticFactory.Pays);
                        seeder.LoadData();
                        client.SaveChanges();
                    }

                    else
                    {
                        client.Database.EnsureCreated();
                    }
                }
            }

            else if (Configuration["DataSource"] == "spotify")
            {
                // sqlite
                using (var client = new WebzineDbContext())
                {
                    client.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                    if (Configuration["ResetDb"] == "true")
                    {
                        client.Database.EnsureDeleted();
                        client.Database.EnsureCreated();

                        SpotifySeeder spotify = new SpotifySeeder("1a3478c9f18842bc9fee8692aa574973", "943d3a231566443ba543d0e20a673d44");

                        var    playlist = spotify.GetPlaylist(Configuration["SpotifyPlaylistId"]);
                        Seeder seed     = spotify.SeedFromPlaylist(client, playlist);

                        client.SaveChanges();

                        var spotifyStyle    = client.Styles.FirstOrDefault();
                        List <LienStyle> ls = new List <LienStyle>();
                        client.Titres.ToList().ForEach(t => ls.Add(new LienStyle {
                            IdStyle = spotifyStyle.IdStyle, IdTitre = t.IdTitre
                        }));

                        ls.ForEach(l => client.LienStyles.Add(l));

                        client.SaveChanges();
                    }

                    else
                    {
                        client.Database.EnsureCreated();
                    }
                }
            }
            else
            {
                // erreur mise de factory par default
                StaticFactory.UpdateBinavigabilite();
            }
        }