private (bool?IsNecessary, string content) GetContent(HueGroupDto currentGroup, HueGroupStatePutDto state, bool withoutOn) { object content = null; if (withoutOn) { content = this._mapper.Map <GroupStateWithoutOnPut>(state); } else { content = this._mapper.Map <GroupStateWithOnPut>(state); } if (content == null) { this._logger?.LogError($"{nameof(GroupStateHandler)}hat keinen gültigen Status Wert"); return(false, string.Empty); } try { return(true, LowerCaseSerializer.SerializeObjectWithoutNullProperties(content)); } catch (Exception ex) { this._logger?.LogError(ex, "Während der Serialisierung trat ein Fehler auf"); return(null, string.Empty); } }
private (bool?IsNecessary, string content) GetContent(HueDeviceDto currentDevice, HueLightStatePutDto state, bool withoutOn) { if (TryParseHueDeviceType(currentDevice, out var deviceType)) { var contentDto = this.MapToType(deviceType, state, withoutOn); if (contentDto == null) { this._logger?.LogError($"{nameof(LightStateHandler)} hat den DeviceType {currentDevice.Type} nicht implementiert"); return(false, string.Empty); } else { try { return(true, LowerCaseSerializer.SerializeObject(contentDto)); } catch (Exception ex) { this._logger?.LogError(ex, "Während der Serialisierung trat ein Fehler auf"); return(null, string.Empty); } } } else { this._logger?.LogError($"Light {currentDevice.Name} hat einen ungültigen Type {currentDevice.Type}"); return(null, string.Empty); } }