async void LoadData()
        {
            var workspaces = await new StorageService().GetWorkspaces();


            Dispatcher.RunAsync(() =>
            {
                Workspaces.AddRange(workspaces);


                if (SettingsService.DefaultWorkspaceId != null)
                {
                    var item = workspaces.FirstOrDefault(x => x.id == SettingsService.DefaultWorkspaceId.Value);

                    SelectedWorkspace = item;
                }
                else
                {
                    SettingsService.DefaultWorkspaceId = workspaces.First().id;
                    SelectedWorkspace = workspaces.FirstOrDefault();
                }
            });



            var users = await new StorageService().GetUsers();

            users.Insert(0, new AsanaUser()
            {
                name = "None", id = -1
            });

            Dispatcher.RunAsync(() =>
            {
                Users.AddRange(users);

                if (SettingsService.CurrentUserId != null)
                {
                    var user     = users.FirstOrDefault(x => x.id == SettingsService.CurrentUserId.Value);
                    SelectedUser = user;
                }
            });



            IsUpdateMainTile = SettingsService.UpdateMainTile;


            IsBusy = false;
        }
Ejemplo n.º 2
0
        async Task LoadWorkspacesFromDb()
        {
            var dbWorkspaces = await new StorageService().GetWorkspaces();

            foreach (var asanaWorkspace in dbWorkspaces)
            {
                asanaWorkspace.ProjectsCount =
                    await GetStorageService().GetAsyncConnection().Table <AsanaProject>().Where(
                        x => x.workspaceid == asanaWorkspace.id && x.archived == false).CountAsync();
            }
            AsanaStateService.NeedToSyncData = !dbWorkspaces.Any();

            Dispatcher.RunAsync(() =>
            {
                Workspaces.Clear();
                Workspaces.AddRange(dbWorkspaces);
                // IsAppBarVisible = true;
            });
        }