public async Task <List <RoomViewModel> > CheckAvailabilityAsync(CheckAvailableRoomsCommand command) { Check.NotNull(command, nameof(command)); var userLocationClaim = _contextAccessor.HttpContext.User.Claims.Where(x => x.Type == "location").FirstOrDefault(); if (userLocationClaim == null) { throw new ServiceException("Can not find user is location"); } var response = await _bus.Request <CheckOfficeAvailability, OfficeAvailabilityRespond>(new { Location = userLocationClaim.Value, StartTime = command.StartTime.TimeOfDay, EndTime = command.EndTime.TimeOfDay }); if (response.Message.Available == false) { throw new ServiceException("Office not available provided times"); } var rooms = await _roomService.GetRoomsByOfficeAsync(new GetAvailableRoomsByOfficeCommand { OfficeId = response.Message.OfficeId }); return(rooms); }
public async Task <IActionResult> CheckAvailableRoomsAsync([FromBody] CheckAvailableRoomsCommand command) { return(Ok(await _reservationBusiness.CheckAvailabilityAsync(command))); }