Esempio n. 1
0
        private void addTaskButton_Click(object sender, EventArgs e)
        {
            LOGGER.Info($"User wants to add a new task");

            AddOrUpdateTaskForm form = new AddOrUpdateTaskForm(null);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                Task created = TaskClient.CreateTask(Accounts[accountsListView.SelectedIndices[0]].id, form.Task);

                RefreshTasks();

                if (FoundTasks.Any(t => t.id == created.id))
                {
                    LOGGER.Info($"Selecting the newly created task");

                    tasksListView.SelectedIndices.Clear();
                    tasksListView.SelectedIndices.Add(FoundTasks.IndexOf(FoundTasks.First(t => t.id == created.id)));
                }
                else
                {
                    MessageBox.Show(this, "Task angelegt", "Der Task wurde erfolgreich angelegt.");
                }
            }
        }
Esempio n. 2
0
        private void tasksListView_DoubleClick(object sender, EventArgs e)
        {
            LOGGER.Debug($"User wants to edit a task");

            if (tasksListView.SelectedIndices.Count == 1)
            {
                LOGGER.Info($"Editing task '{FoundTasks[tasksListView.SelectedIndices[0]]}'");

                AddOrUpdateTaskForm form = new AddOrUpdateTaskForm(FoundTasks[tasksListView.SelectedIndices[0]]);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    LOGGER.Info($"Updating task");

                    Task updated = TaskClient.UpdateTask(Accounts[accountsListView.SelectedIndices[0]].id, form.Task);

                    LOGGER.Info($"Updated task, new value '{updated}'");

                    RefreshTasks();

                    if (FoundTasks.Any(t => t.id == updated.id))
                    {
                        LOGGER.Info($"Selecting the updated task");

                        tasksListView.SelectedIndices.Clear();
                        tasksListView.SelectedIndices.Add(FoundTasks.IndexOf(FoundTasks.First(t => t.id == updated.id)));
                    }
                    else
                    {
                        MessageBox.Show(this, "Task aktualisiert", "Der Task wurde erfolgreich aktualisiert.");
                    }
                }
                else
                {
                    LOGGER.Info($"Edit dialog was canceled by the user");
                }
            }
        }