public MemberContext(string id, bool isMe, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Member), () => Data.Id, auth); if (isMe) { Boards = new BoardCollection(typeof(Member), () => Data.Id, auth); BoardBackgrounds = new BoardBackgroundCollection(() => Data.Id, auth); Organizations = new OrganizationCollection(() => Data.Id, auth); StarredBoards = new StarredBoardCollection(() => Data.Id, auth); } else { Boards = new ReadOnlyBoardCollection(typeof(Member), () => Data.Id, auth); BoardBackgrounds = new ReadOnlyBoardBackgroundCollection(() => Data.Id, auth); Organizations = new ReadOnlyOrganizationCollection(() => Data.Id, auth); StarredBoards = new ReadOnlyStarredBoardCollection(() => Data.Id, auth); } Boards.Refreshed += (s, e) => OnMerged(new[] { nameof(Boards) }); BoardBackgrounds.Refreshed += (s, e) => OnMerged(new[] { nameof(BoardBackgrounds) }); Organizations.Refreshed += (s, e) => OnMerged(new[] { nameof(Organizations) }); StarredBoards.Refreshed += (s, e) => OnMerged(new[] { nameof(StarredBoards) }); Cards = new ReadOnlyCardCollection(EntityRequestType.Member_Read_Cards, () => Data.Id, auth); Cards.Refreshed += (s, e) => OnMerged(new[] { nameof(Cards) }); Notifications = new ReadOnlyNotificationCollection(() => Data.Id, auth); Notifications.Refreshed += (s, e) => OnMerged(new[] { nameof(Notifications) }); MemberPreferencesContext = new MemberPreferencesContext(Auth); MemberPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = MemberPreferencesContext.Data; }
private static bool IsNotificationsUnread(ReadOnlyNotificationCollection notifications) { if (!notifications.Any()) { return(false); } foreach (var notification in notifications) { if (notification.IsUnread != null && notification.IsUnread.Value) { return(true); } } return(false); }
public MemberContext(string id, bool isMe, TrelloAuthorization auth) : base(auth) { Data.Id = id; Actions = new ReadOnlyActionCollection(typeof(Member), () => Data.Id, auth); Boards = isMe ? new BoardCollection(typeof(Member), () => Data.Id, auth) : new ReadOnlyBoardCollection(typeof(Member), () => Data.Id, auth); Cards = new ReadOnlyCardCollection(EntityRequestType.Member_Read_Cards, () => Data.Id, auth); Organizations = isMe ? new OrganizationCollection(() => Data.Id, auth) : new ReadOnlyOrganizationCollection(() => Data.Id, auth); Notifications = new ReadOnlyNotificationCollection(() => Data.Id, auth); MemberPreferencesContext = new MemberPreferencesContext(Auth); MemberPreferencesContext.SubmitRequested += ct => HandleSubmitRequested("Preferences", ct); Data.Prefs = MemberPreferencesContext.Data; }