private void InitializeDbContext() { var optionsBuilder = new DbContextOptionsBuilder <VidlyDbContext>(); optionsBuilder.UseSqlite("Data Source=vidly.db"); _dbContext = new VidlyDbContext(optionsBuilder.Options); }
public UnitOFWork(VidlyDbContext VidlyModel) { this.VidlyModel = VidlyModel; this.CustomerRepository = new CustomerRepository(VidlyModel); this.MovieRepository = new MovieRepository(VidlyModel); this.MemmberShipTypeRepository = new MemmberShipTypeRepository(VidlyModel); this.GenreRepository = new GenreRepository(VidlyModel); this.RentalRepository = new RentalRepository(VidlyModel); this.RentalDetailsRepository = new RentalDetailsRepository(VidlyModel); this.UserRepository = new UsersRepository(VidlyModel); }
public void Example03() { using (var db = new VidlyDbContext()) { var customers = db.Customers.Include(c => c.MembershipTypeCode).ToList(); foreach (var item in customers) { Console.WriteLine($"Display Name: {item.DisplayName}, Email Address: {item.EmailAddress}, Membership Type Id: {item.MembershipTypeCodeId}, Membership Type {item.MembershipTypeCode.MembershipTypeDesc}"); } } }
public void Example01() { using (var db = new VidlyDbContext()) { var membershipTypes = db.MembershipTypeCodes.ToList(); Console.WriteLine("Membership Types..."); foreach (var m in membershipTypes) { Console.WriteLine($"MembershipTypeId: {m.MembershipTypeCodeId}, MembershipTypeName: {m.MembershipTypeDesc}"); } } }
public void Example01() { using (var db = new VidlyDbContext()) { var result = db.Movies.Include(m => m.MovieGenreCode).ToList(); Console.WriteLine("All movies in the database are as follows..."); Console.WriteLine(); foreach (var item in result) { Console.WriteLine($"Movie Name: {item.MovieName}, Release Date: {item.ReleaseDate}, Genre: {item.MovieGenreCode.Genre}"); } } }
public void Example02() { using (var db = new VidlyDbContext()) { var result = db.Movies.Include(m => m.MovieDetail).ToList(); Console.WriteLine("All movies in the database with their details are as follows..."); Console.WriteLine(); foreach (var item in result) { Console.WriteLine($"Movie Name: {item.MovieName}, Release Date: {item.ReleaseDate}, Runtime: {item.Runtime}, IMDB URL: {item.MovieDetail.ImdbUrl}"); } } }
public void Example02() { using (var db = new VidlyDbContext()) { var genres = db.MovieGenreCodes.ToList(); Console.WriteLine("Genres Types (from codes schema)..."); foreach (var g in genres) { Console.WriteLine($"Genre Id: {g.Id}, Genre: {g.Genre}, Is Active? {g.IsActive}"); } var ratings = db.MovieRatingCodes.ToList(); Console.WriteLine("Rating Types (from codes schema)..."); foreach (var r in ratings) { Console.WriteLine($"Rating Id: {r.Id}, Rating: {r.Rating}, Is Active? {r.IsActive}"); } } }
public void Example01() { using (var db = new VidlyDbContext()) { var result = db.Customers.ToList(); Console.WriteLine("All customers in the database are as follows..."); Console.WriteLine(); foreach (var item in result) { /***************************************************************************************************************************************************************** * Example of Interpolated Strings: An interpolated string looks like a template string that contains interpolated expressions. * Example of the "Elvis" Operator: returns one of two values depending on the value of a Boolean expression. condition ? first_expression : second_expression; ******************************************************************************************************************************************************************/ Console.WriteLine("Display Name: {0}, Email Address: {1}, Date of Birth: {2}" , item.DisplayName , item.EmailAddress , item.Dob != null ? $"{item.Dob:MM/dd/yy}" : "Unknown"); } } }
public MovieController() { _context = new VidlyDbContext(); }
public GenreRepository(VidlyDbContext context) : base(context) { }
public UsersRepository(VidlyDbContext context) : base(context) { this.context = context; }
/// <summary> /// ..... /// </summary> public MembershipTypeCodesController() { _context = new VidlyDbContext(); }
public RentalRepository(VidlyDbContext context) : base(context) { this.context = context; }
public MovieRatingCodesController() { _context = new VidlyDbContext(); }
public CustomersController(VidlyDbContext context) { _context = context; }
public RentalDetailsRepository(VidlyDbContext context) : base(context) { }
public MovieGenreCodesController() { _context = new VidlyDbContext(); }
public CustomerRepository(VidlyDbContext context) : base(context) { this.context = context; }
public MemmberShipTypeRepository(VidlyDbContext context) : base(context) { }
public MoviesController() { _dbContext = new VidlyDbContext(); }
public MoviesController() { _context = new VidlyDbContext(); _context.Configuration.ProxyCreationEnabled = false; }
public MovieRepository(VidlyDbContext context) : base(context) { this.context = context; }
public Repository(VidlyDbContext context) { this.context = context; }
public MoviesController(VidlyDbContext context) { _context = context; }
public InstallmentCodesController() { _context = new VidlyDbContext(); }
public StaffsController() { db = new VidlyDbContext(); }
public CustomersController() { _context = new VidlyDbContext(); }
public CustomersController(VidlyDbContext context) { _context = context; _random = new Random(); }