public async Task <IHttpActionResult> QueryMeasurements(QueryRequest query)
        {
            /* Check if model is valid */
            if (!ModelState.IsValid)
            {
                var errors = ModelState.ToDictionary(
                    kvp => kvp.Key,
                    kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
                    );
                return(Content(HttpStatusCode.BadRequest, errors));
            }

            IMeasurementDao dao        = AdoFactory.Instance.GetMeasurementDao("wetr");
            IStationDao     stationDao = AdoFactory.Instance.GetStationDao("wetr");
            Station         s          = await stationDao.FindByIdAsync(query.StationId);

            double[] result = await dao.GetQueryResult(query.Start, query.End, query.MeasurementTypeId, query.ReductionTypeId, query.GroupingTypeId,
                                                       new List <Station>() { s });

            return(Content(HttpStatusCode.OK, result));
        }
Beispiel #2
0
 public async Task <double[]> GetQueryResult(DateTime start, DateTime end, int measurementTypeId, int reductionTypeId, int groupingTypeId, List <Station> stations)
 {
     return(await measurementDao.GetQueryResult(start, end, measurementTypeId, reductionTypeId, groupingTypeId, stations));
 }