示例#1
0
        public async Task <IActionResult> BookARoomAsync([FromBody] Booking booking)
        {
            IEnumerable <Room> rooms = await _roomBusiness.GetRoomsAsync();

            if (!ModelState.IsValid ||
                rooms.All(r => r.Name != booking.Room.Name))
            {
                return(BadRequest());
            }

            CreatedBooking createdBooking = await _bookingsBusiness.BookARoomAsync(booking);

            if (createdBooking.Booking == null)
            {
                return(Ok(createdBooking));
            }

            return(CreatedAtAction("BookARoomAsync", createdBooking));
        }
示例#2
0
        public async Task <IActionResult> GetRoomsAsync()
        {
            IEnumerable <Room> rooms = await _roomsBusiness.GetRoomsAsync();

            return(Ok(rooms));
        }
示例#3
0
        public async Task <IActionResult> GetRoomsAsync()
        {
            var rooms = _roomsBusiness.GetRoomsAsync();

            return(Ok(rooms));
        }