Example #1
0
 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));
     }
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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));
     }
 }
Example #4
0
 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));
     }
 }
Example #5
0
 public System.Threading.Tasks.Task <PostComment.Post> UpdatePostAsync(PostComment.Post post)
 {
     return(base.Channel.UpdatePostAsync(post));
 }
Example #6
0
 public PostComment.Post UpdatePost(PostComment.Post post)
 {
     return(base.Channel.UpdatePost(post));
 }
Example #7
0
 public System.Threading.Tasks.Task <bool> AddPostAsync(PostComment.Post post)
 {
     return(base.Channel.AddPostAsync(post));
 }
Example #8
0
 public bool AddPost(PostComment.Post post)
 {
     return(base.Channel.AddPost(post));
 }