Exemplo n.º 1
0
        public async Task <WeatherForecastData> GetWeatherForecastById(int id)
        {
            var request = new GetWeatherForecastByIdRequest
            {
                WeatherForecastId = id
            };

            var response = await _client.GetWeatherForecastByIdAsync(request);

            return(_mapper.Map <WeatherForecast, WeatherForecastData>(response.Forecast));
        }
Exemplo n.º 2
0
        public override async Task <GetWeatherForecastResponse> GetWeatherForecastById(GetWeatherForecastByIdRequest request, ServerCallContext context)
        {
            var id = request.WeatherForecastId;

            if (id <= 0)
            {
                const string error = "Weather Forecast id must be a positive integer";
                throw new RpcException(new Status(StatusCode.InvalidArgument, error));
            }

            var result = await _repository.GetWeatherForecastById(id);

            return(new GetWeatherForecastResponse
            {
                Forecast = _mapper.Map <WeatherForecastStoredData, WeatherForecast>(result)
            });
        }