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); } }
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); } }
/// <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); } }
public async Task CreateHotel(Hotel hotel) { try { _context.Add(hotel); await _context.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); } }
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)); }
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)); }
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); } }
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); } }
//[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); } }
public async Task CreateRoom([Bind("ID,Name,RoomLayout")] Room hotel) { _context.Add(hotel); await _context.SaveChangesAsync(); }