private void BtnSave_Click(object sender, RoutedEventArgs e) { bool result; if (_id != null) { Rule _newrule = _rcvm.Rule; _newrule.Id = _id; result = _bridge.ModifyObject(_newrule); } else { result = _bridge.CreateObject(_rcvm.Rule); if (result) { _id = _bridge.LastCommandMessages.LastSuccess.value; } } if (result) { DialogResult = true; Close(); } else { _bridge.ShowErrorMessages(); } }
private async Task Send() { DialogResult result = DialogResult.Yes; if (RequestType == WebRequestType.Delete) { result = MessageBox.Show(GlobalStrings.AdvancedCreator_WarningDelete, GlobalStrings.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } if (result == DialogResult.Yes) { string json = await _bridge.SendRawCommandAsyncTask(Url, Text, RequestType); if (json == null) { _bridge.ShowErrorMessages(); } else { if (RequestType == WebRequestType.Get) { Text = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(json), Formatting.Indented); } else { MessageBox.Show(_bridge.LastCommandMessages.ToString(), GlobalStrings.Success, MessageBoxButtons.OK, MessageBoxIcon.Information); OnObjectCreated?.Invoke(this, EventArgs.Empty); } } } }
private void btnSaveScene_Click(object sender, RoutedEventArgs e) { Scene newScene = _scvm.Scene; bool result; log.Info("Scene to be created : " + newScene); if (_currentsceneid == string.Empty) { result = _bridge.CreateObject(newScene); } else { newScene.Id = _currentsceneid; result = _bridge.ModifyObject(newScene); } if (result) { string id = _currentsceneid != string.Empty ? _currentsceneid : _bridge.LastCommandMessages.LastSuccess.value; log.Info("Id of the scene" + id); foreach (KeyValuePair <string, State> obj in newScene.lightstates) { _bridge.SetSceneLightState(id, obj.Key, obj.Value); } _currentsceneid = id; DialogResult = true; Close(); } else { _bridge.ShowErrorMessages(); log.Error(_bridge.LastCommandMessages); } }