You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.6 KiB
74 lines
2.6 KiB
using DealerSelection.Api.Models;
|
|
using DealerSelection.Common.Data.Dapper;
|
|
using Dapper;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Microsoft.Extensions.Logging;
|
|
using DealerSelection.Api.Infrastructure.CCAvenue;
|
|
using DealerSelection.Api.Models.Enum;
|
|
|
|
namespace DealerSelection.Api.Infrastructure.CCAvenue;
|
|
|
|
public class Repository : RepositoryBaseDapperAsync, IRepository
|
|
{
|
|
private readonly ILogger _logger;
|
|
public Repository(string cxnName, ILogger<Repository> logger) : base(cxnName)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task<Dto> GetBookingDetail(string bookingId,string transactionId)
|
|
{
|
|
try
|
|
{
|
|
using (SqlConnection cxn = await OpenCxnAsync())
|
|
{
|
|
IEnumerable<Dto> cusotmerInfo = await cxn.QueryAsync<Dto>(Procedure.GetBokingDetailOnBookingId,
|
|
new
|
|
{
|
|
bookingId,
|
|
transactionId
|
|
},
|
|
commandType: CommandType.StoredProcedure);
|
|
return cusotmerInfo.ToList().FirstOrDefault();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError($"DS Repo:-BookingId:- " + bookingId.ToString() + " Error at Repository:CCAvenueRefund in GetPendingOrderStatusList " + ex.Message.ToString());
|
|
throw new UnexpectedDataException($"Error at Repository:PendingStatusUpdate in CCAvenueRefund for BookingId: {bookingId}.", ex);
|
|
}
|
|
|
|
}
|
|
|
|
public async Task UpdateRefundStatus(int BuId,string bookingId, string transactionId, string refundReferenceNo, RefundStatusResponse request)
|
|
{
|
|
string failreason = request.error_code + ' ' + request.reason;
|
|
try
|
|
{
|
|
using (SqlConnection cxn = await OpenCxnAsync())
|
|
{
|
|
await cxn.QueryAsync(Procedure.UpdateRefundStatus,
|
|
new
|
|
{
|
|
BuId,
|
|
bookingId,
|
|
CCTransactionId=transactionId,
|
|
RefundReferenceNo=refundReferenceNo,
|
|
CCTransactionStatus = request.refund_status == 0 ? CCAvenueTransactionStatus.Refunded.ToString() : CCAvenueTransactionStatus.RefundFailed.ToString(),
|
|
CCTransactionStatusReason = failreason
|
|
},
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError($"DS Repo:-BookingId:-{bookingId}, TransactionId: {transactionId} Error at Repository:CCAvenue in UpdateRefundStatus" + ex.StackTrace);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|