Exemplo n.º 1
0
        public IEnumerable<BoardViewModel> FetchBoardViewModelsForMe()
        {
            var boards = trello.Boards.ForMe(BoardFilter.Open).ToList();

            var organizations = boards
                .Select(b => b.IdOrganization)
                .Where(s => !string.IsNullOrEmpty(s))
                .Distinct()
                .Select(orgId =>
                {
                    try
                    {
                        return trello.Organizations.WithId(orgId);
                    }
                    catch (TrelloUnauthorizedException)
                    {
                        return null;
                    }
                })
                .Where(o => o != null)
                .ToDictionary(organization => organization.Id);

            return boards.Select(b =>
            {
                var model = new BoardViewModel(b);
                if (b.IdOrganization != null && organizations.ContainsKey(b.IdOrganization))
                    model.SetOrganizationName(organizations[b.IdOrganization].DisplayName);
                return model;
            });
        }
Exemplo n.º 2
0
        public IEnumerable <BoardViewModel> FetchBoardViewModelsForMe()
        {
            var boards = trello.Boards.ForMe(BoardFilter.Open).ToList();

            var organizations = boards
                                .Select(b => b.IdOrganization)
                                .Where(s => !string.IsNullOrEmpty(s))
                                .Distinct()
                                .Select(orgId =>
            {
                try
                {
                    return(trello.Organizations.WithId(orgId));
                }
                catch (TrelloUnauthorizedException)
                {
                    return(null);
                }
            })
                                .Where(o => o != null)
                                .ToDictionary(organization => organization.Id);

            return(boards.Select(b =>
            {
                var model = new BoardViewModel(b);
                if (b.IdOrganization != null && organizations.ContainsKey(b.IdOrganization))
                {
                    model.SetOrganizationName(organizations[b.IdOrganization].DisplayName);
                }
                return model;
            }));
        }
Exemplo n.º 3
0
        public IEnumerable<BoardViewModel> FetchBoardViewModelsForMe()
        {
            var boards = trello.Boards.ForMe(BoardFilter.Open).ToList();

            var organizations = boards
                .Select(b => b.IdOrganization)
                .Where(s => !string.IsNullOrEmpty(s))
                .Distinct()
                .Select(orgId =>
                {
                    try
                    {
                        return trello.Organizations.WithId(orgId);
                    }
                    catch (TrelloUnauthorizedException)
                    {
                        return null;
                    }
                    catch (TrelloException)
                    {
                        //TODO: Need to figure out why this is being thrown and correct it.
                        // Adding return null at least supresses the alert.
                        return null;
                    }
                })
                .Where(o => o != null)
                .ToDictionary(organization => organization.Id);

            return boards.Select(b =>
            {
                var model = new BoardViewModel(b);
                if (b.IdOrganization != null && organizations.ContainsKey(b.IdOrganization))
                    model.SetOrganizationName(organizations[b.IdOrganization].DisplayName);
                return model;
            });
        }
Exemplo n.º 4
0
        private void FetchAndDisplayBoards()
        {
            DisableStuff();
            Task.Factory.StartNew(() =>
            {
                // <WTF>

                var boards = trello.Boards.ForMe(BoardFilter.Open);

                var organizations = boards
                    .Select(b => b.IdOrganization)
                    .Where(s => !string.IsNullOrEmpty(s))
                    .Distinct()
                    .Select(orgId =>
                    {
                        try
                        {
                            return trello.Organizations.WithId(orgId);
                        }
                        catch (TrelloUnauthorizedException)
                        {
                            return null;
                        }
                    })
                    .Where(o => o != null)
                    .ToDictionary(organization => organization.Id);

                return boards.Select(b =>
                {
                    var model = new BoardViewModel(b);
                    if (b.IdOrganization != null && organizations.ContainsKey(b.IdOrganization))
                        model.SetOrganizationName(organizations[b.IdOrganization].DisplayName);
                    return model;
                });

                // </WTF>
            })
            .ContinueWith(t =>
            {
                if (t.Exception == null)
                {
                    view.DisplayBoards(t.Result);
                    view.EnableSelectionOfBoards = true;
                }
                else
                {
                    HandleException(t.Exception);
                }
            }, taskScheduler);
        }