//Upvote/Downvote a response public void UpvoteResponse(int responseId) { var upvotedResponse = FindResponseId(responseId); upvotedResponse.Votes++; _context.Responses.Update(upvotedResponse); _context.SaveChanges(); }
//Add a comment public Comment AddComment(int responseId, string text, string username) { var addedComment = new Comment() { Text = text, ResponseId = responseId, CommentedBy = username, CommentedAt = DateTimeOffset.Now, Votes = 1, Inappropriate = false }; _context.Comments.Add(addedComment); _context.SaveChanges(); return(addedComment); }
public Question AddQuestion(string text, Topic topic, string userName) { var questionToAdd = new Question { Text = text, AskedBy = userName, AskedAt = DateTimeOffset.Now, ResponseSolutionId = 0, Votes = 1, Topic = topic, Inappropriate = false }; _context.Questions.Add(questionToAdd); _context.SaveChanges(); return(questionToAdd); }