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.
45 lines
1.8 KiB
45 lines
1.8 KiB
using DealerSelection.Api.Models;
|
|
using DealerSelection.Common.Data.Dapper;
|
|
using Dapper;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
namespace DealerSelection.Api.Infrastructure.InfoBip;
|
|
|
|
public class Repository : RepositoryBaseDapperAsync, IRepository
|
|
{
|
|
private readonly ILogger _logger;
|
|
public Repository(string cxnName, ILogger<Repository> logger) : base(cxnName)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task SaveResponse(int buId, string strMobile, string request_name, string api_request, string api_response, string error_message)
|
|
{
|
|
try
|
|
{
|
|
using (SqlConnection cxn = await OpenCxnAsync())
|
|
{
|
|
await cxn.ExecuteScalarAsync(@"insert into tbl_infobip_api_response(request_name,api_request,api_response,error_message)
|
|
values(@request_name,@api_request,@api_response,@error_message)",
|
|
new
|
|
{
|
|
request_name,
|
|
api_request,
|
|
api_response,
|
|
error_message
|
|
},
|
|
commandType: CommandType.Text);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError("BU:- " + buId.ToString() + $"Error at Repository:InfoBip in SaveResponse for BuId: {buId}, Mobile: {strMobile}," +
|
|
$"request_name: {request_name}, api_request: {api_request}, api_response: {api_response}, error_message: {error_message}." + ex.Message.ToString());
|
|
throw new UnexpectedDataException($"Error at Repository:InfoBip in SaveResponse for BuId: {buId}, Mobile: {strMobile}," +
|
|
$"request_name: {request_name}, api_request: {api_request}, api_response: {api_response}, error_message: {error_message}.", ex);
|
|
}
|
|
}
|
|
}
|