//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; } }
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; } }
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; } }
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; } }