public AlbumsController(BeatStreamrContext context) { _context = context; }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new BeatStreamrContext( serviceProvider.GetRequiredService <DbContextOptions <BeatStreamrContext> >())) { //Look for any users that already exist if (!context.User.Any()) { SeedUsers(); } //Look for any beats that already exist if (!context.Beat.Any()) { SeedBeats(); } void SeedUsers() { context.User.AddRange( new User { Name = "Kanye West", UserName = "******" }, new User { Name = "John Smith", UserName = "******" }, new User { Name = "Daniel Bradford", UserName = "******" }, new User { Name = "Hafsa Ahmed", UserName = "******" }, new User { Name = "Lisa Bradford", UserName = "******" }, new User { Name = "Nathan Bradford", UserName = "******" } ); } void SeedBeats() { context.Beat.AddRange( new Beat { Title = "Soul Beat", BPM = 120, Key = "A#m", Price = 299.99M, ArtistID = 1, BeatFilePath = "/media/beats/horse.mp3" }, new Beat { Title = "Rock Beat", BPM = 130, Key = "Dm", Price = 250.99M, ArtistID = 1, BeatFilePath = "/media/beats/horse.mp3" }, new Beat { Title = "Electro Beat", BPM = 156, Key = "C", Price = 499.99M, ArtistID = 1, BeatFilePath = "/media/beats/horse.mp3" }, new Beat { Title = "Classical Beat", BPM = 99, Key = "Bbm", Price = 199.99M, ArtistID = 1, BeatFilePath = "/media/beats/horse.mp3" } ); } context.SaveChanges(); } }
public UsersContoller(BeatStreamrContext context) { _context = context; }
public BeatsController(BeatStreamrContext context, IHostingEnvironment hostingEnvironment) { _context = context; _hostingEnvironment = hostingEnvironment; }
public HomeController(BeatStreamrContext context) { _context = context; }