Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 11
0
 public ClientRepository(HotelBookingContext context)
 {
     db = context;
 }
 public CustomerRepository()
 {
     db = new HotelBookingContextFactory().Context;
 }
 public HotelRoomMapRepository(HotelBookingContext context)
 {
     db = context;
 }
Ejemplo n.º 14
0
 public BookingRepository(HotelBookingContext context)
 {
     db = context;
 }
Ejemplo n.º 15
0
 public EFUnitOfWork(string connectionString)
 {
     db = new HotelBookingContext(connectionString);
 }
Ejemplo n.º 16
0
 public CustomerRepository(HotelBookingContext context)
 {
     db = context;
 }
Ejemplo n.º 17
0
 public BookingRepository()
 {
     db = new HotelBookingContextFactory().Context;
 }
 public RoomCategoryRepository(HotelBookingContext context)
 {
     db = context;
 }
 public PriceOfHotelCategoryRepository(HotelBookingContext context)
 {
     db = context;
 }