public async Task <BaseServiceResponse <IEnumerable <AnuncioResponse> > > ConsultarPorUsuarioAsync(string idUsuario) { BaseServiceResponse <IEnumerable <AnuncioResponse> > response = new BaseServiceResponse <IEnumerable <AnuncioResponse> >(); List <AnuncioResponse> anuncioResponses = new List <AnuncioResponse>(); var anuncios = await _anuncioRepository.ConsultarAnunciosAsync(idUsuario); var usuario = await _usuarioRepository.ConsultarUsuarioAsync(idUsuario); if (anuncios is null) { response.Message = $"No se pudo obtener información de anuncios del usuario {idUsuario}"; return(response); } foreach (var anuncio in anuncios) { var anuncioDetalle = await _anuncioDetalleRepository.ConsultarAnuncioDetallePorAnuncioAsync(anuncio.IdAnuncio); var tipoPropiedad = await _tipoPropiedadRepository.ConsultarTipoPropiedadAsync(anuncio.IdTipoPropiedad); var ubicacion = await _ubicacionRepository.ConsultarPorAnuncioAsync(anuncio.IdAnuncio); var evaluaciones = await _evaluacionRepository.ConsultarPorAnuncioAsync(anuncio.IdAnuncio); var imagenes = await _imagenRepository.ConsultarPorAnuncioAsync(anuncio.IdAnuncio); var anuncioResponse = _mapper.Map <AnuncioResponse>(anuncio); var usuarioResponse = usuario is null ? new UsuarioResponse() : _mapper.Map <UsuarioResponse>(usuario); var tipoPropiedadResponse = tipoPropiedad is null ? new TipoPropiedadResponse() : _mapper.Map <TipoPropiedadResponse>(tipoPropiedad); var evaluacionResponses = _mapper.Map <IEnumerable <EvaluacionResponse> >(evaluaciones); var imagenResponses = _mapper.Map <IEnumerable <ImagenResponse> >(imagenes); ubicacion = ubicacion ?? new UbicacionEntity(); anuncioDetalle = anuncioDetalle ?? new AnuncioDetalleEntity(); anuncioResponse.Usuario = usuarioResponse; anuncioResponse.TipoPropiedad = tipoPropiedadResponse; anuncioResponse.Metros2 = anuncioDetalle.Metros2; anuncioResponse.CantidadHabitaciones = anuncioDetalle.CantidadHabitaciones; anuncioResponse.CantidadBaños = anuncioDetalle.CantidadBaños; anuncioResponse.CantidadParqueos = anuncioDetalle.CantidadParqueos; anuncioResponse.Plantas = anuncioDetalle.Plantas; anuncioResponse.Direccion = ubicacion.Direccion; anuncioResponse.Latitud = ubicacion.Latitud; anuncioResponse.Longitud = ubicacion.Longitud; anuncioResponse.Evaluaciones = evaluacionResponses; anuncioResponse.Imagenes = imagenResponses; anuncioResponses.Add(anuncioResponse); } response.Success = true; response.Message = "Se obtuvo información de anuncios exitosamente."; response.Data = anuncioResponses; return(response); }