/// <summary>
        /// Creates an Amenity called by the POST route
        /// </summary>
        /// <param name="amenity">One of the Amenities for the hotel that can be applied to a room</param>
        /// <returns>Amenity</returns>
        public async Task <AmenityDTO> Create(AmenityDTO amenityDTO)
        {
            Amenity amenity = new Amenity()
            {
                Id   = amenityDTO.ID,
                Name = amenityDTO.Name
            };

            _context.Entry(amenity).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(amenityDTO);
        }
        /// <summary>
        /// Creates a HotelRoom that is a Room associated with a specific Hotel
        /// </summary>
        /// <param name="hotelRoom">The object to be created</param>
        /// <param name="hotelId">The Hotel that the Room is to be added to</param>
        /// <returns>No Return</returns>
        public async Task <HotelRoomDTO> Create(HotelRoomDTO hotelRoomDTO, int hotelId)
        {
            HotelRoom hotelRoom = new HotelRoom()
            {
                HotelID     = hotelRoomDTO.HotelID,
                PetFriendly = hotelRoomDTO.PetFriendly,
                Rate        = hotelRoomDTO.Rate,
                RoomNumber  = hotelRoomDTO.RoomNumber,
                RoomId      = hotelRoomDTO.RoomID
            };

            _context.Entry(hotelRoom).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotelRoomDTO);
        }
예제 #3
0
        /// <summary>
        /// Creates a Hotel(POST Route)
        /// </summary>
        /// <param name="hotel">The Hotel to be created</param>
        /// <returns>The Hotel that was created</returns>
        public async Task <HotelDTO> Create(HotelDTO hotelDTO)
        {
            Hotel hotel = new Hotel()
            {
                Name         = hotelDTO.Name,
                City         = hotelDTO.City,
                Id           = hotelDTO.ID,
                PhoneNumber  = hotelDTO.Phone,
                State        = hotelDTO.State,
                StretAddress = hotelDTO.StreetAddress
            };

            _context.Entry(hotel).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotelDTO);
        }