public async Task <IActionResult> Create(Guid deviceId, [Bind("Id, DateTime,SoilMoisture,SoilDescription,AirHumidity,AirTemperature,LightState,DeviceName")] Entry entry) { if (!ModelState.IsValid) { return(View(entry)); } await _repository.AddAsync(entry, await GetDeviceAsync(deviceId)); return(RedirectToAction(nameof(Index), new { deviceId })); }
public async Task <IActionResult> PostMeasure([FromBody] MeasureDevice measureDevice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Device dev = await _deviceRepository.GetAsync(measureDevice.deviceId); if (dev == null) { return(NotFound(measureDevice.deviceId)); } await _hubContext.Clients.Group(GetUserName()).InvokeAsync("newEntry", dev.Name); if (await _repository.AddAsync(measureDevice.Entry, dev)) { return(Ok( await _repository.GetAsync(measureDevice.Entry.DateTime, dev))); } return(BadRequest()); }
public async Task RecordAsync(string name, float value, string unit, DateTime date) { var measure = new Measure(name, value, unit, date); await _measureRepository.AddAsync(measure); }