public AddAction(Models.Rule rule) { //Initialise InitializeComponent(); _rule = rule; //If Action already created, load the info. _action = rule.Action; //If Communicator already created, load the info. if (_action != null) { var controller = new CommunicatorController(); _comm = controller.GetAllCommunicators().FirstOrDefault(c => c.Id == rule.Action.CommunicatorId); } }
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!"); } }