public override Task <GetPostsResponse> GetPosts(GetPostsRequest request, ServerCallContext context) { try { var post = new PostComment.Post(); var returnValue = post.GetAllPosts(); var response = new GetPostsResponse(); response.Values.AddRange(returnValue.Select(x => (Post)x)); return(Task.FromResult(response)); } catch (Exception ex) { _logger.LogError(ex, "Error invoking GetPosts"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } }
public PostComment.Post UpdatePost(PostComment.Post newPost) { using (ModelPostEntities ctx = new ModelPostEntities()) { PostComment.Post oldPost = ctx.Posts.Find(newPost.PostId); if (oldPost == null) { return(null); } oldPost.Description = newPost.Description; oldPost.Domain = newPost.Domain; oldPost.Date = newPost.Date; ctx.SaveChanges(); return(oldPost); } }
public override Task <UpdatePostResponse> UpdatePost(UpdatePostRequest request, ServerCallContext context) { try { var post = new PostComment.Post(); var returnValue = post.UpdatePost((global::PostComment.Post)request.Post); var response = new UpdatePostResponse { Value = (Post)returnValue }; return(Task.FromResult(response)); } catch (Exception ex) { _logger.LogError(ex, "Error invoking UpdatePost"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } }
public override Task <GetPostByIdResponse> GetPostById(GetPostByIdRequest request, ServerCallContext context) { try { var post = new PostComment.Post(); var returnValue = post.GetPostById(request.Id); var response = new GetPostByIdResponse { Value = (Post)returnValue }; return(Task.FromResult(response)); } catch (Exception ex) { _logger.LogError(ex, "Error invoking GetPostById"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } }
public System.Threading.Tasks.Task <PostComment.Post> UpdatePostAsync(PostComment.Post post) { return(base.Channel.UpdatePostAsync(post)); }
public PostComment.Post UpdatePost(PostComment.Post post) { return(base.Channel.UpdatePost(post)); }
public System.Threading.Tasks.Task <bool> AddPostAsync(PostComment.Post post) { return(base.Channel.AddPostAsync(post)); }
public bool AddPost(PostComment.Post post) { return(base.Channel.AddPost(post)); }