예제 #1
0
        //Todo Methods
        private async void ChangeTodoCompletionStatus(object obj)
        {
            parentWindow.Busy = true;
            parentWindow.ClearMessages();

            VMHabiticaTodo vmTodo = (VMHabiticaTodo)obj;

            try
            {
                HabiticaClient client = HabiticaClient.GetInstance();

                if (!vmTodo.Completed)
                {
                    await client.CheckOffTodo(vmTodo.Todo);

                    vmTodo.Completed = true;
                }
                else
                {
                    await client.UncheckTodo(vmTodo.Todo);

                    vmTodo.Completed = false;
                }
            }
            catch (Exception e)
            {
                parentWindow.handleException(e);
            }
            finally
            {
                parentWindow.Busy = false;
            }
        }
예제 #2
0
        private async void SaveTodo(object obj)
        {
            parentWindow.Busy = true;
            parentWindow.ClearMessages();

            VMHabiticaTodo vmTodo = (VMHabiticaTodo)obj;

            try
            {
                HabiticaClient client = HabiticaClient.GetInstance();
                await client.SaveTodo(vmTodo.Todo);

                parentWindow.SuccessMessage = "Changes saved";
            }
            catch (Exception e)
            {
                parentWindow.handleException(e);
            }
            finally
            {
                parentWindow.Busy = false;
            }
        }
예제 #3
0
        private async void DeleteTodo(object obj)
        {
            parentWindow.Busy = true;
            parentWindow.ClearMessages();

            VMHabiticaTodo vmTodo = (VMHabiticaTodo)obj;

            try
            {
                HabiticaClient client = HabiticaClient.GetInstance();
                await client.DeleteTodo(vmTodo.Todo);

                TodoList.Remove(vmTodo);
            }
            catch (Exception e)
            {
                parentWindow.handleException(e);
            }
            finally
            {
                parentWindow.Busy = false;
            }
        }
예제 #4
0
        private async void LoadTodo(object obj)
        {
            parentWindow.Busy = true;
            parentWindow.ClearMessages();

            VMHabiticaTodo oldVmTodo = (VMHabiticaTodo)obj;
            int            index     = TodoList.IndexOf(oldVmTodo);

            try
            {
                HabiticaClient client = HabiticaClient.GetInstance();
                TodoList.Insert(index, new VMHabiticaTodo(await client.LoadTodo(oldVmTodo.Todo)));

                TodoList.Remove(oldVmTodo);
            }
            catch (Exception e)
            {
                parentWindow.handleException(e);
            }
            finally
            {
                parentWindow.Busy = false;
            }
        }