public override async Task <int> GetPostPageCount(WordpressPostStatusType status, int pageSize) { return(await GetFromCacheOrData( getCacheItemKey : () => $"{GetType().Name}|{nameof(GetPostPageCount)}|{status.ToString()}|{pageSize}", getCacheItemFunc : async() => await base.GetPostPageCount(status, pageSize) )); }
public override async Task <IReadOnlyCollection <string> > GetPostIds(WordpressPostStatusType status, int pageIndex = 0, int pageSize = int.MaxValue) { return(await GetFromCacheOrData( getCacheItemKey : () => $"{GetType().Name}|{nameof(GetPostIds)}|{pageIndex}|{pageSize}", getCacheItemFunc : async() => await base.GetPostIds(status, pageIndex, pageSize) )); }
public override async Task <WordpressPostContentDto> GetPostContent(WordpressPostStatusType status, string postId) { return(await GetFromCacheOrData( getCacheItemKey : () => $"{GetType().Name}|{nameof(GetPostContent)}|{postId}", getCacheItemFunc : async() => await base.GetPostContent(status, postId) )); }
public virtual async Task <int> GetPostCount( WordpressPostStatusType status ) { const string dbQuery = "SELECT COUNT(1) post_count FROM wp_posts WHERE post_type='post' AND post_status=@status;"; var dbObject = await _dbConnection.Execute(dbQuery, new { status = status.ToString() }); return(dbObject); }
public virtual async Task <WordpressPostContentDto> GetPostContent( WordpressPostStatusType status, string postId ) { const string dbQuery = "SELECT p.post_date,p.post_title,p.post_name,p.post_content FROM wp_posts p WHERE p.post_type='post' AND p.post_status=@status AND p.post_name=@postId LIMIT 1;"; var dbObject = await _dbConnection.QuerySingle <WordpressPostContentDto>(dbQuery, new { status = status.ToString(), postId }); return(dbObject); }
public virtual async Task <int> GetPostPageCount( WordpressPostStatusType status, int pageSize ) { if (pageSize < 0) { throw new ArgumentOutOfRangeException("pageSize"); } var postCount = await GetPostCount(status); if (postCount == 0) { return(0); } var pageCount = (postCount / pageSize) + 1; return(pageCount); }
public virtual async Task <IReadOnlyCollection <string> > GetPostIds( WordpressPostStatusType status, int pageIndex = 0, int pageSize = int.MaxValue ) { if (pageIndex < 0) { throw new ArgumentOutOfRangeException("pageIndex"); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException("pageSize"); } var dbQuery = $"SELECT DISTINCT p.post_name FROM wp_posts p WHERE p.post_type='post' AND p.post_status=@status ORDER BY 1 DESC LIMIT {pageSize} OFFSET {pageIndex * pageSize};"; var dbObject = await _dbConnection.Query <WordpressPostDto>(dbQuery, new { status = status.ToString() }); return(dbObject.Select(r => r.post_name).EnsureArray()); }