Compare commits

...

11 Commits

  1. BIN
      DB/#28058-inbound-CodeTable/proc_InboundApi_StaticData.sql
  2. BIN
      DB/#34488-inbound-api-service-charge/PROC_REMIT_INBOUND_TRANSACTION_SEND.sql
  3. 9
      DB/29883-inbound-api-log/AlterTable.sql
  4. 132
      DB/29883-inbound-api-log/proc_inboundApiLogs.sql
  5. BIN
      DB/SP's/PROC_REMIT_INBOUND_EXRATE.sql
  6. 2
      RemitInboundAPI/RemitInboundAPI.Business/Business/RemitBusiness/IRemitBusiness.cs
  7. 56
      RemitInboundAPI/RemitInboundAPI.Business/Business/RemitBusiness/RemitBusiness.cs
  8. 29
      RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/BankValidationHelper.cs
  9. 8
      RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/SendTransactionValidationHelper.cs
  10. 30
      RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/StaticValueValidationHelper.cs
  11. 2
      RemitInboundAPI/RemitInboundAPI.Business/obj/Debug/net8.0/RemitInboundAPI.Business.AssemblyInfo.cs
  12. 160
      RemitInboundAPI/RemitInboundAPI.Common/Model/RemitModel/ExRateModel.cs
  13. 2
      RemitInboundAPI/RemitInboundAPI.Common/obj/Debug/net8.0/RemitInboundAPI.Common.AssemblyInfo.cs
  14. 24
      RemitInboundAPI/RemitInboundAPI.Repository/Enums.cs
  15. 2
      RemitInboundAPI/RemitInboundAPI.Repository/Repository/RemitRepository/IRemitRepository.cs
  16. 172
      RemitInboundAPI/RemitInboundAPI.Repository/Repository/RemitRepository/RemitRepository.cs
  17. 2
      RemitInboundAPI/RemitInboundAPI.Repository/obj/Debug/net8.0/RemitInboundAPI.Repository.AssemblyInfo.cs
  18. 50
      RemitInboundAPI/RemitInboundAPI/Controllers/RemitController.cs
  19. 18
      RemitInboundAPI/RemitInboundAPI/Program.cs
  20. 95
      RemitInboundAPI/RemitInboundAPI/ValidateModelFilter.cs
  21. 2
      RemitInboundAPI/RemitInboundAPI/obj/Debug/net8.0/RemitInboundAPI.AssemblyInfo.cs
  22. 17
      RemitInboundAPI/RemitInboundAPI/obj/Debug/net8.0/RemitInboundAPI.MvcApplicationPartsAssemblyInfo.cs

BIN
DB/#28058-inbound-CodeTable/proc_InboundApi_StaticData.sql

BIN
DB/#34488-inbound-api-service-charge/PROC_REMIT_INBOUND_TRANSACTION_SEND.sql

9
DB/29883-inbound-api-log/AlterTable.sql

@ -0,0 +1,9 @@
use fastmoneypro_remit
alter table TBL_REMIT_INBOUND_LOG
add
ControlNo VARCHAR(50) NULL,
PartnerId VARCHAR(50) NULL

132
DB/29883-inbound-api-log/proc_inboundApiLogs.sql

