Пример #1
0
 public Types.Comment updateComment(Types.Comment c)
 {
     using (var ctx = new Models.Model())
     {
         Models.Comment c1 = ctx.comments.FirstOrDefault(x => x.commentId == c.commentId);
         c1.time        = c.time;
         c1.description = c.description;
         c1.upvotes     = c.upvotes;
         ctx.SaveChanges();
         return(c);
     }
 }
Пример #2
0
 public int addComment(Types.Comment c)
 {
     using (var ctx = new Models.Model())
     {
         Models.Comment c1 = new Models.Comment();
         c1.time        = c.time;
         c1.description = c.description;
         c1.upvotes     = c.upvotes;
         if (c.replyOfComment != -1)
         {
             c1.replyOfComment = ctx.comments.FirstOrDefault(x => x.commentId == c.replyOfComment);
         }
         Models.User u = ctx.users.FirstOrDefault(x => x.userId == c.user.userId);
         c1.user = u;
         Models.Post p = ctx.posts.FirstOrDefault(x => x.postId == c.post.postId);
         c1.post = p;
         ctx.comments.Add(c1);
         ctx.SaveChanges();
         return(c1.commentId);
     }
 }