// GET: Measurement public ActionResult Index() { var measurements = _measurementService.Get(); if (measurements.Count == 0) { return(NotFound()); } var view = new List <MeasurementViewModel>(); foreach (var measurement in measurements) { var m = new MeasurementViewModel { Time = measurement.Time, Temperature = measurement.Temperature, AirPressure = measurement.AirPressure, Humidity = measurement.Humidity }; if (measurement.LocalWeatherStation != null) { m.WeatherStationName = measurement.LocalWeatherStation.Name; } view.Add(m); } return(Json(view)); }
public async Task <ActionResult> Get(string id) { if (id == "") { throw new NullReferenceException("measurement not found"); } if (!_context.Measurements.Any()) { throw new NullReferenceException("measurement not found"); } var measurement = await _measurementService.Get(id); return(Ok(measurement)); }
private void Button_Click(object sender, RoutedEventArgs e) { var vm = (InputPageViewModel)this.DataContext; var meas = new Measurement(); meas.ID = vm.ID; meas.Name = vm.Name; meas.Timestamp = vm.Timestamp; meas.UoM = vm.UoM; meas.Value = vm.Value; var entry = measurementService.Get(vm.ID); if (entry == null) { measurementService.Create(meas); } else { measurementService.Update(meas); } }
public ActionResult <List <Measurements> > GetAll() => _measurementService.Get();
public Measurement Get(int id) { return(Service.Get(id)); }