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(); } }
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(); } }
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(); } }
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(); } }
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(); } }