public static async Task BuildAsync <T>(this T entity, ICinemaDbContext context)
 {
     if (typeof(T) == typeof(Reservation))
     {
         await BuildRelations(entity as Reservation, context);
     }
     if (typeof(T) == typeof(Screening))
     {
         await BuildRelations(entity as Screening, context);
     }
     if (typeof(T) == typeof(Review))
     {
         await BuildRelations(entity as Review, context);
     }
     if (typeof(T) == typeof(Seat))
     {
         await BuildRelations(entity as Seat, context);
     }
     if (typeof(T) == typeof(SeatReservation))
     {
         await BuildRelations(entity as SeatReservation, context);
     }
     if (typeof(T) == typeof(Event))
     {
         await BuildRelations(entity as Event, context);
     }
     if (typeof(T) == typeof(News))
     {
         await BuildRelations(entity as News, context);
     }
 }
        private static async Task BuildRelations(Screening entity, ICinemaDbContext context)
        {
            entity.Hall = await context.Halls.FindAsync(entity.HallId);

            entity.Movie = await context.Movies.FindAsync(entity.MovieId);

            entity.Pricing = await context.Pricing.FindAsync(entity.PricingId);
        }
Esempio n. 3
0
        public void ThrowWhenParameterDbContextHasNullValue()
        {
            ICinemaDbContext nullContext = null;

            Assert.That(() =>
                        new Cinema.Data.Repositories.GenericRepository <Movie>(nullContext),
                        Throws.InstanceOf <ArgumentNullException>());
        }
Esempio n. 4
0
        public GenericRepository(ICinemaDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("An instance of DbContext is required to use this repository.", "context");
            }

            this.Context = context;
            this.DbSet   = this.Context.Set <T>();
        }
Esempio n. 5
0
 public UnitOfWork(ICinemaDbContext context)
 {
     _context = context;
 }
        private static async Task BuildRelations(News entity, ICinemaDbContext context)
        {
            entity.Author = await context.Users.FindAsync(entity.AuthorId);

            entity.Type = await context.NewsTypes.FindAsync(entity.TypeId);
        }
 private static async Task BuildRelations(Seat entity, ICinemaDbContext context)
 {
     entity.Hall = await context.Halls.FindAsync(entity.HallId);
 }
        private static async Task BuildRelations(SeatReservation entity, ICinemaDbContext context)
        {
            entity.Reservation = await context.Reservations.FindAsync(entity.ReservationId);

            entity.Seat = await context.Seats.FindAsync(entity.SeatId);
        }
 public SeatReservationRepository(ICinemaDbContext context) : base(context)
 {
 }
        private static async Task BuildRelations(Review entity, ICinemaDbContext context)
        {
            entity.User = await context.Users.FindAsync(entity.UserId);

            entity.Movie = await context.Movies.FindAsync(entity.MovieId);
        }
Esempio n. 11
0
 public ReviewRepository(ICinemaDbContext context) : base(context)
 {
 }
        private static async Task BuildRelations(Reservation entity, ICinemaDbContext context)
        {
            entity.User = await context.Users.FindAsync(entity.UserId);

            entity.Screening = await context.Screenings.FindAsync(entity.ScreeningId);
        }
 public Repository(ICinemaDbContext context)
 {
     _context = context;
     _dbSet   = _context.Set <Entity>();
 }
Esempio n. 14
0
 public UserRepository(ICinemaDbContext context) : base(context)
 {
 }
Esempio n. 15
0
 public PricingRepository(ICinemaDbContext context) : base(context)
 {
 }
 public NewsRepository(ICinemaDbContext context) : base(context)
 {
 }
 public ScreeningRepository(ICinemaDbContext context) : base(context)
 {
 }
Esempio n. 18
0
 public MovieRepository(ICinemaDbContext context) : base(context)
 {
 }
 public EventRepository(ICinemaDbContext context) : base(context)
 {
 }