@ -0,0 +1,132 @@
ALTER PROCEDURE [dbo].[proc_inboundApiLogs](
@flag VARCHAR(10) = NULL
,@user VARCHAR(30) = NULL
,@REQUESTEDBY VARCHAR(100) = NULL
,@rowId INT = NULL
,@pageSize INT = NULL
,@pageNumber INT = NULL
,@sortBy VARCHAR(50) = NULL
,@sortOrder VARCHAR(50) = NULL
,@agentId varchar(10) = NULL
,@logType VARCHAR(20) = NULL
,@date VARCHAR(10) = NULL
,@logby VARCHAR(50) = NULL
,@controlno VARCHAR(30) = NULL
,@processid VARCHAR(100) = NULL
)AS
SET NOCOUNT ON
SET XACT_ABORT ON
BEGIN
DECLARE
@table VARCHAR(MAX)
,@select_field_list VARCHAR(MAX)
,@extra_field_list VARCHAR(MAX)
,@sql_filter VARCHAR(MAX)
if @flag = 'method'
BEGIN
SELECT *
FROM (
SELECT '' [value]
,'Select Log Type' [text]
UNION ALL
SELECT 'sendRemittance' [value]
,'Send Transaction' [text]
UNION ALL
SELECT 'calculateExRate' [value]
,'Exchange Rate' [text]
UNION ALL
SELECT 'getCode' [value]
,'Static Value' [text]
) x
END
else IF @flag='s'
BEGIN
SET @sortBy='rowId'
SET @sortOrder='DESC'
SET @table='
(
SELECT rowId
,ProcessIdentifier
,RequestedDate
,MethodName
,RequestJson
,ResponseJson
,RequestedBy
,controlno
FROM TBL_REMIT_INBOUND_LOG (NOLOCK)
WHERE 1=1
)x'
SET @sql_filter = ''
IF @agentId IS NOT NULL
SET @sql_filter=@sql_filter + ' AND MethodName = ''' +@agentId+''''
IF @logby IS NOT NULL
SET @sql_filter=@sql_filter + ' AND RequestedBy = ''' +@logby+''''
IF @date IS NOT NULL
SET @sql_filter=@sql_filter + ' AND CONVERT(varchar(10),RequestedDate,121) = ''' +@date+''''
IF @logType IS NOT NULL
BEGIN
if(@logType='sendTxn')
SET @sql_filter=@sql_filter + ' AND right(processId,7) = '''+@logType+''''
END
IF @controlno IS NOT NULL
SET @sql_filter=@sql_filter + ' AND controlno = ''' +@controlno+''''
IF @processid IS NOT NULL
SET @sql_filter=@sql_filter + ' AND ProcessIdentifier = ''' +@processid+''''
SET @select_field_list = '
rowId
,ProcessIdentifier
,RequestedDate
,MethodName
,RequestJson
,ResponseJson
,RequestedBy
,controlno
'
EXEC dbo.proc_paging
@table
,@sql_filter
,@select_field_list
,@extra_field_list
,@sortBy
,@sortOrder
,@pageSize
,@pageNumber
END
IF @flag='a'
BEGIN
SELECT rowId
,ProcessIdentifier providerName
,MethodName methodName
,controlNo
,[RequestJson] requestXml
,'' requestXml
,[ResponseJson] responseXml
,'' responseXml
,RequestedBy requestedBy
,[RequestedDate] requestedDate
,'' responseDate
FROM TBL_REMIT_INBOUND_LOG (NOLOCK)
WHERE rowId=@rowId
END
END

BIN
DB/SP's/PROC_REMIT_INBOUND_EXRATE.sql

2
RemitInboundAPI/RemitInboundAPI.Business/Business/RemitBusiness/IRemitBusiness.cs

@ -7,7 +7,9 @@ namespace RemitInboundAPI.Business.Business.RemitBusiness
public interface IRemitBusiness
{
Task<ApiResponse> CalculateExRate(ExRateModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetBank(BankResponseModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetRemittanceStatus(RemittanceStatusModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetStatic(CDDIResponseModel model, UserLoginModel loginDetails);
Task<ApiResponse> SendRemittance(SendRemittanceModel model, UserLoginModel loginDetails);
}
}

56
RemitInboundAPI/RemitInboundAPI.Business/Business/RemitBusiness/RemitBusiness.cs

@ -112,5 +112,61 @@ namespace RemitInboundAPI.Business.Business.RemitBusiness
return _response;
}
public async Task<ApiResponse> GetStatic(CDDIResponseModel model, UserLoginModel loginDetails)
{
ApiResponse _response;
//StaticValueValidationHelper validationHelper = new StaticValueValidationHelper();
var _logRequestModel = new InboundLogModel(model.SessionIdentifier, model.ProcessIdentifier, loginDetails.UserName, "GetCode", model.IpAddress, model.PartnerSessionId, JsonConvert.SerializeObject(model));
var _logResponse = await _applicationRepo.LogInboundData(_logRequestModel);
if (_logResponse.ResponseCode == ResponseHelper.SUCCESS)
{
_response = await _remitRepo.GetStatic(model, loginDetails);
_applicationRepo.LogUpdateInboundData(_response, _logResponse.Id);
}
else
{
_response = new ApiResponse(ResponseHelper.FAILED, _logResponse.ResponseMessage);
_logger.LogError("REMITBUSINESS | GETCODE | LOGGING ERROR | " + JsonConvert.SerializeObject(_response));
}
return _response;
}
public async Task<ApiResponse> GetBank(BankResponseModel model, UserLoginModel loginDetails)
{
ApiResponse _response;
BankValidationHelper validationHelper = new BankValidationHelper();
var _logRequestModel = new InboundLogModel(model.SessionIdentifier, model.ProcessIdentifier, loginDetails.UserName, "GetBank", model.IpAddress, model.PartnerSessionId, JsonConvert.SerializeObject(model));
var _logResponse = await _applicationRepo.LogInboundData(_logRequestModel);
if (_logResponse.ResponseCode == ResponseHelper.SUCCESS)
{
// _response = await _remitRepo.GetBank(model, loginDetails);
_response = await validationHelper.BankValidationRequest(model);
if (_response.ResponseCode == ResponseHelper.SUCCESS)
{
_response = await _remitRepo.GetBank(model, loginDetails);
}
else
{
_logger.LogError("REMITBUSINESS | GETREMITTANCESTATUS | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response));
}
_applicationRepo.LogUpdateInboundData(_response, _logResponse.Id);
}
else
{
_response = new ApiResponse(ResponseHelper.FAILED, _logResponse.ResponseMessage);
_logger.LogError("REMITBUSINESS | GETBANK | LOGGING ERROR | " + JsonConvert.SerializeObject(_response));
}
return _response;
}
}
}

29
RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/BankValidationHelper.cs

@ -0,0 +1,29 @@
using RemitInboundAPI.Common.Helper;
using RemitInboundAPI.Common.Model.RemitModel;
using RemitInboundAPI.Common.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RemitInboundAPI.Business.Helper.ValidationHelper
{
public class BankValidationHelper
{
public async Task<ApiResponse> BankValidationRequest(BankResponseModel model)
{
ApiResponse _response;
if (string.IsNullOrEmpty(model.CountryId))
{
_response = new ApiResponse(ResponseHelper.FAILED, "Country can not be empty.");
}
else
{
_response = new ApiResponse(ResponseHelper.SUCCESS, ResponseMessageHelper.SUCCESS);
}
return _response;
}
}
}

8
RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/SendTransactionValidationHelper.cs

@ -45,10 +45,10 @@ namespace RemitInboundAPI.Business.Helper.ValidationHelper
{
_response = new ApiResponse(ResponseHelper.FAILED, "PayoutAmount can not be empty.");
}
else if (string.IsNullOrEmpty(model.RemittanceDetails.ServiceCharge))
{
_response = new ApiResponse(ResponseHelper.FAILED, "ServiceCharge can not be empty.");
}
//else if (string.IsNullOrEmpty(model.RemittanceDetails.ServiceCharge))
//{
// _response = new ApiResponse(ResponseHelper.FAILED, "ServiceCharge can not be empty.");
//}
else if (string.IsNullOrEmpty(model.RemittanceDetails.ExchangeRate))
{
_response = new ApiResponse(ResponseHelper.FAILED, "ExchangeRate can not be empty.");

30
RemitInboundAPI/RemitInboundAPI.Business/Helper/ValidationHelper/StaticValueValidationHelper.cs

@ -0,0 +1,30 @@
using RemitInboundAPI.Common.Helper;
using RemitInboundAPI.Common.Model.RemitModel;
using RemitInboundAPI.Common.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RemitInboundAPI.Business.Helper.ValidationHelper
{
public class StaticValueValidationHelper
{
//public async Task<ApiResponse> ValidateExraStaticRequest(CDDIResponseModel model)
//{
// ApiResponse _response;
// if (string.IsNullOrEmpty(model.SourceOfFund.ToArray))
// {
// _response = new ApiResponse(ResponseHelper.FAILED, "StaticValue can not be empty.");
// }
// else
// {
// _response = new ApiResponse(ResponseHelper.SUCCESS, ResponseMessageHelper.SUCCESS);
// }
// return _response;
//}
}
}

2
RemitInboundAPI/RemitInboundAPI.Business/obj/Debug/net8.0/RemitInboundAPI.Business.AssemblyInfo.cs

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("RemitInboundAPI.Business")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f21fe7c001e9f33c469aaf22f43a6a56b1d6ccf")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e12781bcaa0a9d70ca8c616d2fe43dd9c6d43818")]
[assembly: System.Reflection.AssemblyProductAttribute("RemitInboundAPI.Business")]
[assembly: System.Reflection.AssemblyTitleAttribute("RemitInboundAPI.Business")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

160
RemitInboundAPI/RemitInboundAPI.Common/Model/RemitModel/ExRateModel.cs

@ -1,19 +1,125 @@
using RemitInboundAPI.Common.Model.ApplicationModel;
using System.ComponentModel.DataAnnotations;
namespace RemitInboundAPI.Common.Model.RemitModel
{
public class ExRateModel : CommonRequestModel
{
[Required]
[StringLength(4, MinimumLength = 2)]
public string? SendingCountryCode { get; set; }
[Required]
[StringLength(10, MinimumLength = 3)]
public string? SendingCurrencyCode { get; set; }
[Required]
[StringLength(4, MinimumLength = 2)]
public string? PayoutCountryCode { get; set; }
[Required]
[StringLength(10, MinimumLength = 3)]
public string? PayoutCurrencyCode { get; set; }
[Required]
public string? CollectionAmount { get; set; }
[Required]
public string? PayoutAmount { get; set; }
[Required]
public string? PayoutTypeCode { get; set; }
public string? CalcBy { get; set; }
}
public class StaticCodeModel: CommonRequestModel
{
public string? Type { get; set; }
}
public class CDDIResponseModel : CommonRequestModel
{
//public string UserId { get; set; }
//public int Type { get; set; }
public List<SourceOfFund>? SourceOfFund { get; set; }
public List<PurposeOfRemittance>? PurposeOfRemittance { get; set; }
public List<IdType>? IdType { get; set; }
public List<Relationship>? Relationship { get; set; }
public List<Occupation>? Occupation { get; set; }
public List<Country>? Country { get; set; }
public List<PaymentType>? PaymentType { get; set; }
}
public class PaymentType
{
public string? id { get; set; }
public string? text { get; set; }
public string? code { get; set; }
}
public class Country
{
public string? id { get; set; }
public string? text { get; set; }
public string? countryCode { get; set; }
public string? IsoApha3 { get; set; }
}
public class Occupation
{
public string? id { get; set; }
public string? text { get; set; }
}
public class PurposeOfRemittance
{
public string ? id { get; set; }
public string? text { get; set; }
}
public class Relationship
{
public string? id { get; set; }
public string? text { get; set; }
//public bool isBackRequired { get; set; }
}
public class IdType
{
public string? id { get; set; }
public string? text { get; set; }
//public bool isBackRequired { get; set; }
}
public class SourceOfFund
{
public string? id { get; set; }
public string? text { get; set; }
}
public class BankResponseModel : CommonRequestModel
{
[Required]
[StringLength(4)]
public string? CountryId { get; set; }
public List<Bank>? Bank { get; set; }
}
public class Bank
{
public string? id { get; set; }
public string? text { get; set; }
public string? code { get; set; }
}
public class RemittanceStatusModel : CommonRequestModel
{
public string? IMEControlNo { get; set; }
@ -30,55 +136,107 @@ namespace RemitInboundAPI.Common.Model.RemitModel
public class RemittanceDetailsModel
{
[Required]
[StringLength(3)]
public string? SendingCountryCode { get; set; }
[Required]
[StringLength(3)]
public string? PayoutCountryCode { get; set; }
[Required]
[StringLength(2)]
public string? PayoutTypeCode { get; set; }
public string? PayoutBankCode { get; set; }
public string? PayoutBankBranchCode { get; set; }
[Required]
public string? PayoutCurrencyCode { get; set; }
[Required]
public string? SendingCurrencyCode { get; set; }
[Required]
public string? CollectionAmount { get; set; }
[Required]
public string? TransferAmount { get; set; }
public string? PayoutAmount { get; set; }
public string? ServiceCharge { get; set; }
[Required]
public string? ExchangeRate { get; set; }
[Required]
public string? RemittancePurpose { get; set; }
[Required]
public string? SourceOfFund { get; set; }
[Required]
public string? Relationship { get; set; }
[Required]
public string? Occupation { get; set; }
[Required]
[StringLength(1)]
public string? CalcBy { get; set; }
}
public class RemitSenderDetailsModel
{
[Required]
[StringLength(20)]
public string? SenderFirstName { get; set; }
[StringLength(20)]
public string? SenderMiddleName { get; set; }
[Required]
[StringLength(20)]
public string? SenderLastName { get; set; }
[Required]
[StringLength(10)]
public string? SenderDOB { get; set; }
[Required]
[StringLength(15)]
public string? SenderIdType { get; set; }//need to provide codes to partner
[Required]
[StringLength(20)]
public string? SenderIdNo { get; set; }
[Required]
[StringLength(10)]
public string? SenderIdIssuedDate { get; set; }
[Required]
[StringLength(10)]
public string? SenderIdValidDate { get; set; }//optional
[Required]
[StringLength(15)]
public string? SenderMobile { get; set; }
[Required]
[StringLength(3)]
public string? SenderNativeCountryCode { get; set; }
[Required]
[StringLength(15)]
public string? SenderCity { get; set; }
[Required]
[StringLength(20)]
public string? SenderAddress { get; set; }
[Required]
public string? SenderEmail { get; set; }
[Required]
public string? SenderGender { get; set; }
}
public class RemitReceiverDetailsModel
{
[Required]
[StringLength(20)]
public string? ReceiverFirstName { get; set; }
[StringLength(20)]
public string? ReceiverMiddleName { get; set; }
[Required]
[StringLength(20)]
public string? ReceiverLastName { get; set; }
public string? ReceiverIdType { get; set; }//need to provide codes to partner
public string? ReceiverIdNo { get; set; }
public string? ReceiverIdIssuedDate { get; set; }
public string? ReceiverIdValidDate { get; set; }//optional
[StringLength(20)]
public string? ReceiverMobile { get; set; }
[Required]
[StringLength(15)]
public string? ReceiverCity { get; set; }
[Required]
[StringLength(50)]
public string? ReceiverAddress { get; set; }
public string? ReceiverAccountNo { get; set; }
public string? ReceiverEmail { get; set; }

2
RemitInboundAPI/RemitInboundAPI.Common/obj/Debug/net8.0/RemitInboundAPI.Common.AssemblyInfo.cs

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("RemitInboundAPI.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f21fe7c001e9f33c469aaf22f43a6a56b1d6ccf")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bcb9c8d7ef1d3e01b5136737ae5df1084da5ac03")]
[assembly: System.Reflection.AssemblyProductAttribute("RemitInboundAPI.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("RemitInboundAPI.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

24
RemitInboundAPI/RemitInboundAPI.Repository/Enums.cs

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RemitInboundAPI.Repository
{
public class Enums
{
public enum MasterData
{
All,
sourceOfFund,
purposeOfRemittance,
idType,
relationship,
occupation,
country,
paymentType
}
}
}

2
RemitInboundAPI/RemitInboundAPI.Repository/Repository/RemitRepository/IRemitRepository.cs

@ -7,7 +7,9 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
public interface IRemitRepository
{
Task<ApiResponse> CalculateExRate(ExRateModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetBank(BankResponseModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetRemittanceStatus(RemittanceStatusModel model, UserLoginModel loginDetails);
Task<ApiResponse> GetStatic(CDDIResponseModel model, UserLoginModel loginDetails);
Task<ApiResponse> SendRemittance(SendRemittanceModel model, UserLoginModel loginDetails);
}
}

172
RemitInboundAPI/RemitInboundAPI.Repository/Repository/RemitRepository/RemitRepository.cs

@ -5,6 +5,10 @@ using RemitInboundAPI.Common.Model;
using RemitInboundAPI.Repository.DBHelper;
using RemitInboundAPI.Common.Model.RemitModel;
using RemitInboundAPI.Common.Model.ApplicationModel;
using System.Data;
using System.Linq;
using static RemitInboundAPI.Repository.Enums;
using static System.Net.Mime.MediaTypeNames;
namespace RemitInboundAPI.Repository.Repository.RemitRepository
{
@ -48,7 +52,7 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
else
{
var _dbResponse = _connHelper.ParseDbResult(dt);
_response.ResponseCode = _dbResponse.ResponseCode;
_response.ResponseCode = _dbResponse.ResponseCode;
_response.ResponseMessage = _dbResponse.ResponseMessage;
if (_response.ResponseCode == ResponseHelper.SUCCESS)
@ -96,7 +100,7 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
sql += ", @CollectionAmount = " + _connHelper.FilterString(model.RemittanceDetails.CollectionAmount);
sql += ", @TransferAmount = " + _connHelper.FilterString(model.RemittanceDetails.TransferAmount);
sql += ", @PayoutAmount = " + _connHelper.FilterString(model.RemittanceDetails.PayoutAmount);
sql += ", @ServiceCharge = " + _connHelper.FilterString(model.RemittanceDetails.ServiceCharge);
//sql += ", @ServiceCharge = " + _connHelper.FilterString(model.RemittanceDetails.ServiceCharge);
sql += ", @ExchangeRate = " + _connHelper.FilterString(model.RemittanceDetails.ExchangeRate);
sql += ", @RemittancePurpose = " + _connHelper.FilterString(model.RemittanceDetails.RemittancePurpose);
sql += ", @SourceOfFund = " + _connHelper.FilterString(model.RemittanceDetails.SourceOfFund);
@ -146,6 +150,7 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
Status = Convert.ToString(_transactionResponse["TranStatus"]),
//SendingCommission = Utilities.ShowDecimal(Convert.ToString(_transactionResponse["SendingCommission"])),
//SendingCommissionCurrency = Convert.ToString(_transactionResponse["SendingCommissionCurrency"]),
ServiceCharge = Utilities.ShowDecimal(Convert.ToString(_transactionResponse["serviceCharge"])),
CollectionAmount = Utilities.ShowDecimal(Convert.ToString(_transactionResponse["CollectionAmount"])),
TransferAmount = Utilities.ShowDecimal(Convert.ToString(_transactionResponse["TransferAmount"])),
PayoutAmount = Utilities.ShowDecimal(Convert.ToString(_transactionResponse["PayoutAmount"])),
@ -173,7 +178,7 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
sql += ", @AgentId = " + _connHelper.FilterString(loginDetails.AgentId);
sql += ", @PartnerTransactionId = " + _connHelper.FilterString(model.PartnerTransactionId);
sql += ", @IMEControlNo = " + _connHelper.FilterString(model.IMEControlNo);
_logger.LogDebug("REMITREPOSITORY | GETREMITTANCESTATUS | SQL | " + sql);
var _transactionResponse = _connHelper.ParseDbResult(sql);
@ -199,5 +204,166 @@ namespace RemitInboundAPI.Repository.Repository.RemitRepository
}
return _response;
}
public async Task<ApiResponse> GetStatic(CDDIResponseModel model, UserLoginModel loginDetails)
{
var _response = new ApiResponse();
try
{
//string typeName = Enum.GetName(typeof(MasterData), model.Type);
var sql = "EXEC proc_InboundApi_StaticData @flag='cddi'";
sql += ", @UserName= " + _connHelper.FilterString(loginDetails.UserName);
//sql += ", @Type = " + _connHelper.FilterString(typeName);
_logger.LogDebug("REMITREPOSITORY | GETSTATIC | SQL | " + sql);
var dt = _connHelper.ExecuteDataset(sql);
if (dt == null || dt.Tables[0].Rows.Count <= 0)
{
_response.ResponseCode = ResponseHelper.FAILED;
_response.ResponseMessage = ResponseMessageHelper.DBNULLERROR;
_logger.LogError("REMITREPOSITORY | GETSTATIC | DBNULLERROR | " + JsonConvert.SerializeObject(_response));
}
//else if (dt.Tables.Count > 1)
else
{
var _cddi = new CDDIResponseModel();
//Source Of Fund
var Source = dt.Tables[0].AsEnumerable().Select(cc => new SourceOfFund
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text")
}).ToList();
_cddi.SourceOfFund = Source;
//Purpose Of Remittance
var Reason = dt.Tables[1].AsEnumerable().Select(cc => new PurposeOfRemittance
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text")
}).ToList();
_cddi.PurposeOfRemittance = Reason;
//Id Type
var IdType = dt.Tables[2].AsEnumerable().Select(cc => new IdType
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text")
}).ToList();
_cddi.IdType = IdType;
//Relationship
var relation = dt.Tables[3].AsEnumerable().Select(cc => new Relationship
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text")
}).ToList();
_cddi.Relationship = relation;
//Occupation
var occupation = dt.Tables[4].AsEnumerable().Select(cc => new Occupation
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text")
}).ToList();
_cddi.Occupation = occupation;
//Country
var country = dt.Tables[5].AsEnumerable().Select(cc => new Country
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text"),
countryCode = cc.Field<string>("code"),
IsoApha3 = cc.Field<string>("iso")
}).ToList();
_cddi.Country = country;
//PaymentType
var pType = dt.Tables[6].AsEnumerable().Select(cc => new PaymentType
{
id = cc.Field<int>("id").ToString(),
text = cc.Field<string>("text"),
code = cc.Field<string>("code")
}).ToList();
_cddi.PaymentType = pType;
_response.ResponseCode = 100;
_response.ResponseMessage = "API Called successfully";
_response.Data = _cddi;
}
//else
//{
// _response.ResponseCode = 101;
// _response.ResponseMessage = "Failed";
// _response.Data = null;
//}
}
catch (Exception ex)
{
_response.ResponseCode = ResponseHelper.EXCEPTION;
_response.ResponseMessage = "Exception occurred: " + ex.Message;
_logger.LogError("REMITREPOSITORY | GETSTATIC | EXCEPTION | " + JsonConvert.SerializeObject(_response));
}
return _response;
}
public async Task<ApiResponse> GetBank(BankResponseModel model, UserLoginModel loginDetails)
{
var _response = new ApiResponse();
try
{
// Construct the SQL query with parameters
string sql = "EXEC proc_InboundApi_StaticData @flag='getbank'";
sql += ", @UserName= " + _connHelper.FilterString(loginDetails.UserName);
sql += ", @country= " + _connHelper.FilterString(model.CountryId);
_logger.LogDebug("REMITREPOSITORY | GETBANK | SQL | " + sql);
var dt = _connHelper.ExecuteDataset(sql);
if (dt == null || dt.Tables[0].Rows.Count <= 0)
{
_response.ResponseCode = ResponseHelper.FAILED;
_response.ResponseMessage = ResponseMessageHelper.DBNULLERROR;
_logger.LogError("REMITREPOSITORY | GETBANK | DBNULLERROR | " + JsonConvert.SerializeObject(_response));
}
else
{
var ba = new BankResponseModel();
var bankList = dt.Tables[0].AsEnumerable().Select(row => new Bank
{
id = row.Field<Int64>("id").ToString(),
text = row.Field<string>("text"),
code = row.Field<string>("imeCode")
}).ToList();
ba.Bank = bankList;
_response.ResponseCode = 100;
_response.ResponseMessage = "API Called successfully";
_response.Data = ba;
}
}
catch (Exception ex)
{
// Exception occurred during execution
_response.ResponseCode = ResponseHelper.EXCEPTION;
_response.ResponseMessage = "Exception occurred: " + ex.Message;
_logger.LogError("REMITREPOSITORY | GETBANK | EXCEPTION | " + JsonConvert.SerializeObject(_response));
}
return _response;
}
}
}

2
RemitInboundAPI/RemitInboundAPI.Repository/obj/Debug/net8.0/RemitInboundAPI.Repository.AssemblyInfo.cs

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("RemitInboundAPI.Repository")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f21fe7c001e9f33c469aaf22f43a6a56b1d6ccf")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bcb9c8d7ef1d3e01b5136737ae5df1084da5ac03")]
[assembly: System.Reflection.AssemblyProductAttribute("RemitInboundAPI.Repository")]
[assembly: System.Reflection.AssemblyTitleAttribute("RemitInboundAPI.Repository")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

50
RemitInboundAPI/RemitInboundAPI/Controllers/RemitController.cs

@ -12,6 +12,7 @@ namespace RemitInboundAPI.Controllers
{
[ApiController]
[Route("api/v1/[controller]")]
public class RemitController : ControllerBase
{
private readonly ILogger<RemitController> _logger;
@ -26,8 +27,10 @@ namespace RemitInboundAPI.Controllers
[HttpPost]
[Route("calculateExRate")]
[Authorize(AuthenticationSchemes = "ApplicationAuthorization")]
[ServiceFilter(typeof(ValidateModelFilter))]
public async Task<IActionResult> CalculateExRate(ExRateModel model)
{
var _response = new ApiResponse();
var loginDetails = await AuthorizationHelper.GetLoginDetails(User);
model.SessionIdentifier = loginDetails.SessionIdentifier; //unique for one session
@ -47,6 +50,7 @@ namespace RemitInboundAPI.Controllers
[HttpPost]
[Route("sendRemittance")]
[ServiceFilter(typeof(ValidateModelFilter))]
[Authorize(AuthenticationSchemes = "ApplicationAuthorization")]
public async Task<IActionResult> SendRemittance(SendRemittanceModel model)
{
@ -70,6 +74,7 @@ namespace RemitInboundAPI.Controllers
[HttpPost]
[Route("getRemittanceStatus")]
[Authorize(AuthenticationSchemes = "ApplicationAuthorization")]
[ServiceFilter(typeof(ValidateModelFilter))]
public async Task<IActionResult> GetRemittanceStatus(RemittanceStatusModel model)
{
var _response = new ApiResponse();
@ -88,5 +93,50 @@ namespace RemitInboundAPI.Controllers
}
return Ok(_response);
}
[HttpPost]
[Route("getCode")]
[Authorize(AuthenticationSchemes = "ApplicationAuthorization")]
[ServiceFilter(typeof(ValidateModelFilter))]
public async Task<IActionResult> StaticCode(CDDIResponseModel model)
{
var _response = new ApiResponse();
var loginDetails = await AuthorizationHelper.GetLoginDetails(User);
model.SessionIdentifier = loginDetails.SessionIdentifier; //unique for one session
model.ProcessIdentifier = Convert.ToString(Guid.NewGuid()); //unique for each process
model.IpAddress = Utilities.GetIpAddress(HttpContext);
using (LogContext.PushProperty("PartnerSessionId", model.PartnerSessionId))
using (LogContext.PushProperty("ProcessIdentifier", model.ProcessIdentifier))
using (LogContext.PushProperty("SessionIdentifier", model.SessionIdentifier))
{
_logger.LogInformation($"REMITCONTROLLER | GETCODE| REQUEST | {JsonConvert.SerializeObject(model)}");
_response = await _remitBusiness.GetStatic(model, loginDetails);
_logger.LogInformation($"REMITCONTROLLER | GETCODE | RESPONSE | {JsonConvert.SerializeObject(_response)}");
}
return Ok(_response);
}
[HttpPost]
[Route("getBank")]
[Authorize(AuthenticationSchemes = "ApplicationAuthorization")]
[ServiceFilter(typeof(ValidateModelFilter))]
public async Task<IActionResult> GetBank(BankResponseModel model)
{
var _response = new ApiResponse();
var loginDetails = await AuthorizationHelper.GetLoginDetails(User);
model.SessionIdentifier = loginDetails.SessionIdentifier; //unique for one session
model.ProcessIdentifier = Convert.ToString(Guid.NewGuid()); //unique for each process
model.IpAddress = Utilities.GetIpAddress(HttpContext);
using (LogContext.PushProperty("PartnerSessionId", model.PartnerSessionId))
using (LogContext.PushProperty("ProcessIdentifier", model.ProcessIdentifier))
using (LogContext.PushProperty("SessionIdentifier", model.SessionIdentifier))
{
_logger.LogInformation($"REMITCONTROLLER | GETBANK| REQUEST | {JsonConvert.SerializeObject(model)}");
_response = await _remitBusiness.GetBank(model, loginDetails);
_logger.LogInformation($"REMITCONTROLLER | GETBANK | RESPONSE | {JsonConvert.SerializeObject(_response)}");
}
return Ok(_response);
}
}
}

18
RemitInboundAPI/RemitInboundAPI/Program.cs

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using RemitInboundAPI;
using RemitInboundAPI.Authorization;
using RemitInboundAPI.Business.Business.ApplicationBusiness;
using RemitInboundAPI.Business.Business.RemitBusiness;
@ -17,10 +19,26 @@ builder.Host.UseSerilog(((ctx, lc) => lc
.ReadFrom.Configuration(ctx.Configuration)
));
Log.Information("REMIT INBOUND API STARTED!");
// Add services to the container.
builder.Services.Configure<ApiBehaviorOptions>(options
=> options.SuppressModelStateInvalidFilter = true);
builder.Services.AddScoped<ValidateModelFilter>();
builder.Services.AddControllers();
//builder.Services.AddScoped<ValidateModelFilter>();
//builder.Services.AddControllers(options =>
//{
// options.Filters.Add(typeof(ValidateModelFilter)); // Register the ValidateModelFilter globally
//});
//builder.Services.AddControllersWithViews(options =>
//{
// options.Filters.Add(typeof(ValidateModelFilter)); // Register the ValidateModelFilter globally
//});
builder.Services.AddScoped<IConnectionHelper, ConnectionHelper>();
builder.Services.AddScoped<IApplicationRepository, ApplicationRepository>();

95
RemitInboundAPI/RemitInboundAPI/ValidateModelFilter.cs

@ -0,0 +1,95 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using RemitInboundAPI.Common.Helper;
using Serilog.Context;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace RemitInboundAPI
{
public class MGErrorResponse
{
public Error error { get; set; }
}
public class Error
{
public string responseCode { get; set; }
public string responseMessage { get; set; }
public string target { get; set; }
}
public class ValidationError
{
public string Property { get; set; }
public string Display { get; set; }
public string Errors { get; set; }
}
public class ValidateModelFilter : ActionFilterAttribute
{
private readonly ILogger<ValidateModelFilter> _logger;
public ValidateModelFilter(ILogger<ValidateModelFilter> logger)
{
_logger = logger;
}
public override async void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
var response = new MGErrorResponse
{
error = new Error()
{
responseCode = "101"
}
};
if (context.ModelState.ErrorCount > 0)
{
var modelType = context.ActionDescriptor.Parameters
.FirstOrDefault(p => p.BindingInfo.BindingSource.Id.Equals("Body", StringComparison.InvariantCultureIgnoreCase))?.ParameterType; //Get model type
List<string> _exclude = new List<string>() { "command", "model" };
List<ValidationError> list = new List<ValidationError>();
foreach (var e in context.ModelState)
{
var property = modelType.GetProperties().FirstOrDefault(p => p.Name.Equals(e.Key, StringComparison.InvariantCultureIgnoreCase));
String propertyName = property != null ? property.Name : e.Key;
String displayName = propertyName;
if (property != null)
{
var displayNameAttributeValue = property.GetCustomAttributes(typeof(DisplayNameAttribute), true).Cast<DisplayNameAttribute>().SingleOrDefault()?.DisplayName;
displayName = displayNameAttributeValue ?? displayName;
}
if (!_exclude.Contains(propertyName))
{
list.Add(new ValidationError
{
Property = propertyName,
Display = displayName,
Errors = string.Join(",", e.Value.Errors.Select(r => r.ErrorMessage).ToArray())
});
}
}
response.error.responseMessage = string.Join(",", list.Select(x => x.Errors).ToArray());
// response.error.responseMessage = "InvalidRequest";//string.Join(",", list.Select(x => x.Errors).ToArray());
response.error.target = string.Join(",", list.Select(x => x.Display).ToArray());
context.Result = new BadRequestObjectResult(response);
}
}
}
}
}

2
RemitInboundAPI/RemitInboundAPI/obj/Debug/net8.0/RemitInboundAPI.AssemblyInfo.cs

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("RemitInboundAPI")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f21fe7c001e9f33c469aaf22f43a6a56b1d6ccf")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e12781bcaa0a9d70ca8c616d2fe43dd9c6d43818")]
[assembly: System.Reflection.AssemblyProductAttribute("RemitInboundAPI")]
[assembly: System.Reflection.AssemblyTitleAttribute("RemitInboundAPI")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

17
RemitInboundAPI/RemitInboundAPI/obj/Debug/net8.0/RemitInboundAPI.MvcApplicationPartsAssemblyInfo.cs

@ -0,0 +1,17 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("Swashbuckle.AspNetCore.SwaggerGen")]
// Generated by the MSBuild WriteCodeFragment class.
Loading…
Cancel
Save