public async Task <ActionResult <ListResult <List <PostMedium> > > > GetUserPosts(DateTime beforeDateTime, string username, int skip = 0, int take = 20) { _logger.LogInformation(nameof(GetUserPosts) + ": " + username); if (beforeDateTime == DateTime.MinValue) { beforeDateTime = DateTime.UtcNow; } var posts = await _repo.GetUserPosts(beforeDateTime, username, skip, take); if (posts == null) { return(NotFound()); } var list = new List <PostMedium>(); foreach (var item in posts) { list.Add(PostMedium.FromPost(item, _imageServer)); } return(new ListResult <List <PostMedium> > { Data = list, Count = await _repo.GetUserPostsCount(username, beforeDateTime) }); }
public async Task <ActionResult <ListResult <List <PostMedium> > > > GetAllPosts(DateTime beforeDateTime, int skip = 0, int take = 20) { if (beforeDateTime == DateTime.MinValue) { beforeDateTime = DateTime.UtcNow; } var posts = await _repo.GetPosts(beforeDateTime, skip, take); var list = new List <PostMedium>(); foreach (var item in posts) { list.Add(PostMedium.FromPost(item, _imageServer)); } return(new ListResult <List <PostMedium> > { Data = list, Count = await _repo.GetPostCount(it => it.UpTime < beforeDateTime) }); }
public async Task <ActionResult <ListResult <List <PostMedium> > > > SearchPostsByTags(string keywords, DateTime beforeDateTime, int skip = 0, int take = 20) { if (beforeDateTime == DateTime.MinValue) { beforeDateTime = DateTime.UtcNow; } var posts = await _repo.GetPostsByTag(keywords, beforeDateTime, skip, take); var list = new List <PostMedium>(); foreach (var item in posts) { list.Add(PostMedium.FromPost(item, _imageServer)); } return(new ListResult <List <PostMedium> > { Data = list, Count = await _repo.GetPostsByTagCount(keywords, beforeDateTime) }); }