/// <summary> /// Updates an event /// </summary> /// <param name="id">The id of the event</param> /// <returns>Whether the event was updated</returns> public bool Update(string id) { bool updated = false; try { SavedEvent @event = _eventController.GetEvent(id); if (@event != null) { EventCrudView form = new EventCrudView(_controls); form.CreateView(CrudPurposes.Edit, @event); form.ShowDialog(); SavedEvent result = form.Data.Results; DialogResult dialogResult = form.Data.DialogResult; if (dialogResult != DialogResult.Cancel && result != null) { result.Id = @event.Id; updated = _eventController.EditEvent(result); } form.Dispose(); } } catch (Exception) { MessageBox.Show("Unable to update item.", "Please try again.", MessageBoxButtons.OK); updated = false; } return(updated); }
/// <summary> /// Adds and event /// </summary> /// <returns>Whether the event was added</returns> public bool Add() { bool added = false; try { EventCrudView form = new EventCrudView(_controls); form.CreateView(CrudPurposes.Create); form.ShowDialog(); SavedEvent result = form.Data.Results; DialogResult dialogResult = form.Data.DialogResult; if (dialogResult != DialogResult.Cancel && result != null) { added = _eventController.CreateEvent(result); } form.Dispose(); } catch (Exception) { MessageBox.Show("Unable to add item.", "Please try again.", MessageBoxButtons.OK); added = false; } return(added); }