|
|
@ -6,6 +6,7 @@ using Newtonsoft.Json; |
|
|
|
using RemitInboundAPI.Common.Model.ApplicationModel; |
|
|
|
using RemitInboundAPI.Common.Helper; |
|
|
|
using RemitInboundAPI.Repository.Repository.ApplicationRepository; |
|
|
|
using RemitInboundAPI.Business.Helper.ValidationHelper; |
|
|
|
|
|
|
|
namespace RemitInboundAPI.Business.Business.RemitBusiness |
|
|
|
{ |
|
|
@ -25,55 +26,58 @@ namespace RemitInboundAPI.Business.Business.RemitBusiness |
|
|
|
public async Task<CommonResponse> CalculateExRate(ExRateModel model, UserLoginModel loginDetails) |
|
|
|
{ |
|
|
|
CommonResponse _response; |
|
|
|
ExRateValidationHelper validationHelper = new ExRateValidationHelper(); |
|
|
|
var _logRequestModel = new InboundLogModel(model.SessionIdentifier, model.ProcessIdentifier, loginDetails.UserName, "CalculateExRate", model.IpAddress, model.PartnerSessionId, JsonConvert.SerializeObject(model)); |
|
|
|
var _logResponse = await _applicationRepo.LogInboundData(_logRequestModel); |
|
|
|
|
|
|
|
if (_logResponse.ResponseCode == ResponseHelper.SUCCESS) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(model.SendingCountryCode)) |
|
|
|
_response = await validationHelper.ValidateExrateRequest(model); |
|
|
|
if (_response.ResponseCode == ResponseHelper.SUCCESS) |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "SendingCountryCode can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
_response = await _remitRepo.CalculateExRate(model, loginDetails); |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.SendingCurrencyCode)) |
|
|
|
else |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "SendingCurrencyCode can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.PayoutCountryCode)) |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "PayoutCountryCode can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
|
|
|
|
_applicationRepo.LogUpdateInboundData(_response, _logResponse.Id); |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.PayoutCurrencyCode)) |
|
|
|
else |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "PayoutCurrencyCode can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "Error occured in application, please contact Administrator."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | LOGGING ERROR | " + JsonConvert.SerializeObject(new CommonResponse(ResponseHelper.FAILED, "Error logging Inbound master log."))); |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.CollectionAmount)) |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "CollectionAmount can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
|
|
|
|
return _response; |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.PayoutAmount)) |
|
|
|
|
|
|
|
public async Task<CommonResponse> SendRemittance(SendRemittanceModel model, UserLoginModel loginDetails) |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "PayoutAmount can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
} |
|
|
|
else if (string.IsNullOrEmpty(model.PaymentTypeCode)) |
|
|
|
CommonResponse _response; |
|
|
|
SendTransactionValidationHelper validationHelper = new SendTransactionValidationHelper(); |
|
|
|
var _logRequestModel = new InboundLogModel(model.SessionIdentifier, model.ProcessIdentifier, loginDetails.UserName, "SendRemittance", model.IpAddress, model.PartnerSessionId, JsonConvert.SerializeObject(model)); |
|
|
|
var _logResponse = await _applicationRepo.LogInboundData(_logRequestModel); |
|
|
|
|
|
|
|
if (_logResponse.ResponseCode == ResponseHelper.SUCCESS) |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "PaymentTypeCode can not be empty."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
_response = await validationHelper.SendTransactionValidationRequest(model); |
|
|
|
if (_response.ResponseCode == ResponseHelper.SUCCESS) |
|
|
|
{ |
|
|
|
_response = await _remitRepo.SendRemittance(model, loginDetails); |
|
|
|
} |
|
|
|
else |
|
|
|
_response = await _remitRepo.CalculateExRate(model, loginDetails); |
|
|
|
{ |
|
|
|
_logger.LogError("REMITBUSINESS | SENDREMITTANCE | VALIDATION ERROR | " + JsonConvert.SerializeObject(_response)); |
|
|
|
} |
|
|
|
|
|
|
|
_applicationRepo.LogUpdateInboundData(_response, _logResponse.Id); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_response = new CommonResponse(ResponseHelper.FAILED, "Error occured in application, please contact Administrator."); |
|
|
|
_logger.LogError("REMITBUSINESS | CALCULATEEXRATE | LOGGING ERROR | " + JsonConvert.SerializeObject(new CommonResponse(ResponseHelper.FAILED, "Error logging Inbound master log."))); |
|
|
|
_logger.LogError("REMITBUSINESS | SENDREMITTANCE | LOGGING ERROR | " + JsonConvert.SerializeObject(new CommonResponse(ResponseHelper.FAILED, "Error logging Inbound master log."))); |
|
|
|
} |
|
|
|
|
|
|
|
return _response; |
|
|
|