Complaints working, web comments response page, filtering for announcements
This commit is contained in:
@@ -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)
|
||||
|
@@ -68,10 +68,13 @@ namespace Data
|
||||
List<Complaint> complaints = new List<Complaint>();
|
||||
UserRepository userRepository = new UserRepository();
|
||||
User user = userRepository.GetUserById(userId);
|
||||
string sql = "SELECT * FROM Complaints ORDER BY ID DESC OFFSET @start ROWS FETCH NEXT @count ROWS ONLY;";
|
||||
// Status 3 is Archived status
|
||||
// no need to list archived complaints for now
|
||||
// future revision: add an option to see archived complaints?
|
||||
string sql = "SELECT * FROM Complaints WHERE Status != 3 ORDER BY ID DESC OFFSET @start ROWS FETCH NEXT @count ROWS ONLY;";
|
||||
if (user.Role == UserRole.TENANT)
|
||||
{
|
||||
sql = $"SELECT * FROM Complaints WHERE Author = {userId} ORDER BY ID DESC OFFSET @start ROWS FETCH NEXT @count ROWS ONLY;";
|
||||
sql = $"SELECT * FROM Complaints WHERE Author = {userId} AND Status != 3 ORDER BY ID DESC OFFSET @start ROWS FETCH NEXT @count ROWS ONLY;";
|
||||
}
|
||||
if (c == null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user