public async Task GetTodoLists()
        {
            HttpResult <TodoList[]> result = await client.GetTodoListsAsync();

            Assert.IsNotNull(result, "Result is null");
            Assert.IsTrue(result.Succeeded, GetRequestFailedMessage(result));
            Assert.IsTrue(result.Content.Length > 0, "No todo lists received");
            Assert.IsTrue(result.Content[0].Todos.Count > 0, "No todo items received");
        }
Example #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            TodoPageModel.TodoLists.Clear();
            HttpResult <UserInfo> userInfoResult;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                userInfoResult = await accountClient.GetUserInfoAsync();
            }

            if (userInfoResult.Succeeded)
            {
                UserInfo userInfo = userInfoResult.Content;
                TodoPageModel.Username = String.Format("{0}", userInfo.UserName);

                HttpResult <TodoList[]> todoListResult;
                using (TodoClient todoClient = ClientFactory.CreateTodoClient())
                {
                    todoListResult = await todoClient.GetTodoListsAsync();
                }

                if (todoListResult.Succeeded)
                {
                    if (todoListResult.Content.Length == 0)
                    {
                        this.NavigationService.Navigate(AddTodoListPage.GetNavigationUri());
                    }
                    else
                    {
                        foreach (TodoList todoList in todoListResult.Content)
                        {
                            TodoPageModel.TodoLists.Add(new TodoListModel(todoList));
                        }
                    }
                }
                else
                {
                    ErrorDialog.ShowErrors(todoListResult.Errors);
                }
            }
            else
            {
                ErrorDialog.ShowErrors(userInfoResult.Errors);
            }
        }
        async Task GetTodoListsAsync()
        {
            TodoPageModel.TodoLists.Clear();
            HttpResult <TodoList[]> todoListResult;

            using (TodoClient todoClient = ClientFactory.CreateTodoClient())
            {
                todoListResult = await todoClient.GetTodoListsAsync();
            }

            if (todoListResult.Succeeded)
            {
                foreach (TodoList todoList in todoListResult.Content)
                {
                    TodoPageModel.TodoLists.Add(new TodoListModel(todoList));
                }
            }
            else
            {
                await ErrorDialog.ShowErrorsAsync(todoListResult.Errors);
            }
        }