static DbMockMovieTets() { var options = new DbContextOptionsBuilder <VideoStoreDbContext>() .UseInMemoryDatabase("VideoStore") .Options; context = new VideoStoreDbContext(options); Seed(context); }
private static void Seed(VideoStoreDbContext context) { context.Genres.AddRange(GenreSeed.Seed()); context.Person.AddRange(PeopleSeed.Seed()); context.ProductionCompanies.AddRange(ProductionCompanySeed.Seed()); context.Movies.AddRange(MovieSeed.Seed()); context.MovieGenre.AddRange(MovieGenreSeed.Seed()); context.MovieActor.AddRange(MovieActorSeed.Seed()); context.MovieDirector.AddRange(MovieDirectorSeed.Seed()); context.MovieProductionCompany.AddRange(MovieProductionCompanySeed.Seed()); context.SaveChanges(); }
public ActionResult Delete(int id) { VideoStoreDbContext context = new VideoStoreDbContext(); Customer customer = repository.Get(id); if (customer == null || context.VideoFilms.Where(x => x.CustomerId == customer.Id).ToList().Count != 0) { return(HttpNotFound()); } else { return(View(customer)); } }
public ActionResult DeleteConfirmed(int id) { Customer customer = repository.Get(id); VideoStoreDbContext context = new VideoStoreDbContext(); if (customer == null || context.VideoFilms.Where(x => x.CustomerId == customer.Id).ToList().Count != 0) { return(HttpNotFound("Can't delete customer, either customer do not exist in database or customer has videofilms rented")); } else { repository.Remove(customer); repository.SaveChanges(); return(RedirectToAction("index")); } }
public GenreRepository(VideoStoreDbContext dbContext) { _dbContext = dbContext; }
public MovieRepository(VideoStoreDbContext dbContext) { _dbContext = dbContext; }
public UserRepository(VideoStoreDbContext dbContext, IAuthService authService) { _dbContext = dbContext; _authService = authService; }
public Repository(VideoStoreDbContext context) { this.context = context; }
public Repository() { context = new VideoStoreDbContext(); DbSet = context.Set <T>(); }
public MovieProductionCompanyRepository(VideoStoreDbContext dbContext) { _dbContext = dbContext; }
public PeopleRepository(VideoStoreDbContext dbContext) { _dbContext = dbContext; }