示例#1
0
 public Task <List <Post> > GetPosts(ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         return(Task.FromResult(ctx.Posts.ToList()));
     }
 }
示例#2
0
 public Task <Comment> GetCommentById(int id, ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         return(Task.FromResult(ctx.Comments.Find(id)));
     }
 }
示例#3
0
 public Task AddComment(Comment comment, ServerCallContext context)
 {
     using (var context = new PostCommentEntities())
     {
         context.Comments.Add(comment);
         return(Task.CompletedTask);
     }
 }
示例#4
0
 public Task DeletePost(Post post, ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         ctx.Posts.Remove(post);
         return(Task.CompletedTask);
     }
 }
示例#5
0
 public override Task AddPost(Post post, ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         ctx.Posts.Add(post);
         return(Task(new Empty()));
     }
 }
示例#6
0
 public Task <Comment> UpdateComment(Comment comment, ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         ctx.ChangeTracker.DetectChanges();
         var commentToUpdate = ctx.Comments.Find(comment);
         commentToUpdate = comment;
         return(Task.FromResult(commentToUpdate));
     }
 }
示例#7
0
 public override Task <Post> UpdatePost(Post post, ServerCallContext context)
 {
     using (var ctx = new PostCommentEntities())
     {
         ctx.ChangeTracker.DetectChanges();
         var postToUpdate = ctx.Posts.Find(post);
         postToUpdate = post;
         return(Task.FromResult(postToUpdate));
     }
 }