public async Task UpdateConfigurationAsync( SmartDevice smartDevice, UpdateSmartDeviceConfigurationRequest updateSmartDeviceConfigurationRequest) { smartDevice.IsCaching = (bool)updateSmartDeviceConfigurationRequest.IsCaching; smartDevice.IsTurnedOn = (bool)updateSmartDeviceConfigurationRequest.IsTurnedOn; await _dbContext.SaveChangesAsync(); await _smartDeviceHubService.SendUpdateMessageAsync(smartDevice.Id); }
public async Task <IActionResult> UpdateConfiguration( [FromRoute] Guid smartDeviceId, [FromBody] UpdateSmartDeviceConfigurationRequest updateSmartDeviceConfigurationRequest) { Guid partnerId = Guid.Parse(User.Identity.Name); try { SmartDevice smartDevice = await _smartDeviceService.GetSmartDeviceByIdAndPartnerIdAsync(smartDeviceId, partnerId); await _smartDeviceService.UpdateConfigurationAsync(smartDevice, updateSmartDeviceConfigurationRequest); return(Ok()); } catch (Exception e) { return(BadRequest(new BadRequestResponseMessage(e.Message))); } }