示例#1
0
        public async Task <IActionResult> Check([FromBody] Reservation reservation)
        {
            try {
                if (reservation == null)
                {
                    return(BadRequest(new { message = "Invalid arguments" }));
                }
                if (reservation.StartDate == DateTime.MinValue || reservation.EndDate == DateTime.MinValue)
                {
                    return(BadRequest(new { message = "Invalid start or end date" }));
                }

                // get any rooms available
                var availableRooms =
                    _mapper.Map <List <Room> >(await _reservationRepository.CheckReservation(reservation));

                return(Ok(availableRooms.Where(e => reservation.RoomType == 0 || e.TotalBeds == reservation.RoomType)));
            } catch (Exception e) {
                return(BadRequest(new { message = e.Message }));
            }
        }