Exemplo n.º 1
0
        public static RoomDetailsDto ToRoomDetailsDto(this Room model)
        {
            if (model == null)
            {
                return(null);
            }

            var dto = new RoomDetailsDto
            {
                Id           = model.Id,
                AddedDate    = model.AddedDate,
                Capacity     = model.Capacity,
                Color        = model.Color,
                Description  = model.Description,
                IpAddress    = model.IPAddress,
                ModifiedDate = model.ModifiedDate,
                Name         = model.Name
            };

            if (model.Place != null)
            {
                dto.PlaceDto = model.Place.ToPlaceDto();
            }

            return(dto);
        }
Exemplo n.º 2
0
        public async Task <RoomDetailsDto> GetRoom(int roomId)
        {
            Room room = await roomRepository.GetRoomById(roomId);

            RoomDetailsDto roomDetailsDto = mapper.Map <RoomDetailsDto>(room);

            if (room != null)
            {
                return(roomDetailsDto);
            }
            throw new RoomNotFoundException("Room not exist");
        }