public void Handle(GetRoomRequest message) { var roomService = new RoomService(); var roomPictureService = new RoomPictureService(); var room = roomService.GetModel(message.RoomId); var roomPictures = roomPictureService.GetModelList(string.Format("RoomId={0}", message.RoomId)); var response = room.MapTo <GetRoomResponse>(); if (roomPictures.Any()) { response.RoomPictures = roomPictures.MapTo <List <RoomPictureDto> >(); } _bus.Reply(response); }
public void Handle(GetRoomListRequest message) { var roomService = new RoomService(); var roomPictureService = new RoomPictureService(); var roomList = roomService.GetModelList(string.Format("HotelId={0}", message.HotelId)).MapTo <List <GetRoomResponse> >(); if (roomList.Any()) { roomList.ForEach(r => { r.RoomPictures = roomPictureService.GetModelList(string.Format("RoomId={0}", r.Id)).MapTo <List <RoomPictureDto> >(); }); } _bus.Reply(new GetRoomListResponse() { Rooms = roomList }); }