/// <summary> /// Saves the board. /// </summary> /// <param name="board">Board.</param> public void SaveBoard(BoardCache board) { if (IsBoardExists(board.Id) == true) { this.Conn.Update(board); } else { this.Conn.Insert(board); } this.Conn.Commit(); }
/// <summary> /// Updates the boards. /// </summary> /// <returns>The boards.</returns> private static async Task FetchBoards() { var boards = await client.Me.GetBoardsAsync(); // Fetch personal board. foreach (var board in boards) { var new_board = new BoardCache() { Id = board.Id, Name = board.Name, Type = BoardType.Me, Description = board.Description, CreatedAt = board.CreatedAt, Url = board.Url }; db.SaveBoard(new_board); logger.Info(string.Format("Fetched my board {0},{1} is saved to the database", board.Id, board.Name)); } // Fetch following boards. var following = await client.Me.GetFollowingBoardsAsync(null, FETCH_PIN_LIMIT); foreach (var board in following) { var new_board = new BoardCache() { Id = board.Id, Name = board.Name, Type = BoardType.Following, Description = string.Empty, CreatedAt = DateTime.Today, Url = board.Url }; db.SaveBoard(new_board); logger.Info(string.Format("Fetched following board {0},{1} is saved to the database", board.Id, board.Name)); } while (string.IsNullOrEmpty(following.NextPageCursor) == false) { foreach (var board in following) { var new_board = new BoardCache() { Id = board.Id, Name = board.Name, Type = BoardType.Following, Description = string.Empty, CreatedAt = DateTime.Today, Url = board.Url }; db.SaveBoard(new_board); logger.Info(string.Format("Fetched following board {0},{1} is saved to the database", board.Id, board.Name)); } } }