// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); // Seed the database var options = new DbContextOptionsBuilder <HotelBookingContext>() .UseInMemoryDatabase("HotelBookingDb") .Options; var dbContext = new HotelBookingContext(options); DbInitializer.Initialize(dbContext); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Bookings}/{action=Index}/{id?}"); }); }
public bool SaveStayType(StayType stayType) { var context = new HotelBookingContext(); context.StayTypes.Add(stayType); return(context.SaveChanges() > 0); }
public bool DeleteStayType(StayType stayType) { var context = new HotelBookingContext(); context.Entry(stayType).State = System.Data.Entity.EntityState.Deleted; return(context.SaveChanges() > 0); }
public RoomsController() { // Create database context var options = new DbContextOptionsBuilder <HotelBookingContext>() .UseInMemoryDatabase("HotelBookingDb") .Options; _context = new HotelBookingContext(options); }
public IEnumerable <StayType> SearchStayType(string serchTerm) { var context = new HotelBookingContext(); var stayType = context.StayTypes.AsQueryable(); if (!string.IsNullOrEmpty(serchTerm)) { stayType = stayType.Where(s => s.Name.ToLower().Contains(serchTerm.ToLower())); } return(stayType.ToList()); }
public BookingManagerTest() { connection = new SqliteConnection("DataSource=:memory:"); // In-memory database only exists while the connection is open connection.Open(); // Initialize test database var options = new DbContextOptionsBuilder <HotelBookingContext>() .UseSqlite(connection).Options; var dbContext = new HotelBookingContext(options); DbInitializer.Initialize(dbContext); }
public ActionResult Index() { using (var ctx = new HotelBookingContext()) { var hotel = new Hotel() { Name = "Bill Bill" }; ctx.Hotels.Add(hotel); ctx.SaveChanges(); } ViewBag.Title = "Home Page"; return(View()); }
public BookingManagerTests() { connection = new SqliteConnection("DataSource=:memory:"); // In-memory database only exists while the connection is open connection.Open(); // Initialize test database var options = new DbContextOptionsBuilder <HotelBookingContext>() .UseSqlite(connection).Options; var dbContext = new HotelBookingContext(options); DbInitializer.Initialize(dbContext); // Create repositories and BookingManager var bookingRepos = new BookingRepository(dbContext); var roomRepos = new RoomRepository(dbContext); bookingManager = new BookingManager(bookingRepos, roomRepos); }
public StayType GetStayTypeById(int Id) { var context = new HotelBookingContext(); return(context.StayTypes.Find(Id)); }
public IEnumerable <StayType> GetAllStayType() { var context = new HotelBookingContext(); return(context.StayTypes.ToList()); }
public ClientRepository(HotelBookingContext context) { db = context; }
public CustomerRepository() { db = new HotelBookingContextFactory().Context; }
public HotelRoomMapRepository(HotelBookingContext context) { db = context; }
public BookingRepository(HotelBookingContext context) { db = context; }
public EFUnitOfWork(string connectionString) { db = new HotelBookingContext(connectionString); }
public CustomerRepository(HotelBookingContext context) { db = context; }
public BookingRepository() { db = new HotelBookingContextFactory().Context; }
public RoomCategoryRepository(HotelBookingContext context) { db = context; }
public PriceOfHotelCategoryRepository(HotelBookingContext context) { db = context; }