예제 #1
0
        public async Task <ActionResult> GetObservations(WeatherWmo stationId, string fields)
        {
            var result = await _service.GetJsonAsync(stationId);

            var records = result?.GetRecords();

            if (!string.IsNullOrEmpty(fields))
            {
                var splitter = ',';
                var expandos = _service.FilterBy(records, fields.Split(splitter));

                var jsonExpandos = JsonConvert.SerializeObject(expandos);
                return(Ok(jsonExpandos));
            }
            else
            {
                var jsonRecords = JsonConvert.SerializeObject(records);
                return(Ok(jsonRecords));
            }
        }