Complaints working, web comments response page, filtering for announcements

This commit is contained in:
Dimitar Byalkov
2023-06-09 04:57:28 +02:00
parent d8e185757d
commit d81450ed21
20 changed files with 336 additions and 48 deletions

View File

@@ -210,7 +210,19 @@ public class CommentRepository : ICommentRepository
public void CreateCommentOnComplaint(User author, string description, string title, DateTime publishDate, int complaintId)
{
Comment comment = CreateComment(author, description, title, publishDate);
using (SqlConnection connection = SqlConnectionHelper.CreateConnection())
{
string sql = "INSERT INTO ComplaintsComments (ComplaintID, CommentID) VALUES (@complaintID, @commentID);";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.Parameters.AddWithValue("@complaintID", complaintId);
cmd.Parameters.AddWithValue("@commentID", comment.ID);
int writer = cmd.ExecuteNonQuery();
if (writer != 1)
{
throw new DatabaseOperationException("Database error: Complaint comment not created");
}
}
}
public List<Comment> GetAllCommentsOnComplaint(int complaintId)