Example #1
0
        static DbMockMovieTets()
        {
            var options = new DbContextOptionsBuilder <VideoStoreDbContext>()
                          .UseInMemoryDatabase("VideoStore")
                          .Options;

            context = new VideoStoreDbContext(options);
            Seed(context);
        }
Example #2
0
 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();
 }
Example #3
0
        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));
            }
        }
Example #4
0
        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;
 }
Example #6
0
 public MovieRepository(VideoStoreDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #7
0
 public UserRepository(VideoStoreDbContext dbContext, IAuthService authService)
 {
     _dbContext   = dbContext;
     _authService = authService;
 }
Example #8
0
 public Repository(VideoStoreDbContext context)
 {
     this.context = context;
 }
Example #9
0
 public Repository()
 {
     context = new VideoStoreDbContext();
     DbSet   = context.Set <T>();
 }
Example #10
0
 public MovieProductionCompanyRepository(VideoStoreDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #11
0
 public PeopleRepository(VideoStoreDbContext dbContext)
 {
     _dbContext = dbContext;
 }