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); }
public void ThrowWhenParameterDbContextHasNullValue() { ICinemaDbContext nullContext = null; Assert.That(() => new Cinema.Data.Repositories.GenericRepository <Movie>(nullContext), Throws.InstanceOf <ArgumentNullException>()); }
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>(); }
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); }
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>(); }
public UserRepository(ICinemaDbContext context) : base(context) { }
public PricingRepository(ICinemaDbContext context) : base(context) { }
public NewsRepository(ICinemaDbContext context) : base(context) { }
public ScreeningRepository(ICinemaDbContext context) : base(context) { }
public MovieRepository(ICinemaDbContext context) : base(context) { }
public EventRepository(ICinemaDbContext context) : base(context) { }