private void bSave_Click(object sender, EventArgs e) { if (_comm != null && _rule != null && tOutput.Text != "") { if (_action==null) _action = new Models.Action(); _action.CommunicatorId = _comm.Id; _action.Enabled = cEnabled.Checked; _action.OutputValue = tOutput.Text; _action.Communicator = _comm; _action.Rule = _rule; _action.RuleId = _rule.Id; //_action.Id var controller = new ActionController(); _action = controller.CreateAction(_action); if (_action.Id > 0) System.Windows.Forms.MessageBox.Show("Success!"); } }
private void bSaveAction_Click(object sender, EventArgs e) { var ruleSelected = _rule != null; var destinationSelected = add_cbCommunicatorDestination.SelectedItem != null; var outputEntered = add_tOutputValue.Text != ""; if (!(ruleSelected && destinationSelected && outputEntered)) { DebugOutput.Print("Unable to save - not all data has been entered!"); return; } _communicator = (Models.Communicator)add_cbCommunicatorDestination.SelectedItem; var newAction = new Models.Action() { Rule = _rule, RuleId = _rule.Id, Communicator =_communicator, CommunicatorId = _communicator.Id, OutputValue = add_tOutputValue.Text, Enabled = add_cActionEnabled.Checked }; var controller = new ActionController(); var action = controller.CreateAction(newAction); if (action != null) { DebugOutput.Print("Successfully created a new Action."); this.Close(); } }