public async Task <GetPostResponse> GetPostAsync(GetPostRequest request) { var response = new GetPostResponse(); var entity = await _postRepository.GetPostByUrlAsync(request.Url); if (entity == null) { response.StatusCode = (int)HttpStatusCode.NotFound; return(response); } response.Post = _postMapper.ToModel(entity); return(response); }
public async Task <GetPostResponse> GetPostFromIdAsync(int postId, string requesterId = null) { var entity = await _postRepository.GetPostFromIdAsync(postId); var response = new GetPostResponse(); if (entity == null) { _logger.LogWarning($"Post with Id {postId} not found"); response.StatusCode = (int)HttpStatusCode.NotFound; return(response); } var postModel = _postMapper.ToModel(entity, requesterId); response.StatusCode = (int)HttpStatusCode.OK; response.Post = postModel; return(response); }