示例#1
0
        public void CanGetRoom()
        {
            DbContextOptions <AsyncdbContext> options = new DbContextOptionsBuilder <AsyncdbContext>().UseInMemoryDatabase("CanCreateHotel").Options;

            using (AsyncdbContext context = new AsyncdbContext(options))
            {
                Room      room      = new Room();
                HotelRoom hotelroom = new HotelRoom();

                room.HotelRoom     = hotelroom;
                room.ID            = 1;
                room.Name          = "Awesomeness";
                room.RoomAmenities = new RoomAmenities();
                room.RoomLayout    = 0;



                context.Add(hotelroom);
                context.SaveChanges();

                var result = context.Room.FirstOrDefault(m => m.ID == room.ID);

                Assert.NotEqual(result, room);
            }
        }
示例#2
0
        public void CanGetHotelRoom()
        {
            DbContextOptions <AsyncdbContext> options = new DbContextOptionsBuilder <AsyncdbContext>().UseInMemoryDatabase("CanCreateHotel").Options;

            using (AsyncdbContext context = new AsyncdbContext(options))
            {
                HotelRoom hotelroom = new HotelRoom();
                Hotel     hotel     = new Hotel();
                Room      room      = new Room();

                hotelroom.Hotel       = hotel;
                hotelroom.HotelID     = 1;
                hotelroom.PetFriendly = true;
                hotelroom.Rate        = 1200;
                hotelroom.Room        = room;
                hotelroom.RoomID      = 12;
                hotelroom.RoomNumber  = 001;


                context.Add(hotelroom);
                context.SaveChanges();

                var result = context.HotelRoom.FirstOrDefault(m => m.Hotel.ID == hotelroom.HotelID);

                Assert.Equal(result, hotelroom);
            }
        }
示例#3
0
 /// <summary>
 /// creates amenity
 /// </summary>
 /// <param name="amenities">passes in amenity object ready for user input</param>
 /// <returns>amenity added to database</returns>
 public async Task CreateAmenitie(Amenities amenities)
 {
     try
     {
         _context.Add(amenities);
         await _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#4
0
 public async Task CreateHotel(Hotel hotel)
 {
     try
     {
         _context.Add(hotel);
         await _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#5
0
        public async Task <IActionResult> Create([Bind("AmenitiesID,RoomID")] RoomAmenities roomAmenities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roomAmenities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AmenitiesID"] = new SelectList(_context.Amenities, "ID", "Name", roomAmenities.AmenitiesID);
            ViewData["RoomID"]      = new SelectList(_context.Room, "ID", "Name", roomAmenities.RoomID);
            return(View(roomAmenities));
        }
示例#6
0
        public async Task <IActionResult> Create([Bind("HotelID,RoomNumber,RoomID,Rate,PetFriendly")] HotelRoom hotelRoom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hotelRoom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HotelID"] = new SelectList(_context.Hotel, "ID", "Name", hotelRoom.HotelID);
            ViewData["RoomID"]  = new SelectList(_context.Room, "ID", "Name");
            return(View(hotelRoom));
        }
示例#7
0
        public void CanGetAmenitie()
        {
            DbContextOptions <AsyncdbContext> options = new DbContextOptionsBuilder <AsyncdbContext>().UseInMemoryDatabase("CanCreateHotel").Options;

            using (AsyncdbContext context = new AsyncdbContext(options))
            {
                Amenities amenities = new Amenities();

                amenities.Name          = "Heat";
                amenities.ID            = 1;
                amenities.RoomAmenities = new RoomAmenities();



                context.Add(amenities);
                context.SaveChanges();

                var result = context.Amenities.FirstOrDefault(m => m.ID == amenities.ID);

                Assert.Equal(result, amenities);
            }
        }
示例#8
0
        public void CanGetHotel()
        {
            DbContextOptions <AsyncdbContext> options = new DbContextOptionsBuilder <AsyncdbContext>().UseInMemoryDatabase("CanCreateHotel").Options;

            using (AsyncdbContext context = new AsyncdbContext(options))
            {
                Hotel hotel = new Hotel();


                hotel.ID           = 566;
                hotel.Name         = "Hotel Name";
                hotel.StreetAdress = "1234 N Address";
                hotel.State        = "Alabama";
                hotel.Phone        = 1234567;

                context.Add(hotel);
                context.SaveChanges();

                var result = context.Hotel.FirstOrDefault(m => m.ID == hotel.ID);

                Assert.Equal(result, hotel);
            }
        }
示例#9
0
        //[Fact]
        public void CanGetRoomAmenities()
        {
            DbContextOptions <AsyncdbContext> options = new DbContextOptionsBuilder <AsyncdbContext>().UseInMemoryDatabase("CanCreateHotel").Options;

            using (AsyncdbContext context = new AsyncdbContext(options))
            {
                RoomAmenities roomamenities = new RoomAmenities();

                roomamenities.Amenities   = new Amenities();
                roomamenities.AmenitiesID = 1;
                roomamenities.Room        = new Room();
                roomamenities.RoomID      = 1;



                context.Add(roomamenities);
                context.SaveChanges();

                var result = context.HotelRoom.FirstOrDefault(m => m.Hotel.ID == roomamenities.RoomID);

                //Assert.NotEqual(result, roomamenities);
            }
        }
示例#10
0
 public async Task CreateRoom([Bind("ID,Name,RoomLayout")] Room hotel)
 {
     _context.Add(hotel);
     await _context.SaveChangesAsync();
 }