/// <summary> /// creates a new hotel /// </summary> /// <param name="hotel">inputted hotel data</param> /// <returns>created hotel</returns> public async Task <Hotels> Create(Hotels hotel) { _context.Entry(hotel).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); return(hotel); }
public async Task <IActionResult> Create([Bind("ID,Name")] Amenities amenities) { if (ModelState.IsValid) { _context.Add(amenities); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(amenities)); }
public async Task <IActionResult> Create([Bind("ID,Name,StreetAddress,City,State,Phone")] Hotel hotel) { if (ModelState.IsValid) { _context.Add(hotel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hotel)); }
public async Task <IActionResult> Create([Bind("ID,Name,Layout")] Room room) { if (ModelState.IsValid) { _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(room)); }
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["RoomID"] = new SelectList(_context.Rooms, "ID", "ID", hotelRoom.RoomID); return(View(hotelRoom)); }
//Service 1: Amenity protected async Task <Amenity> CreateAndSaveTestAmenity() { var amenity = new Amenity { Name = "TestAmenity" }; _db.Amenities.Add(amenity); await _db.SaveChangesAsync(); Assert.NotEqual(0, amenity.ID); return(amenity); }
public async Task <IActionResult> Create([Bind("RoomLocationId,AmenityPackageId")] RoomLocationAmenities roomLocationAmenities) { if (ModelState.IsValid) { _context.Add(roomLocationAmenities); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AmenityPackageId"] = new SelectList(_context.AmenityPackages, "AmenityPackageId", "AmenityPackageId", roomLocationAmenities.AmenityPackageId); ViewData["RoomLocationId"] = new SelectList(_context.RoomLocations, "RoomLocationId", "RoomLocationId", roomLocationAmenities.RoomLocationId); return(View(roomLocationAmenities)); }
/// <summary> /// creates an amenity /// </summary> /// <param name="inboundData">inputted DTO data</param> /// <returns>the created amenity</returns> public async Task <Amenity> Create(AmenityDTO inboundData) { Amenity amenity = new Amenity() { ID = inboundData.ID, Name = inboundData.Name }; _context.Entry(amenity).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); return(amenity); }
public async Task <IActionResult> Create([Bind("RoomLocationId,RoomId,LocationId,Price,PetFriendly")] RoomLocation roomLocation) { if (ModelState.IsValid) { _context.Add(roomLocation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "LocationId", roomLocation.LocationId); ViewData["RoomId"] = new SelectList(_context.Rooms, "RoomId", "RoomId", roomLocation.RoomId); return(View(roomLocation)); }
public async Task <IActionResult> Create([Bind("RoomID,AmenitiesID")] 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.Rooms, "ID", "Name", roomAmenities.RoomID); return(View(roomAmenities)); }
/// <summary> /// creates a new room /// </summary> /// <param name="incomingData">the inputted data in DTO format</param> /// <returns>created room</returns> public async Task <Room> Create(RoomDTO incomingData) { Room room = new Room { ID = incomingData.ID, Nickname = incomingData.Name, Layout = Int32.Parse(incomingData.Layout), }; _context.Entry(room).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); return(room); }
/// <summary> /// creates a new hotel room row /// </summary> /// <param name="hotelID">the hotel the room belongs to</param> /// <param name="roomNumber">the key of that room in the specific hotel</param> /// <param name="incomingData">HotleRoomDTO with data for the table</param> /// <returns>created hotel room object</returns> public async Task <HotelRoom> Create(int hotelID, int roomNumber, HotelRoomDTO incomingData) { HotelRoom hotelRoom = new HotelRoom() { HotelsID = hotelID, RoomNumber = roomNumber, RoomID = incomingData.RoomID, Rate = incomingData.Rate, PetFriendly = incomingData.PetFriendly }; _context.Entry(hotelRoom).State = EntityState.Added; await _context.SaveChangesAsync(); return(hotelRoom); }
public async Task CreateAmenity(Amenities amenity) { _context.Add(amenity); await _context.SaveChangesAsync(); }
public async Task CreateHotel(Hotel hotel) { _context.Add(hotel); await _context.SaveChangesAsync(); }
public async Task CreateLocation(Location location) { _context.Add(location); await _context.SaveChangesAsync(); }
public async Task CreateRoom(Room room) { _context.Add(room); await _context.SaveChangesAsync(); }
public async Task CreateAmenityPackage(AmenityPackage amenityPackage) { _context.Add(amenityPackage); await _context.SaveChangesAsync(); }