public void GetPost_WhenEmptyContext_ReturnsNull() { // Arrange var id = 1; // Act var postDto = _postManager.GetAsync(id).GetAwaiter().GetResult(); // Assert Assert.Null(postDto); }
public async Task <IActionResult> GetPost(int id) { var post = await _postManager.GetAsync(id); var postModel = new { post.Id, post.PostTitle, post.Content, post.PostStatus, post.Permerlink, coverImage = post.CoverImageId != null?Url.Action("PostCoverImage", new { postId = post.Id }) : null }; return(Json(postModel)); }
public async Task CreateCommentAsync(CreateCommentInput input) { var @post = await _postManager.GetAsync(input.PostId); var @comment = Comment.Create(@post, AbpSession.GetUserId(), input.Text); await _postManager.CreateCommentAsync(@comment); }
public async Task OnGet() { try { if (ID == null || ID == 0) { Post = new Post(); Post.Author = ""; Post.Description = ""; Post.Title = ""; Post.Comments = new List <Comment>(); } else { Post = await _postMinion.GetAsync((int)ID) ?? new Post(); } } catch (Exception e) { ViewData["ErrorMessage"] = e.Message; Post = new Post(); } }
/// <inheritdoc/> public async Task UpdateAsync() { _logger.LogInformation(SyncMessage.CommentUpdateStart); var commentsCloud = await _cloudManager.GetComments().ToListAsync(); var commentsApp = (await _commentManager.GetAllAsync()).ToList(); foreach (var commentApp in commentsApp) { var commentCloud = commentsCloud.FirstOrDefault(c => c.Id == commentApp.CloudId); var postApp = await _postManager.GetAsync(commentApp.PostId); var isUpdated = false; if (postApp.CloudId != commentCloud.PostId) { var postId = (await _postManager.GetByCloudIdAsync(commentCloud.Id)).Id; commentApp.PostId = postId; isUpdated = true; } if (commentApp.Name != commentCloud.Name) { commentApp.Name = commentCloud.Name; isUpdated = true; } if (commentApp.Email != commentCloud.Email) { commentApp.Email = commentCloud.Email; isUpdated = true; } if (commentApp.Body != commentCloud.Body) { commentApp.Body = commentCloud.Body; isUpdated = true; } if (isUpdated) { await _commentManager.UpdateAsync(commentApp); } } _logger.LogInformation(SyncMessage.CommentUpdateEnd); }
public async Task <PostDto> GetAsync(Guid id) { var post = await _postManager.GetAsync(id); return(ObjectMapper.Map <PostDto>(post)); }