using FrameworkDAL.Query.CommentHistory; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using FrameworkDAL.DTO.CommentHistory; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace FrameworkDAL.CustomCode.CommentHistory { public class CommentHistoryDAL : ICommentHistoryDAL { private readonly IQueryExecutor _QueryExecutor; public CommentHistoryDAL(IQueryExecutor QueryExecutor) { _QueryExecutor = QueryExecutor; } public async Task GetCommentHistoryAsync(int objectId, int objectTypeId, LoginDTO loginDTO) { try { string sql = CommentHistoryQB.GET_COMMENTHISTORY; var parameters = new { ObjectId = objectId, ObjectTypeId = objectTypeId }; List CommentHistoryDTOs = (await _QueryExecutor.QueryAsync(loginDTO,sql,parameters)).ToList(); string json = JsonConvert.SerializeObject(CommentHistoryDTOs); return json; } catch (Exception ex) { throw new Exception($"Failed to retrieve Comment History data: {ex.Message}", ex); } } } }