using Dapper; using DealerSelection.Api.Infrastructure.Mulesoft; using DealerSelection.Api.Models; using DealerSelection.Common.Data.Dapper; using Microsoft.Extensions.Logging; using System.Data; using System.Data.SqlClient; namespace DealerSelection.Api.Infrastructure.BatchJob; public class Repository : RepositoryBaseDapperAsync, IRepository { private readonly ILogger _logger; public Repository(string cxnName, ILogger logger) : base(cxnName) { _logger = logger; } public async Task> Get24HrOldRecordsForJobProcessing() { try { using (SqlConnection cxn = await OpenCxnAsync()) { IEnumerable cusotmerInfo = await cxn.QueryAsync(Procedure.Get24HrOldRecordsForJobProcessing, commandType: CommandType.StoredProcedure); return cusotmerInfo.ToList(); } } catch (Exception ex) { _logger.LogError($"DS Repo:-Error at Repository:BatchJob in Get24HrOldRecordsForJobProcessing.", ex.StackTrace); throw new UnexpectedDataException("Error at Repository:BatchJob in Get24HrOldRecordsForJobProcessing.", ex); } } public async Task> GetDataForLsqPush(int buId) { try { using (SqlConnection cxn = await OpenCxnAsync()) { IEnumerable lsqDto = await cxn.QueryAsync(Procedure.GetDataForLsqPush, new { buId }, commandType: CommandType.StoredProcedure); return lsqDto.ToList(); } } catch (Exception ex) { _logger.LogError("BU:- " + buId.ToString() + "Error at Repository:Mulesoft in GetDataForLsqPush " + ex.Message.ToString()); throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetDataForLsqPush for BuId: {buId}.", ex); } } }