Exemple #1
0
 public void DeleteComm(int commId)
 {
     using (var context = new PostgressContext())
     {
         Comments comment = context.Comments.Where(x => x.Id == commId).FirstOrDefault();
         context.Comments.Remove(comment);
         context.SaveChanges();
     }
 }
Exemple #2
0
 public void PatchComm(int commId, Comment comment)
 {
     using (var context = new PostgressContext())
     {
         Comments _comment = context.Comments.Where(x => x.Id == commId).FirstOrDefault();
         _comment.Body   = comment.Body;
         _comment.PostId = comment.Postid;
         _comment.Title  = comment.Title;
         _comment.UserId = comment.Userid;
         context.SaveChanges();
     }
 }
Exemple #3
0
 public void PutRating(Models.Front.Rating rating)
 {
     using (var context = new PostgressContext())
     {
         context.Ratings.Add(new Ratings
         {
             RatingValue = rating.RatingValue,
             Date        = DateTime.Now,
             UserId      = rating.UserId,
             PostId      = rating.PostId
         }
                             );
         context.SaveChanges();
     }
 }
Exemple #4
0
        public void PutComm(Comment comment)
        {
            using (var context = new PostgressContext())
            {
                context.Comments.Add(new Comments
                {
                    Body   = comment.Body,
                    Title  = comment.Title,
                    UserId = comment.Userid,
                    PostId = comment.Postid
                }
                                     );

                context.SaveChanges();
            }
        }
Exemple #5
0
        public void CreatePost(Post post)
        {
            using (var context = new PostgressContext())
            {
                context.Posts.Add(new Postss()
                {
                    Title       = post.Title,
                    Body        = post.Body,
                    Description = post.Description,
                    CategoryId  = post.CategoryId,
                    Date        = DateTime.Now,
                    UserId      = post.UserId
                }
                                  );

                context.SaveChanges();
            }
        }