public bool Add() { bool added = false; try { MessageCrudView form = new MessageCrudView(_controls); form.CreateView(CrudPurposes.Create); form.ShowDialog(); AppMessage result = form.Data.Results; DialogResult dialogResult = form.Data.DialogResult; if (dialogResult != DialogResult.Cancel && result != null) { added = _messageController.CreateMessage(result); } form.Dispose(); } catch (Exception) { MessageBox.Show("Unable to add item.", "Please try again.", MessageBoxButtons.OK); added = false; } return(added); }
public bool Update(string id) { bool updated = false; try { AppMessage message = _messageController.GetMessage(id); if (message != null) { MessageCrudView form = new MessageCrudView(_controls); form.CreateView(CrudPurposes.Edit, message); form.ShowDialog(); AppMessage result = form.Data.Results; DialogResult dialogResult = form.Data.DialogResult; if (dialogResult != DialogResult.Cancel && result != null) { result.Id = message.Id; updated = _messageController.EditMessage(result); } form.Dispose(); } } catch (Exception) { MessageBox.Show("Unable to update item.", "Please try again.", MessageBoxButtons.OK); updated = false; } return(updated); }