public async Task <IActionResult> Edit(Guid deviceId, [FromForm] Device device) { if (deviceId != device.DeviceId) { return(NotFound()); } if (!ModelState.IsValid) { return(View(device)); } return(!await _logDb.DeviceSave(device) ? (IActionResult)NotFound() : RedirectToAction(nameof(Index), new { deviceId })); }
public async Task <Device> DeviceUpdate(Guid deviceId, [FromBody] Device device) { if (device == null) { return new Device() { StatusData = StatusData.Failure("No device supplied") } } ; if (deviceId != device.DeviceId) { return(device.Failure("Device Id doesn't match route")); } if (!ModelState.IsValid) { return(device.Failure("Model isn't valid")); } await _logDb.DeviceSave(device); return(device); }