using ECPDAL.Communication.DTOs; using ECPDAL.Communication.Interfaces; using ECPDAL.Communication.QueryBuilders; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; namespace ECPDAL.Communication.Implementations; public class CommentReactionDAL(IQueryExecutor _qe) : ICommentReactionDAL { public async Task> GetReactionsForThreadAsync( int commentThreadId, LoginDTO login, CancellationToken ct) { var rows = await _qe.QueryAsync( login, CommentReactionQB.GET_REACTIONS_FOR_THREAD, new { CommentThreadId = commentThreadId, login.DatabaseName }, cancellationToken: ct).ConfigureAwait(false); return rows.ToList(); } public async Task GetUserReactionAsync( int commentThreadId, int userId, byte reactionType, LoginDTO login, CancellationToken ct) { var rows = await _qe.QueryAsync( login, CommentReactionQB.GET_USER_REACTION, new { CommentThreadId = commentThreadId, UserId = userId, ReactionType = reactionType, login.DatabaseName }, cancellationToken: ct).ConfigureAwait(false); return rows.FirstOrDefault(); } public async Task SaveCommentReactionAsync( CommentReactionDTO dto, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteAsync( login, CommentReactionQB.SAVE_COMMENT_REACTION, dto, cancellationToken: ct).ConfigureAwait(false); } public async Task DeleteCommentReactionAsync( int commentThreadId, int userId, byte reactionType, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteAsync( login, CommentReactionQB.DELETE_COMMENT_REACTION, new { CommentThreadId = commentThreadId, UserId = userId, ReactionType = reactionType, login.DatabaseName, }, cancellationToken: ct).ConfigureAwait(false); } }