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.
 
 
 

3179 lines
134 KiB

using Business.KftcPasswordRule;
using System.Linq;
using Business.PennyTest;
using Business.TPApi;
using Common;
using Common.Helper;
using Common.KFTC;
using Common.Language;
using Common.Model;
using Common.Model.Config;
using Common.Model.Customer;
using Common.Model.CustomerRegister;
using Common.Model.Notification;
using Common.Model.Remit;
using Common.Model.RequestOTP;
using log4net;
using Newtonsoft.Json;
using PushNotification;
using Repository.Mobile;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Runtime.Remoting.Messaging;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using static Common.Model.DynamicReceiverSetup.DynamicReceiver;
using Notify = Common.Model.Notification;
using System.Collections;
using Repository;
using System.Configuration;
using Business.TrustDoc;
using Business.Addressy;
using System.Text;
namespace Business.Mobile
{
public class MobileServices : IMobileServices
{
private readonly IMobileServicesRepo _requestServices;
private readonly Dao _dao = new Dao();
private static readonly ILog Log = LogManager.GetLogger(typeof(MobileServices));
private readonly PennyTestBusiness _pennyTestBusiness;
private ITrustDocBusiness _trustDocBusiness;
public MobileServices(IMobileServicesRepo requestServices, PennyTestBusiness pennyTestBusiness, ITrustDocBusiness trustDocBusiness)
{
_requestServices = requestServices;
_pennyTestBusiness = pennyTestBusiness;
_trustDocBusiness = trustDocBusiness;
}
public JsonRxResponse GetCountriesServices()
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var listCountriesServices = _requestServices.GetCountriesServices();
if (listCountriesServices == null || listCountriesServices.Count < 1)
{
Log.Debug("GetCountriesServices | Returning null while calling the GetCountriesServices to fetch the countries services.");
jsonRx.SetResponse("1", "Could not fetch the exrate data.");
return jsonRx;
}
jsonRx.SetResponse("0", "Success");
var path = GetStatic.ReadWebConfig("ServiceType_Resource", "");
var text = File.ReadAllText(path);
List<ServiceTypeDetails> sd = JsonConvert.DeserializeObject<List<ServiceTypeDetails>>(text);
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
if (string.IsNullOrEmpty(lang))
{
lang = "en";
}
var idx = sd.FindIndex(x => x.countryCode == lang);
var data = new ServiceTypeDetails();
if (idx < 0)
{
data = sd[sd.FindIndex(x => x.countryCode == "en")];
}
else
{
data = sd[idx];
}
foreach (var item in listCountriesServices)
{
foreach (var product in item.serviceAvailable)
{
switch (product.text.ToLower())
{
case "cash payment":
product.description = data.cashPayment;
break;
case "bank deposit":
product.description = data.bankDeposit;
break;
case "mobile wallet":
product.description = data.mobileWallet;
break;
case "home delivery":
product.description = data.homeDelivery;
break;
case "card payment":
product.description = data.cardPayment;
break;
}
}
}
jsonRx.Data = listCountriesServices;
Log.Debug("GetCountriesServices | DB RESPONSE AFTER PARSING : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not fetch the countries service details.");
return jsonRx;
}
}
public JsonRxResponse GetNotifyInfo(NotifiCationInfo info)
{
JsonRxResponse res = new JsonRxResponse();
res = _requestServices.GetNotifyInfo(info.customerId);
return res;
}
public JsonRxResponse GetNotifyDetailInfo(NotifiCationDetailInfo info)
{
JsonRxResponse res = new JsonRxResponse();
res = _requestServices.GetNotifyDetailInfo(info.rowId);
return res;
}
public JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile.
jsonRx = _requestServices.RequestOTP(requestOTPModel);
Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (jsonRx.ErrorCode == "0")
{
bool emailSent = false;
bool smsSent = false;
if (requestOTPModel.userId.IsValidEmail() & (jsonRx.Extra3.Equals("0") | jsonRx.Extra3.Equals("100")))
{
if (!string.IsNullOrEmpty(jsonRx.ErrorCode) && jsonRx.ErrorCode.Equals("0"))
{
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = jsonRx.Extra });
bodyMappings.Add(new Notify.Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP });
bodyMappings.Add(new Notify.Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" });
try
{
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = requestOTPModel.userId,
ControlNo = requestOTPModel.receiverId,
ProviderId = "REQUESTOTP_EMAIL",
Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= requestOTPModel.userId,
DeviceType = requestOTPModel.DeviceType,
} }
};
Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
var jsonRx1 = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(jsonRx1));
emailSent = true;
}
catch (Exception emailException)
{
Log.Error("Error sending email", emailException);
}
try
{
string mobileNum = jsonRx.Extra2;
var mobNum = getSenderFormattedNumber(mobileNum);
SendSMSApiService _sendAPI = new SendSMSApiService();
StringBuilder s = new StringBuilder();
s.AppendLine($"Dear { jsonRx.Extra}");
s.AppendLine($"Your OTP code for Customer Registration is {requestOTPModel.OTP }.");
s.AppendLine("Regards, IME London");
SMSRequestModel _req = new SMSRequestModel
{
ProviderId = "ProcessId",
MobileNumber = mobileNum,
SMSBody = s.ToString(),
ProcessId = requestOTPModel.ProcessId,
RequestedBy = requestOTPModel.userId,
UserName = requestOTPModel.userId,
method = "send",
ControlNo = "", // GetControlNo()
};
Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
smsSent = true;
}
catch (Exception smsException)
{
Log.Error("Error sending SMS", smsException);
}
if (emailSent || smsSent)
{
jsonRx.ErrorCode = "0";
jsonRx.SetResponse("0", "OTP has been Sent.");
return jsonRx;
}
}
}
else
{
if (jsonRx.Extra3 != null & jsonRx.Extra3.Equals("103"))
{
return new JsonRxResponse { ErrorCode = "0", Msg = "OTP Already Sent" };
}
jsonRx.ErrorCode = "1";
// var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang);
return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = jsonRx.Msg };
}
}
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx;
}
}
public string getSenderFormattedNumber(string number)
{
string finalNo = number;
if (!number.Contains("+44"))
{
string mobileFirst = number.Substring(0, 1);
if (mobileFirst == "0")
{
if (number.Length == 11)
{
finalNo = "+44" + number.Substring(1, number.Length - 1);
return finalNo;
}
else if (number.Length < 11)
{
finalNo = $"+44{number}";
}
}
else if (number.Substring(0, 1) != "0" && number.Length == 10)
{
finalNo = $"+44{number}";
}
}
else if (number.Contains("+44"))
{
string MobN = number.Substring(4, 1);
if (MobN == "0" && number.Length > 14)
{
finalNo = number.Remove(4, 1);
}
}
if (!finalNo.Substring(0, 1).Contains("+"))
{
finalNo = $"+{finalNo}";
}
return finalNo;
}
public JsonRxResponse VerifyIdNumber(IDValidateModel iDValidate)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.VerifyIdNumber(iDValidate);
Log.Debug("VerifyIdNumber | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx;
}
}
public JsonRxResponse SubmitOTP(RequestOTPModel requestOTPModel)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.SubmitOTP(requestOTPModel);
Log.Debug("SubmitOTP | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (jsonRx.ErrorCode.Equals("0"))
{
string email = requestOTPModel.userId;
UserDetails userDetails = _requestServices.GetUserDetails(email);
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = userDetails.FullName });
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerId", SText = userDetails.CustomerId.ToString() });
bodyMappings.Add(new Notify.Mapping() { SValue = "UserId", SText = userDetails.MembershipId });
bodyMappings.Add(new Notify.Mapping() { SValue = "FirstName", SText = userDetails.FirstName });
bodyMappings.Add(new Notify.Mapping() { SValue = "MiddleName", SText = userDetails.MiddleName });
bodyMappings.Add(new Notify.Mapping() { SValue = "LastName", SText = userDetails.LastName });
bodyMappings.Add(new Notify.Mapping() { SValue = "MobileNo", SText = userDetails.Mobile });
bodyMappings.Add(new Notify.Mapping() { SValue = "Address", SText = userDetails.Address });
bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = userDetails.Email });
bodyMappings.Add(new Notify.Mapping() { SValue = "RegisteredDate", SText = Convert.ToString(userDetails.RegisteredDate) });
bodyMappings.Add(new Notify.Mapping() { SValue = "rewardPoint", SText = userDetails.TotalPoints });
bodyMappings.Add(new Notify.Mapping() { SValue = "RegReward", SText = userDetails.RegPoints });
bodyMappings.Add(new Notify.Mapping() { SValue = "TranReward", SText = userDetails.TranPoints });
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = userDetails.Email,
ProviderId = "BasicRegistration",
NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
Template = Common.Model.Enum.NotifyTemplate.BASIC_REGISTRATION_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= userDetails.Email
}
}
};
jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
}
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx;
}
}
public JsonRxResponse CalculateExRate(ExRateCalculateRequest m)
{
ThirdPartyAPI _tpApi = new ThirdPartyAPI();
JsonRxResponse response = new JsonRxResponse();
APIJsonResponse jsonResponse = new APIJsonResponse();
try
{
ExRateCalculate exRequest = new ExRateCalculate()
{
AgentRefId = "",
CalcBy = m.calcBy,
CAmount = Convert.ToDecimal(m.cAmount == "" ? "0" : m.cAmount),
CardOnline = "",
CollCurrency = m.sCurrency,
CouponCode = m.DeviceType,
CustomerId = 0,
IsExRateCalcByPartner = false,
IsManualSc = false,
IsOnline = false,
ManualSc = 0,
//PAgentId = Convert.ToInt32(m.pAgent == "" || m.pAgent==null ? "0" : m.pAgent),
PAgentName = "",
PAmount = Convert.ToDecimal(m.pAmount == "" || m.pAmount == null ? "0" : m.pAmount),
PaymentType = m.paymentType,
PayoutPartner = 0,
PCountry = Convert.ToInt32(m.pCountry == "" || m.pCountry == null ? "0" : m.pCountry),
pCountryCode = m.pCountryName,
PCountryName = m.pCountryName,
PCurrency = m.pCurrency,
ProcessId = m.processId,
ProviderId = "",
RequestedBy = "mobile",
SAgent = 0,
SBranch = Convert.ToInt32(GetStatic.ReadWebConfig("sBranch", "")),
SchemeId = m.schemeId,
SCountry = Convert.ToInt32(m.sCountry == "" || m.sCountry == null ? "0" : m.sCountry),
SCurrency = m.sCurrency,
ServiceType = m.serviceType,
SessionId = "",
SSuperAgent = Convert.ToInt32(GetStatic.ReadWebConfig("sSuperAgent", "")),
tPExRate = m.tpExRate,
UserName = m.userId,
ProcessFor = "dashboard",
};
Log.Debug("CalculateExRate | TPAPI REQUEST : " + JsonConvert.SerializeObject(exRequest));
var result = _tpApi.ThirdPartyApiGetDataOnly<ExRateCalculate, APIJsonResponse>(exRequest, "TP/ExRate", out jsonResponse);
Log.Debug("CalculateExRate | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
response = new JsonRxResponse()
{
ErrorCode = result.ResponseCode,
Id = result.Id,
Msg = result.Msg,
Data = result.Data,
Extra = result.Extra,
Extra2 = result.Extra1,
FootNoteMessage = result.FootNoteMessage
};
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
string enumString = string.Empty;
response.FootNoteMessage = response.ErrorCode.Equals("0") ? Utilities.GetLanguageMapping(ConfigurationManager.AppSettings["footNote_calculateDashboard"].ToString(), lang).Message : "";
//return new JsonRxResponse { ErrorCode = response.ErrorCode.Equals("0") ? "0" : "1", Msg = map.Message, Id = response.Id, Extra = response.Extra, Data = response.Data, Extra2 = response.Extra2, FootNoteMessage = response.FootNoteMessage };
return response;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
response.SetResponse("1", "Error occured while calculating ex-rate");
return response;
}
}
public JsonRxResponse ChangeTxnPin(ChangeTxnPinModel changeTxnPin)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.ChangeTxnPin(changeTxnPin);
Log.Debug("ChangeTxnPin | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", ex.ToString());
return jsonRx;
}
}
public JsonRxResponse ChangeSettings(ChangeSettingModel changeSettings)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.ChangeSettings(changeSettings);
Log.Debug("ChangeSettings | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while ChangeSettings.");
return jsonRx;
}
}
public JsonRxResponse ChangePasswordAndTxnPin(ChangePasswordAndTxnPinModel changePasswordAndTxnPin)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
if (string.IsNullOrEmpty(changePasswordAndTxnPin.CurrentPassword))
{
jsonRx.SetResponse("1", "Current Password cannot be empty!");
return jsonRx;
}
if (string.IsNullOrEmpty(changePasswordAndTxnPin.NewPassword))
{
jsonRx.SetResponse("1", "New Password cannot be empty!");
return jsonRx;
}
if (string.IsNullOrEmpty(changePasswordAndTxnPin.ConfirmNewPassword))
{
jsonRx.SetResponse("1", "Confirm New Password cannot be empty!");
return jsonRx;
}
if (string.IsNullOrEmpty(changePasswordAndTxnPin.CurrentPin))
{
jsonRx.SetResponse("1", "Current Pin cannot be empty!");
return jsonRx;
}
if (string.IsNullOrEmpty(changePasswordAndTxnPin.NewPin))
{
jsonRx.SetResponse("1", "New Pin cannot be empty!");
return jsonRx;
}
if (string.IsNullOrEmpty(changePasswordAndTxnPin.ConfirmNewPin))
{
jsonRx.SetResponse("1", "Confirm New Pin cannot be empty!");
return jsonRx;
}
if (changePasswordAndTxnPin.NewPin.Length < 6)
{
jsonRx.SetResponse("1", "PIN should be 6 digit number!");
return jsonRx;
}
if (changePasswordAndTxnPin.ConfirmNewPin.Length < 6)
{
jsonRx.SetResponse("1", "PIN should be 6 digit number!");
return jsonRx;
}
if (changePasswordAndTxnPin.NewPin.Length > 6)
{
jsonRx.SetResponse("1", "PIN cannot be greater than 6 digit!");
return jsonRx;
}
if (changePasswordAndTxnPin.ConfirmNewPin.Length > 6)
{
jsonRx.SetResponse("1", "PIN cannot be greater than 6 digit!");
return jsonRx;
}
jsonRx = _requestServices.ChangePasswordAndTxnPin(changePasswordAndTxnPin);
Log.Debug("ChangePasswordAndTxnPin | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while ChangeTxnPin.");
return jsonRx;
}
}
public JsonRxResponse RegisterKycExistingCustomer()
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var httpRequest = HttpContext.Current.Request;
var custKyc = new CustomerKYCModel()
{
userId = httpRequest["userId"],
type = httpRequest["type"],
employeerName = httpRequest["employeerName"],
monthlyIncome = httpRequest["monthlyIncome"],
businessType = httpRequest["businessType"],
mobile = httpRequest["mobile"],
additionalAddress = httpRequest["additionalAddress"],
additionalIdType = httpRequest["additionalIdType"],
visaStatus = httpRequest["visaStatus"],
idType = httpRequest["idType"],
occupation = httpRequest["occupation"],
purposeOfRegistration = httpRequest["purposeOfRegistration"],
otherOccupation = httpRequest["otherOccupation"],
otherIdType = httpRequest["otherIdType"],
ExistingCutomer = true
};
var idFrontUrl = httpRequest.Files["idFront"];
var idBackUrl = httpRequest.Files["idBack"];
var idSideUrl = httpRequest.Files["idSide"];
Log.Debug($"RegisterKYCExistingCustomer | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}");
if (custKyc.type.Equals("1") && httpRequest.Files.Count < 1) //documents
{
Log.Debug("RegisterKycExistingCustomer | Validate Image : Failed" + JsonConvert.SerializeObject(jsonRx));
jsonRx.SetResponse("1", "Primary Id documents are required.");
return jsonRx;
}
jsonRx = ValidateForm(custKyc, idFrontUrl, idBackUrl, idSideUrl);
if (!jsonRx.ErrorCode.Equals("0"))
{
Log.Debug("RegisterKYC | Validate form failed : " + JsonConvert.SerializeObject(jsonRx));
jsonRx.SetResponse("1", jsonRx.Msg);
return jsonRx;
}
var rep = _requestServices.RegisterKYCExistingCustomer(custKyc);
Log.Debug("RegisterKYCExistingCustomer | DB RESPONSE : " + JsonConvert.SerializeObject(rep));
//if (rep.ErrorCode.Equals("0"))
//{
// var fireBaseId = Convert.ToString(CallContext.GetData(Constants.FcmId));
// Task.Run(() => FcmNotifier.Notify(fireBaseId, Languages.GetMessage("kyc_submit_no_pennytest", lang), Languages.GetTitle("kyc", lang)));
//}
return rep;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not register the customer Kyc.");
return jsonRx;
}
}
public JsonRxResponse RegisterKYC(string deviceType = "")
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
bool isKyc = false;
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var httpRequest = HttpContext.Current.Request;
var idFrontUrl = httpRequest.Files["idFront"];
var idBackUrl = httpRequest.Files["idBack"];
var idSideUrl = httpRequest.Files["idSide"];
var additionalIdUrl = httpRequest.Files["additionalId"];
var additionalIdBackUrl = httpRequest.Files["additionalIdBack"];
var facePictureUrl = httpRequest.Files["faceImageFile"];
var custKyc = new CustomerKYCModel()
{
userId = httpRequest["userId"],
type = httpRequest["type"],
monthlyIncome = httpRequest["monthlyIncome"],
businessType = httpRequest["businessType"],
mobile = httpRequest["mobile"],
additionalAddress = httpRequest["additionalAddress"],
idType = httpRequest["idType"],
idNumber = httpRequest["IdNumber"] != null ? httpRequest["IdNumber"] : "",
idIssuingCountry = httpRequest["IdIssuedCountry"] != null ? httpRequest["IdIssuedCountry"] : "",
idStartDate = httpRequest["idStartDate"] != null ? httpRequest["idStartDate"] : "",
idExpiryDate = httpRequest["IdEndDate"] != null ? httpRequest["IdEndDate"] : "",
additionalIdType = httpRequest["additionalIdType"],
employeerName = httpRequest["employeerName"],
occupation = httpRequest["occupation"],
purposeOfRegistration = httpRequest["purposeOfRegistration"],
otherOccupation = httpRequest["otherOccupation"],
otherIdType = httpRequest["otherIdType"],
RegistrationType = httpRequest["RegistrationType"] != null ? httpRequest["RegistrationType"] : "",
TrustDocId = httpRequest["TrustDocId"] != null ? httpRequest["TrustDocId"] : "",
customerType = httpRequest["customerType"],
idFront = idFrontUrl != null ? idFrontUrl.FileName : "",
idBack = idBackUrl != null ? idBackUrl.FileName : "",
additionalId = additionalIdUrl != null ? additionalIdUrl.FileName : "",
additionalIdBack = additionalIdBackUrl != null ? additionalIdBackUrl.FileName : "",
};
if (deviceType.ToLower().Equals("ios") & !string.IsNullOrEmpty(custKyc.customerType))
{
custKyc.idType = custKyc.customerType;
}
else if (!string.IsNullOrEmpty(custKyc.customerType) && (!string.IsNullOrEmpty(custKyc.RegistrationType)) && custKyc.RegistrationType.Equals("EKYC"))
{
custKyc.idType = custKyc.customerType;
}
if (!string.IsNullOrEmpty(custKyc.RegistrationType) && custKyc.RegistrationType.Equals("EKYC"))
{
isKyc = true;
}
var isBackRequired = "0";
//if (httpRequest.Files.Count > 0 && Utilities.IsCheckAdditionalId())
//{
// var id = _requestServices.checkAdditionalId(custKyc.additionalIdType);
// if (id != null)
// {
// isBackRequired = id["isBackRequired"].ToString();
// }
//}
//Log.Debug($"RegisterKYC | httpRequest : {httpRequest.Params}");
Log.Debug($"RegisterKYC | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}");
//if (httpRequest.Files.Count <= 1) //documents
//{
// Log.Debug("RegisterKYC | Validate Image : Failed" + JsonConvert.SerializeObject(jsonRx));
// jsonRx.SetResponse("1", "Primary Id documents are required.");
// return jsonRx;
//}
jsonRx = ValidateForm(custKyc, idFrontUrl, idBackUrl, idSideUrl, additionalIdUrl, facePictureUrl, additionalIdBackUrl, isBackRequired, isKyc);
if (!jsonRx.ErrorCode.Equals("0"))
{
Log.Debug("RegisterKYC | Validate form failed : " + JsonConvert.SerializeObject(jsonRx));
jsonRx.SetResponse("100", jsonRx.Msg);
return jsonRx;
}
var rep = _requestServices.RegisterKYC(custKyc);
SendNotificationRequest pushNotificationRequest = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = custKyc.userId,
ProcessId = Guid.NewGuid().ToString(),
ProviderId = "RegisterKYC",
NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(),
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = "Thank you for signing up with IME London. You can continue to send transactions while your KYC is being processed, even though it is currently in processing.",
Title = "KYC Processing",
},
Address= rep.Extra2,
DeviceType = rep.Extra3
}
},
Language = Convert.ToString(CallContext.GetData(Constants.Language))
};
Log.Debug("RegisterKYC | DB RESPONSE" + JsonConvert.SerializeObject(rep));
return rep;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not register the customer Kyc.");
return jsonRx;
}
}
public JsonRxResponse RenewID()
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var httpRequest = HttpContext.Current.Request;
RenewID renewId = new RenewID();
renewId.userId = httpRequest["userId"];
var idFrontUrl = httpRequest.Files["idFront"];
var idBackUrl = httpRequest.Files["idBack"];
if (!IsValidImageIdRequest(ref renewId, idFrontUrl, idBackUrl))
{
Log.Debug("RenewID.IsValidImageIdRequest | Validate Image : Failed");
jsonRx.SetResponse("1", "Invalid image file.");
}
var rep = _requestServices.RenewID(renewId);
Log.Debug("RenewID | DB RESPONSE | " + JsonConvert.SerializeObject(rep));
return rep;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not RenewID.");
return jsonRx;
}
}
public JsonRxResponse DepositSlip(DepositSlip depoSlip)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var httpRequest = HttpContext.Current.Request;
var slipUrl = httpRequest.Files["DepositSlip"];
if (!IsValidImageASlipIdRequest(ref depoSlip, slipUrl))
{
Log.Debug("DepositSlip.IsValidImageASlipIdRequest | Validate Image : Failed");
jsonRx.SetResponse("1", "Invalid image file.");
}
var rep = _requestServices.DepositSlip(depoSlip);
Log.Debug("DepositSlip | DB RESPONSE | " + JsonConvert.SerializeObject(rep));
return rep;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Couldnot upload Deposit Slip!");
return jsonRx;
}
}
public bool IsValidImageASlipIdRequest(ref DepositSlip depoSlip, HttpPostedFile slipUrl)
{
bool isValidated = true;
string fileName = "";
var extension = "";
if (slipUrl != null)
{
extension = Path.GetExtension(slipUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && slipUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveIdFileToPath(slipUrl, depoSlip.UserId, extension, "slip", "deposit");
depoSlip.Slip = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
return isValidated;
}
public bool IsValidImageIdRequest(ref RenewID renewID, HttpPostedFile idFrontUrl, HttpPostedFile idBackUrl)
{
bool isValidated = true;
string fileName = "";
var extension = "";
if (idFrontUrl != null)
{
extension = Path.GetExtension(idFrontUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idFrontUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveIdFileToPath(idFrontUrl, renewID.userId, extension, "id_front");
renewID.idFront = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
if (idBackUrl != null)
{
extension = Path.GetExtension(idBackUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveIdFileToPath(idBackUrl, renewID.userId, extension, "id_back");
renewID.idBack = fileName;
}
}
return isValidated;
}
private static string SaveIdFileToPath(HttpPostedFile file, string user, string extension, string img, string type = null)
{
string fileName = "";
string docUploadPath = ApplicationConfig.GetDocumentUploadPath();
// Get the file size
int fileSize = file.ContentLength;
fileName = "upload-" + img + "-" + user + "-" + GetTimestamp(DateTime.Now) + extension;
if (type == "deposit")
{
docUploadPath = docUploadPath + "/CustomerDocument/DepositSlip/";
}
else
{
docUploadPath = docUploadPath + "/CustomerDocument/VerifyDocumentUpload/";
}
Log.Debug("Preparing file to save in dir " + docUploadPath);
if (!Directory.Exists(docUploadPath))
Directory.CreateDirectory(docUploadPath);
string fileToSave = Path.Combine(docUploadPath, fileName);
Log.Debug("Saving file as " + fileToSave);
file.SaveAs(fileToSave);
Log.Debug("Done with Saving ");
return fileName;
}
public JsonRxResponse ValidateMobile(string mobile)
{
JsonRxResponse rxResponse = new JsonRxResponse() { ErrorCode = "0", Extra2 = mobile };
if (string.IsNullOrEmpty(mobile))
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Mobile Number is missing!";
return rxResponse;
}
if (!mobile.IsValidMobileNumber())
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number format!";
return rxResponse;
}
if (!mobile.Contains("+81"))
{
string mobileFirst = mobile.Substring(0, 1);
if (mobileFirst == "0")
{
if (mobile.Length == 11)
{
rxResponse.Extra = "+81" + mobile.Substring(1, mobile.Length - 1);
return rxResponse;
}
else if (mobile.Length < 11)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number provided!";
return rxResponse;
}
else if (mobile.Length > 11)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number length provided!";
return rxResponse;
}
}
else if (mobile.Substring(0, 1) != "0" && mobile.Length == 10)
{
rxResponse.Extra = $"+81{mobile}";
return rxResponse;
}
else if (mobile.Substring(0, 1) == "0" && mobile.Length > 11)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number length!";
return rxResponse;
}
}
else if (mobile.Contains("+81"))
{
string MobN = mobile.Substring(3, 1);
if (MobN == "0")
{
if (mobile.Length == 14)
{
rxResponse.Extra = mobile.Remove(3, 1);
return rxResponse;
}
else if (mobile.Length < 14)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number provided!";
return rxResponse;
}
else if (mobile.Length > 14)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number length provided!";
return rxResponse;
}
}
else if (mobile.Substring(3, 1) != "0" && mobile.Length == 13)
{
rxResponse.Extra = mobile;
}
else if (mobile.Substring(3, 1) == "1" && mobile.Length == 14)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number length or format!";
return rxResponse;
}
else if (mobile.Substring(3, 1) == "0" && mobile.Length > 11)
{
rxResponse.ErrorCode = "1";
rxResponse.Msg = "Invalid Mobile Number length!";
return rxResponse;
}
}
//else
//{
// rxResponse.Extra = mobile;
//}
return rxResponse;
}
private JsonRxResponse ValidateForm(CustomerKYCModel kyc, HttpPostedFile idFrontUrl, HttpPostedFile idBackUrl, HttpPostedFile idSideUrl, HttpPostedFile additionalIdUrl = null, HttpPostedFile facePictureUrl = null, HttpPostedFile additionalIdBackUrl = null, string isBackRequired = "0", bool isEkyc = false)
{
string enumString = string.Empty;
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse() { ErrorCode = "0", Msg = "Kyc Form validation success." };
Log.Debug("IsValidatedForm | Requested parameters : " + JsonConvert.SerializeObject(kyc));
//NULL validation
//var jsonRxMobile = ValidateMobile(kyc.mobile);
//if (!jsonRxMobile.ErrorCode.Equals("0"))
//{
// Log.Debug($"RegisterKYC | Mobile : {kyc.mobile} | ValidateMobile failed : { JsonConvert.SerializeObject(jsonRxMobile)}");
// jsonRx.SetResponse("1", jsonRxMobile.Msg);
// return jsonRx;
//}
//else
//{
// Log.Debug($"RegisterKYC | ValidateMobile Response : { JsonConvert.SerializeObject(jsonRxMobile)}");
// kyc.mobile = jsonRxMobile.Extra;
//}
if (kyc.type.Equals("0"))
{
if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation))
{
enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
jsonRx.SetResponse("100", map.Message);
return jsonRx;
}
else if (string.IsNullOrEmpty(kyc.occupation))
{
if (string.IsNullOrEmpty(kyc.otherOccupation))
{
enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
jsonRx.SetResponse("100", map.Message);
return jsonRx;
}
}
if (string.IsNullOrEmpty(kyc.idExpiryDate))
{
jsonRx.SetResponse("100", "IdExpiryDate is required");
return jsonRx;
}
if (string.IsNullOrEmpty(kyc.idStartDate))
{
jsonRx.SetResponse("100", "Idissue Date is required");
return jsonRx;
}
if (string.IsNullOrEmpty(kyc.idIssuingCountry))
{
jsonRx.SetResponse("100", "idIssuingCountry is required");
return jsonRx;
}
}
//if (string.IsNullOrEmpty(kyc.idNumber))
//{
// jsonRx.SetResponse("1", "Id number is required");
// return jsonRx;
//}
//if (string.IsNullOrEmpty(kyc.additionalAddress))
//{
// enumString = RESPONSE_MSG.VALIDATE_FORM_4.ToString();
// var map = Utilities.GetLanguageMapping(enumString, lang);
// jsonRx.SetResponse("1", map.Message);
// return jsonRx;
//}
//if (kyc.additionalAddress.Length > 50)
//{
// enumString = RESPONSE_MSG.VALIDATE_FORM_11.ToString();
// var map = Utilities.GetLanguageMapping(enumString, lang);
// jsonRx.SetResponse("1", map.Message);
// return jsonRx;
//}
//if (string.IsNullOrEmpty(kyc.businessType))
//{
// enumString = RESPONSE_MSG.VALIDATE_FORM_5.ToString();
// var map = Utilities.GetLanguageMapping(enumString, lang);
// jsonRx.SetResponse("1", map.Message);
// return jsonRx;
//}
//if (string.IsNullOrEmpty(kyc.mobile))
//{
// enumString = RESPONSE_MSG.VALIDATE_FORM_6.ToString();
// var map = Utilities.GetLanguageMapping(enumString, lang);
// jsonRx.SetResponse("1", map.Message);
// return jsonRx;
//}
//if (string.IsNullOrEmpty(kyc.purposeOfRegistration))
//{
// enumString = RESPONSE_MSG.VALIDATE_FORM_7.ToString();
// var map = Utilities.GetLanguageMapping(enumString, lang);
// jsonRx.SetResponse("1", map.Message);
// return jsonRx;
//}
if (!isEkyc && string.IsNullOrEmpty(kyc.idType))
{
if (string.IsNullOrEmpty(kyc.otherIdType))
{
enumString = RESPONSE_MSG.VALIDATE_FORM_1.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
jsonRx.SetResponse("100", map.Message);
return jsonRx;
}
}
else if (!isEkyc && string.IsNullOrEmpty(kyc.idType) && string.IsNullOrEmpty(kyc.otherIdType))
{
enumString = RESPONSE_MSG.VALIDATE_FORM_10.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
jsonRx.SetResponse("100", map.Message);
return jsonRx;
}
if (!isEkyc && !kyc.ExistingCutomer)
{
if (isBackRequired == "1" && additionalIdBackUrl == null)
{
jsonRx.SetResponse("100", "Additional ID Back is required!");
return jsonRx;
}
if (string.IsNullOrEmpty(kyc.additionalIdType))
{
enumString = RESPONSE_MSG.VALIDATE_FORM_8.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
jsonRx.SetResponse("100", map.Message);
return jsonRx;
}
}
if (!IsValidImage(ref kyc, idFrontUrl, idBackUrl, idSideUrl, additionalIdUrl, facePictureUrl, additionalIdBackUrl))
{
Log.Debug("IsValidatedForm | Validate Image : Failed");
jsonRx.SetResponse("100", "Invalid image file.");
return jsonRx;
}
return jsonRx;
}
public bool IsValidImage(ref CustomerKYCModel kyc, HttpPostedFile idFrontUrl, HttpPostedFile idBackUrl, HttpPostedFile idSideUrl, HttpPostedFile additionalIdUrl, HttpPostedFile facePictureUrl, HttpPostedFile additionalIdBackUrl)
{
bool isValidated = true;
string fileName = "";
var extension = "";
DataRow dirDetails = _requestServices.GetCustomerImageSavePath(kyc.userId);
if (null == dirDetails)
{
return false;
}
string registrationDate = dirDetails["REGISTERED_DATE"].ToString();
string membershipId = dirDetails["MEMBERSHIPID"].ToString();
if (string.IsNullOrEmpty(registrationDate) || string.IsNullOrEmpty(membershipId))
{
return false;
}
if (idFrontUrl != null)
{
extension = Path.GetExtension(idFrontUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idFrontUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(idFrontUrl, membershipId, extension, "id_front", registrationDate);
kyc.idFront = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
if (idBackUrl != null)
{
extension = Path.GetExtension(idBackUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(idBackUrl, membershipId, extension, "id_back", registrationDate);
kyc.idBack = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
if (idSideUrl != null)
{
extension = Path.GetExtension(idSideUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idSideUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(idSideUrl, membershipId, extension, "id_side", registrationDate);
kyc.idSide = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
if (additionalIdUrl != null)
{
extension = Path.GetExtension(additionalIdUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && additionalIdUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(additionalIdUrl, membershipId, extension, "id_additional_front", registrationDate);
kyc.additionalId = fileName;
}
}
if (additionalIdBackUrl != null)
{
extension = Path.GetExtension(additionalIdBackUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && additionalIdBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(additionalIdBackUrl, membershipId, extension, "id_additional_back", registrationDate);
kyc.additionalIdBack = fileName;
}
}
if (!isValidated)
{
return isValidated;
}
if (facePictureUrl != null)
{
extension = Path.GetExtension(facePictureUrl.FileName);
if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && facePictureUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
{
isValidated = false;
}
else
{
fileName = SaveFileToPath(facePictureUrl, membershipId, extension, "face_picture", registrationDate);
kyc.facePicture = fileName;
}
}
return isValidated;
}
private static string SaveFileToPath(HttpPostedFile file, string membershipId, string extension, string img, string registrationDate)
{
string fileName = "";
string folderName = membershipId;
string docUploadPath = ApplicationConfig.GetDocumentUploadPath();
// Get the file size
int fileSize = file.ContentLength;
fileName = "upload-" + img + "-" + GetTimestamp(DateTime.Now) + extension;
docUploadPath = docUploadPath + "/CustomerDocument/" + registrationDate.Replace("_", "/") + "/" + folderName;
Log.Debug("Preparing file to save in dir " + docUploadPath);
if (!Directory.Exists(docUploadPath))
Directory.CreateDirectory(docUploadPath);
//var tempDocUploadPath = docUploadPath + "/temp";
//if (!Directory.Exists(tempDocUploadPath))
// Directory.CreateDirectory(tempDocUploadPath);
//CompressImageDao ci = new CompressImageDao();
//string tempFileUploadPath = Path.Combine(tempDocUploadPath, fileName);
//file.SaveAs(tempFileUploadPath);
string fileToSave = Path.Combine(docUploadPath, fileName);
Log.Debug("Saving file as " + fileToSave);
file.SaveAs(fileToSave);
//if (!ci.CompressImageAndSave((fileSize / 1024), tempFileUploadPath, fileToSave))
//{
// file.SaveAs(fileToSave);
//}
//if (Directory.Exists(tempDocUploadPath))
// Directory.Delete(tempDocUploadPath, true);
Log.Debug("Done with Saving ");
return fileName;
}
public static string GetTimestamp(DateTime value)
{
return value.ToString("yyyyMMddHHmmssffff");
}
public JsonRxResponse LoadFormStaticData(string type)
{
JsonRxResponse jsonRx = new JsonRxResponse
{
ErrorCode = "1",
Msg = "Error"
};
try
{
if (type.ToLower().Equals("receiver"))
{
StaticData sd = _requestServices.LoadFormStaticData("receiver");
if (sd != null)
{
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = sd;
Log.Debug("LoadFormStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("LoadFormStaticData | Returning null while calling DB");
jsonRx.SetResponse("1", "Error occured", null);
return jsonRx;
}
else if (type.ToLower().Equals("kyc"))
{
KycStaticData sd = _requestServices.LoadKycStaticData("kyc");
if (sd != null)
{
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = sd;
Log.Debug("LoadFormStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("LoadFormStaticData | Returning null while calling DB");
jsonRx.SetResponse("1", "Error occured", null);
return jsonRx;
}
else if (type.ToLower().Equals("login-kyc"))
{
LocateBusiness locateBusiness = new LocateBusiness();
var r = locateBusiness.LoadKycStaticData();
if (r != null)
{
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = r;
Log.Debug("LoadFormStaticData-login-kyc | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("LoadFormStaticData | Returning null while calling DB");
jsonRx.SetResponse("1", "Error occured", null);
return jsonRx;
}
Log.Debug("LoadFormStaticData | Error occurred while specifying the type, Type mismatch error.");
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while loading static data for." + type);
return jsonRx;
}
}
public JsonRxResponse SaveReceiver(ReceiverModel model, string userId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx.SetResponse("1", "error");
var receiver = _requestServices.SaveReceiver(model, userId);
Log.Debug("SaveReceiver | DB RESPONSE : " + JsonConvert.SerializeObject(receiver));
if (!receiver.ErrorCode.Equals("0"))
{
jsonRx.SetResponse("1", receiver.Msg);
jsonRx.Data = null;
return jsonRx;
}
jsonRx.SetResponse("0", "success");
jsonRx.Data = receiver;
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while saving the receiver details.");
jsonRx.Data = null;
return jsonRx;
}
}
public JsonRxResponse GetReceiverDetail(string id)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx.SetResponse("1", "No receiver", null);
var receiver = _requestServices.GetReceiverDetail(id);
Log.Debug("GetReceiverDetail | DB RESPONSE : " + JsonConvert.SerializeObject(receiver));
if (receiver != null)
{
jsonRx.SetResponse("0", "Success", null);
jsonRx.Data = receiver;
}
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while fetching the specific receiver details.");
return jsonRx;
}
}
public JsonRxResponse GetReceiversByCustomer(string customer, string customerId, string search)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx.SetResponse("1", "No receiver", null);
var ls = _requestServices.GetReceiversByCustomer(customer, search);
List<AccountDetails> lsAccount = GetCustomerPaymentMethods(customerId);
LoadReceiverAccount lra = new LoadReceiverAccount();
lra.AccountList = lsAccount;
lra.Receivers = ls;
if (lra == null)
{
Log.Debug("GetReceiversByCustomer | Returning null while fetching the list of receivers.");
return jsonRx;
}
jsonRx.SetResponse("0", ls.Count.ToString() + " receiver", null);
jsonRx.Data = lra;
Log.Debug("GetReceiversByCustomer | DB RESPONSE AFTER PARSING : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while fetching the list of receivers.");
return jsonRx;
}
}
public JsonRxResponse RemoveReceiver(string userId, string receiverId)
{
JsonRxResponse res = new JsonRxResponse();
try
{
res = _requestServices.RemoveReceiver(userId, receiverId);
Log.Debug("RemoveReceiver | DB RESPONSE : " + JsonConvert.SerializeObject(res));
if (res.ErrorCode == "0")
{
return res;
}
Log.Debug("RemoveReceiver | Error occurred while deleting the receiver." + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while removing the receiver.");
return res;
}
}
public JsonRxResponse LoadKycStaticData(string type)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var kycStaticData = _requestServices.LoadKycStaticData(type);
if (kycStaticData != null)
{
jsonRx.SetResponse("0", "Success");
jsonRx.Data = kycStaticData;
Log.Debug("LoadKycStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("LoadKycStaticData | Returning null while fetching from DB.");
jsonRx.SetResponse("1", "Cound not fetch the data.");
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Cound not fetch the data.");
return jsonRx;
}
}
public JsonRxResponse GenerateReceipt(string tranId, string notice = "N")
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var tranResponse = _requestServices.GenerateReceipt(tranId, notice);
if (tranResponse != null)
{
jsonRx.SetResponse("0", "Success");
jsonRx.Data = tranResponse;
Log.Debug("GenerateReceipt | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("GenerateReceipt | Returning null while fetching the receipt details.");
//jsonRx.SetResponse("1", "Unable to fetch the receipt details.");
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.GET_BRANCH_INFOS_SUCCESS.ToString(), lang);
return new JsonRxResponse { Msg = map.Message };
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Unable to fetch the receipt details.");
return jsonRx;
}
}
public JsonRxResponse GetNotificationList(string customerId)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.GetNotificationList(customerId);
Log.Debug("GetNotificationList | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while loading notification.");
return jsonRx;
}
}
public JsonRxResponse UpdateNotification(string rowId)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.UpdateNotification(rowId);
Log.Debug("UpdateNotification | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while loading notification.");
return jsonRx;
}
}
public JsonRxResponse GetTransactionHistory(DateFilterParams search, string userId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
if (search == null)
{
search = new DateFilterParams();
}
try
{
jsonRx.SetResponse("1", "No transaction details found.");
var litranHistoryResponse = _requestServices.GetTransactionHistory(search, userId);
if (litranHistoryResponse == null)
{
Log.Debug("GetTransactionHistory | Returning null while fetching the list of transaction details.");
return jsonRx;
}
jsonRx.SetResponse("0", litranHistoryResponse.Count.ToString() + " paid txn");
jsonRx.Data = litranHistoryResponse;
Log.Debug("GetTransactionHistory | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.GET_TRANSACTION_HISTORY_FAIL.ToString(), lang);
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", map.Message);
return jsonRx;
}
}
public JsonRxResponse OldUserRegister(OldUserRegisterModel oldUserRegister)
{
//var lang ="EN";
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse res = new JsonRxResponse();
try
{
string pwd = oldUserRegister.Password;
string txnPwd = oldUserRegister.TxnPin;
string Confirmpwd = oldUserRegister.ConfirmPassword;
string txnConfirmpwd = oldUserRegister.ConfirmTxnPin;
string enumString = string.Empty;
if (!oldUserRegister.UserId.IsValidEmail())
{
Log.Debug("OldUserRegister.IsValidatedForm | Validate Email : Failed " + Convert.ToString(oldUserRegister.UserId));
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_7.ToString(), lang);
res.SetResponse("1", map.Message);
return res;
}
if (pwd != Confirmpwd)
{
// res.SetResponse("1", "Password does not match with confirm password");
enumString = RESPONSE_MSG.OLD_USER_REGISTER_FAIL_8.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("1", map.Message);
}
var verifyPwdResp = ValidatePassword(Confirmpwd);
Log.Debug("OldUserRegister.IsValidPassword | RESPONSE : " + JsonConvert.SerializeObject(verifyPwdResp));
if (verifyPwdResp.ErrorCode != "0")
{
return verifyPwdResp;
}
if (txnPwd != txnConfirmpwd)
{
// res.SetResponse("1", "Txn pin does not match with confirm txn pin");
enumString = RESPONSE_MSG.OLD_USER_REGISTER_FAIL_9.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("1", map.Message);
// return new JsonRxResponse { ErrorCode = "1", Msg = map.Message };
// var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_9.ToString(), lang);
// res.SetResponse("1", map.Message);
return res;
}
if (string.IsNullOrWhiteSpace(txnPwd) || string.IsNullOrWhiteSpace(txnConfirmpwd))
{
//res.SetResponse("1", "Txn pin is missing");
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_10.ToString(), lang);
res.SetResponse("1", map.Message);
return res;
}
if (txnPwd.Length < 6)
{
// res.SetResponse("1", "Txn pin cannot be less than 6 characters");
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang);
res.SetResponse("1", map.Message);
return res;
}
res = _requestServices.OldUserRegister(oldUserRegister);
Log.Debug("OldUserRegister | DB RESPONSE : " + JsonConvert.SerializeObject(res));
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while registering the customer.");
return res;
}
}
private JsonRxResponse ValidatePassword(string confirmpwd)
{
JsonRxResponse _resp = new JsonRxResponse() { ErrorCode = "0", Msg = "Success" };
if (string.IsNullOrEmpty(confirmpwd))
{
_resp.SetResponse("100", "Password can not be empty!");
return _resp;
}
if (confirmpwd.Length < 6)
{
_resp.SetResponse("100", "Password must be of atleast 6 digits!");
return _resp;
}
//if (!Regex.Match(confirmpwd, @"\d+").Success)
//{
// _resp.SetResponse("1", "Password must contain 1 number!");
// return _resp;
//}
//if (!Regex.Match(confirmpwd, @"[A-Z]").Success)
//{
// _resp.SetResponse("1", "Password must contain atleaset one capital letter!");
// return _resp;
//}
//if (!Regex.Match(confirmpwd, @"[!@#$%&*_+\-]").Success)
//{
// _resp.SetResponse("1", "Password must contain atleaset one special character!");
// return _resp;
//}
return _resp;
}
private JsonRxResponse CalculateAge(string dob)
{
JsonRxResponse _resp = new JsonRxResponse() { ErrorCode = "0", Msg = "Success" };
if (DateTime.TryParse(dob, out DateTime dateOfBirth))
{
DateTime today = DateTime.Today;
int age = today.Year - dateOfBirth.Year;
if (dateOfBirth.Date > today.AddYears(-age))
age--;
if (age < 18)
{
_resp.SetResponse("100", "User must me at least 18 years old to register with IME London!");
return _resp;
}
}
return _resp;
}
public JsonRxResponse NewUserRegister(NewUserRegisterModel newUserRegister)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse res = new JsonRxResponse();
try
{
string pwd = newUserRegister.Password;
string Confirmpwd = newUserRegister.ConfirmPassword;
string enumString = string.Empty;
string dob = newUserRegister.DOB;
if (!newUserRegister.UserId.IsValidEmail())
{
enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_4.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("100", map.Message);
return res;
}
if (string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(Confirmpwd))
{
enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_6.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("100", map.Message);
return res;
}
if (!String.Equals(pwd, Confirmpwd, StringComparison.CurrentCulture))
{
enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_5.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("100", map.Message);
return res;
}
var verifyPwdResp = ValidatePassword(Confirmpwd);
Log.Debug("NewUserRegister.IsValidPassword | RESPONSE : " + JsonConvert.SerializeObject(verifyPwdResp));
if (verifyPwdResp.ErrorCode != "0")
{
return verifyPwdResp;
}
var calculateAge = CalculateAge(dob);
if (calculateAge.ErrorCode != "0")
{
Log.Debug("NewUserRegister.IsNotValidAge | RESPONSE : " + JsonConvert.SerializeObject(calculateAge));
return calculateAge;
}
//var calculateAge = CalculateAge(dob);
Log.Debug("NewUserRegister.IsValidAge | RESPONSE : " + JsonConvert.SerializeObject(calculateAge));
if (calculateAge.ErrorCode != "0")
{
return calculateAge;
}
newUserRegister.MobileNumber = newUserRegister.MobileNumber.getUKFormattedNumber();
res = _requestServices.NewUserRegister(newUserRegister);
Log.Debug("NewUserRegister | completed with db response. " + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while registering the customer.");
return res;
}
}
public JsonRxResponse OldUserAccessRequest(OldUserAccessRequestModel oldUserAccessRequest)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse res = new JsonRxResponse();
string enumString = string.Empty;
try
{
if (!Utilities.ConvertToGlobalFormat(oldUserAccessRequest.Dob))
{
Log.DebugFormat("OldUserAccessRequest.IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(oldUserAccessRequest.Dob));
res.SetResponse("1", "Please input your dob in correct format.");
return res;
}
if (!oldUserAccessRequest.IdNumber.IsValidNumber())
{
enumString = RESPONSE_MSG.OLD_USER_ACCESS_REQUEST_FAIL_4.ToString();
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("1", map.Message);
return res;
}
res = _requestServices.OldUserAccessRequest(oldUserAccessRequest);
Log.Debug("OldUserAccessRequest | DB RESPONSE : " + JsonConvert.SerializeObject(res));
if (res.ErrorCode == "0")
{
res.Data = new
{
referenceId = res.Id,
generatedUserId = res.Extra
};
}
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while registering the customer.");
return res;
//var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_ACCESS_REQUEST_FAIL_1.ToString(), lang);
// return new JsonRxResponse { ErrorCode ="1", Msg = map.Message}; ;
}
}
public JsonRxResponse RegisterCustomer(CustomerRegisterParameters registerParam)
{
Log.Debug("RegisterCustomer | user trying to sign-up the system." + JsonConvert.SerializeObject(registerParam));
JsonRxResponse res = new JsonRxResponse();
try
{
if (!Utilities.ConvertToGlobalFormat(registerParam.Dob))
{
Log.DebugFormat("IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(registerParam.Dob));
res.SetResponse("1", "Please input your dob in correct format.");
return res;
}
//string pwd = StringExtension.ToVirtualKeyDecryptString(registerParam.Password);
string pwd = registerParam.Password;
//string Confirmpwd = StringExtension.ToVirtualKeyDecryptString(registerParam.ConfirmPassword);
string Confirmpwd = registerParam.ConfirmPassword;
if (pwd != Confirmpwd)
{
res.SetResponse("1", "Password does not match with confirm password");
return res;
}
if (string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(Confirmpwd))
{
res.SetResponse("1", "Password is missing");
return res;
}
if (pwd.Length < 6)
{
res.SetResponse("1", "Password cannot be less than 6 characters");
return res;
}
var regData = new ValidationModel
{
Dob = registerParam.Dob,
Email = registerParam.Username,
Password = pwd,
ConfirmPassword = Confirmpwd
};
registerParam.Password = pwd;
registerParam.ConfirmPassword = Confirmpwd;
res = _requestServices.RegisterCustomer(registerParam);
if (res.ErrorCode == "0")
{
Log.Debug("RegisterCustomer | Register Customer Success...");
if (registerParam.Username.IsValidEmail())
{
//EmailParameters _emailParams = new EmailParameters()
//{
// To = registerParam.Username,
// MsgSubject = "Customer Registration Sign Up",
// MsgBody = "Dear " + registerParam.Username + ",<br/>Thank you for registering, You are now successfully enrolled to the GME Remittance System."
//};
//Task.Run(() => GetStatic.SendEmail(_emailParams));
}
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
Task.Run(() => FcmNotifier.Notify(registerParam.fcmId, Languages.GetMessage("registration_success", lang), Languages.GetTitle("registration", lang)));
return res;
}
Log.Debug("RegisterCustomer | Error occurred while registering the customer." + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while registering the customer.");
return res;
}
}
public JsonRxResponse CheckInfoAgree(string username)
{
JsonRxResponse res = new JsonRxResponse();
try
{
res = _requestServices.CheckInfoAgree(username);
Log.Debug("CheckInfoAgree | DB RESPONSE : " + JsonConvert.SerializeObject(res));
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while password reset.");
return res;
}
return res;
}
public JsonRxResponse CustomerInfoAgree(string username, string agreeYn)
{
JsonRxResponse res = new JsonRxResponse();
try
{
if (string.IsNullOrEmpty(agreeYn))
{
return new JsonRxResponse { ErrorCode = "1", Msg = "The invalid agreeYn flag.", Id = username };
}
if (agreeYn.Equals("Y"))
{
// return new JsonRxResponse { ErrorCode = "1", Msg = "The user has not agreeded to the terms.", Id = username };
res = _requestServices.CustomerInfoAgree(username, "agree");
if (res.ErrorCode.Equals("0"))
{
// _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id);
res.Msg = "Thank you for completing your profile. You can now start sending transactions";
SendNotificationRequest pushNotificationRequest = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = username,
ProcessId = Guid.NewGuid().ToString(),
ProviderId = "CustomerInfoAgree",
NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(),
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel() { Address = res.Extra, NotificationContent = new NotificationDTO() }
},
Language = Convert.ToString(CallContext.GetData(Constants.Language))
};
//Task.Run(() => NotifierV2.SendNotification(pushNotificationRequest, NOTIFICATION_TYPE.PUSH_NOTIFICATION));
//SendNotificationRequest emailNotificationRequest = new SendNotificationRequest()
//{
// IsBulkNotification = false,
// UserName = username,
// ProcessId = Guid.NewGuid().ToString(),
// ProviderId = "CustomerInfoAgree",
// NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
// Template = Common.Model.Enum.NotifyTemplate.KYC_VERIFICATION_EMAIL,
// Recipients = new List<RecipientViewModel>()
// {
// new RecipientViewModel() { Address= res.Extra , NotificationContent = new NotificationDTO() }
// },
// Language = Convert.ToString(CallContext.GetData(Constants.Language))
//};
//Task.Run(() => NotifierV2.SendNotification(emailNotificationRequest, NOTIFICATION_TYPE.EMAIL));
}
Log.Debug("CustomerInfoAgree.Agree | DB RESPONSE : " + JsonConvert.SerializeObject(res));
}
//else if (agreeYn.Equals("N"))
//{
// res = _requestServices.CustomerInfoAgree(username, "agree-manual");
// Log.Debug("CustomerInfoAgree.Manual | DB RESPONSE : " + JsonConvert.SerializeObject(res));
//}
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred CustomerInfoAgree.");
return res;
}
return res;
}
public JsonRxResponse ResetPassword(PasswordReset pwdReset, string processId = "")
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse res = new JsonRxResponse();
try
{
if (!Utilities.ConvertToGlobalFormat(pwdReset.Dob))
{
Log.DebugFormat("ResetPassword.IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(pwdReset.Dob));
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.INVALID_DOB_FOR_RESETPASSWORD.ToString(), lang);
res.SetResponse("1", map.Message);
return res;
}
DateTime dateTime;
if (DateTime.TryParseExact(pwdReset.Dob, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime))
{
pwdReset.Dob = dateTime.ToString("yyyy-MM-dd");
}
if (!pwdReset.Username.IsValidEmail())
{
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.INVALID_EMAIL_FOR_RESETPASSWORD.ToString(), lang);
res.SetResponse("1", map.Message);
return res;
};
// var randomPassword = PasswordGenerator.GenerateRandomPassword();
var randomPassword = Utilities.GenerateRandomPin();
pwdReset.RandomPassword = randomPassword;
res = _requestServices.ResetPassword(pwdReset);
Log.Debug("ResetPassword | DB RESPONSE : " + JsonConvert.SerializeObject(res));
if (res.ErrorCode == "0")
{
bool emailSent = false;
bool smsSent = false;
try
{
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = res.Extra2 });
bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = pwdReset.Username });
bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword });
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = pwdReset.Username,
ProcessId = processId,
ProviderId = "ResetPassword",
NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= pwdReset.Username
}
}
};
Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
var resEmail = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(resEmail));
emailSent = true;
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms";
var mobileNo = "";
if (!string.IsNullOrEmpty(res.Extra3))
{
mobileNo = getSenderFormattedNumber(res.Extra3);
SendSMSApiService _sendAPI = new SendSMSApiService();
StringBuilder s = new StringBuilder();
s.AppendLine($"Dear { res.Extra2}");
s.AppendLine($"We received your password reset request and your new credentials are");
s.AppendLine($"Login ID: { pwdReset.Username}");
s.AppendLine($"Password: { pwdReset.RandomPassword}");
s.AppendLine("Regards, IME London");
SMSRequestModel _req = new SMSRequestModel
{
ProviderId = "onewaysms",
MobileNumber = mobileNo,
SMSBody = s.ToString(),
ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
RequestedBy = pwdReset.Username,
UserName = pwdReset.Username,
method = "send",
ControlNo = "", // GetControlNo()
};
Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
smsSent = true;
}
}
catch (Exception ex)
{
Log.Error("ResetPassword.SendNotification", ex);
}
if (emailSent || smsSent)
{
res.ErrorCode = "0";
res.SetResponse("0", "Reset password email/sms has been sent.");
return res;
}
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.SEND_EMAIL_FOR_RESETPASSWORD_SUCCESS.ToString(), lang);
return new JsonRxResponse { ErrorCode = "0", Msg = map.Message };
// return res;
}
return res;
}
catch (Exception ex)
{
Log.Error("ResetPassword", ex);
res.SetResponse("1", "Error occurred while password reset.");
return res;
}
}
public JsonRxResponse RefreshCustomerInformation(UserModel user)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.RefreshCustomerInformation(user);
Log.Debug("RefreshCustomerInformation | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling the refresh customer information.");
return jsonRx;
}
}
public JsonRxResponse GetWalletStatement(DateFilterParams search, string userId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
if (search == null)
{
search = new DateFilterParams();
}
try
{
//jsonRx.SetResponse("0", "No wallet statement found.");
var liWalletStmtResponse = _requestServices.GetWalletStatement(search, userId);
if (liWalletStmtResponse == null)
{
jsonRx.ErrorCode = "1";
jsonRx.Msg = "No Record(s) Found!";
jsonRx.Data = new System.Collections.ArrayList();
Log.Debug("GetWalletStatement | Returning null while fetching the list of wallet statements.");
return jsonRx;
}
jsonRx.ErrorCode = "0";
jsonRx.Data = liWalletStmtResponse;
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while fetching the list of transaction details.");
return jsonRx;
}
}
public JsonRxResponse ChangePassword(ChangePassword changePwd)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.ChangePassword(changePwd);
Log.Debug("ChangePassword | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not change the password.");
return jsonRx;
}
}
public List<AccountDetails> GetCustomerPaymentMethods(string customerId)
{
List<AccountDetails> lsAccount = _requestServices.GetPaymentAccountsByCustomer(customerId);
lsAccount.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
return lsAccount;
}
public JsonRxResponse RealtimeValidation(RealtimeValidationModel model, string lang = "")
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
if (string.IsNullOrEmpty(model.IdNumber))
{
jsonRx.ErrorCode = "1";
var map = Utilities.GetLanguageMapping(!string.IsNullOrEmpty(model.IdType) && model.IdType.Equals(ID_TYPE.DRIVING_LICENCE.ToString()) ?
RESPONSE_MSG.VALIDATION_FAIL_6.ToString() : RESPONSE_MSG.VALIDATION_FAIL_3.ToString(), lang);
jsonRx.Msg = map.Message;
return jsonRx;
}
if (!string.IsNullOrEmpty(model.IdType))
{
if (string.IsNullOrEmpty(model.FullName))
{
jsonRx.ErrorCode = "1";
jsonRx.Msg = "Full Name is required";
return jsonRx;
}
if (!string.IsNullOrEmpty(model.FullName))
{
if (!Regex.IsMatch(model.FullName, "^[A-Za-z]+[A-Za-z ]*$"))
{
jsonRx.ErrorCode = "1";
jsonRx.Msg = "Invalid Full name ";
return jsonRx;
}
}
if (string.IsNullOrEmpty(model.DOB))
{
jsonRx.ErrorCode = "1";
jsonRx.Msg = "DOB is empty.";
return jsonRx;
}
if (!string.IsNullOrEmpty(model.DOB))
{
DateTime data = new DateTime();
if (!DateTime.TryParse(model.DOB, out data))
{
jsonRx.ErrorCode = "1";
jsonRx.Msg = "Invalid DOB Format";
return jsonRx;
}
else
{
if (!Utilities.ConvertToGlobalFormat(model.DOB))
{
model.DOB = DateTime.Now.ToString("yyyyyMMdd");
}
else
model.DOB = data.ToString("yyyyyMMdd");
}
}
}
if (!string.IsNullOrEmpty(model.IdType) && model.IdType.Equals(ID_TYPE.DRIVING_LICENCE.ToString()))
{
if (!model.IdNumber.IsValidDrivingNumber())
{
jsonRx.ErrorCode = "1";
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.VALIDATION_FAIL_5.ToString(), lang);
jsonRx.Msg = map.Message;
return jsonRx;
}
}
else if (!model.IdNumber.IsValidNumber())
{
jsonRx.ErrorCode = "1";
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.VALIDATION_FAIL_4.ToString(), lang);
jsonRx.Msg = map.Message;
return jsonRx;
}
jsonRx = _requestServices.RealtimeValidation(model);
return jsonRx;
}
catch (Exception ex)
{
Log.Error("RealtimeValidation Error", ex);
jsonRx.SetResponse("1", "Could not perform realtime validation.");
return jsonRx;
}
}
public JsonRxResponse GetCDDI(string userId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.GetCDDI(userId);
Log.Debug("GetCDDI | DB RESPONSE: " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("GetCDDI | EXCEPTION: ", ex);
jsonRx.SetResponse("1", "Error occurred while fetching the CDDI Info.");
return jsonRx;
}
}
public JsonRxResponse DynamicReceiverField(DynamicReceiverRequest dynamicReceiverRequest, string customerId)
{
var jsonResult = _requestServices.DynamicReceiverField(dynamicReceiverRequest, customerId);
if (jsonResult.ErrorCode == "0")
{
Log.Debug("Dynamic ReceiverField success.");
}
else
{
Log.Debug("Dynamic ReceiverField failed.");
}
return jsonResult;
}
public JsonRxResponse GetReceiverInformation(string customerId)
{
var jsonResult = _requestServices.GetReceiverInformation(customerId);
if (jsonResult.ErrorCode == "0")
{
Log.Debug("receiver ReceiverField success.");
var reciver = jsonResult.Data;
List<AccountDetails> lsAccount = null;//GetCustomerPaymentMethods(customerId);
jsonResult.Data = new { Receivers = reciver, accounts = lsAccount };
}
else
{
Log.Debug("GetReceiverInformation | RESPONSE: " + JsonConvert.SerializeObject(jsonResult));
}
return jsonResult;
}
public JsonRxResponse AddReceiver(string customerId, ReceiverInfoModel receiver)
{
var jsonResult = new JsonRxResponse();
try
{
if (receiver.deviceType.ToLower().Equals("ios"))
{
List<DymanicField> dymanicFields = new List<DymanicField>();
List<ReceiverField> list = new List<ReceiverField>();
var dt = _requestServices.GetReceiverFields(receiver);
if (dt != null)
{
foreach (DataRow item in dt.Rows)
{
list.Add(new ReceiverField()
{
Field = findMapString(item["field"].ToString()),
FieldRequired = item["fieldRequired"].ToString(),
MinLength = int.Parse(item["minFieldLength"].ToString()),
MaxLength = int.Parse(item["maxFieldLength"].ToString())
});
}
}
var props = Utilities.GetPropertiesNameOfClass(receiver);
var requiredList = props.Where(x => list.Any(z => x.Key.ToLower() == z.Field.ToLower()))
.Where(y => string.IsNullOrEmpty(y.Value)).ToList(); // case when Field Value empty
//var pLength = props.SingleOrDefault(p => p.Key.ToLower().Equals("mobile")).Value.Length;
//var rLength = list.SingleOrDefault(p => p.Field.ToLower().Equals("mobile")).MinLength;
//if (pLength < rLength)
// requiredList.Add(new KeyValuePair() { Key = "mobile" });
if (requiredList.Count > 0)
{
// string.Format("Required Fields:-" , string.Join(", ", requiredList.Select(x => x.Key).ToList()));
jsonResult.SetResponse("100", string.Format("Required Fields:-\r\n{0}", string.Join("\r\n", requiredList.Select(x => findMapKeyValue(x.Key)).ToList())));
return jsonResult;
}
}
if (!string.IsNullOrWhiteSpace(receiver.fullName))
{
var str = receiver.fullName.Split(' ');
if (str.Length.Equals(2))
{
receiver.firstName = str[0];
receiver.lastName = str[1];
}
else if (str.Length > 2)
{
receiver.firstName = str[0];
receiver.middleName = str[1];
var ls = "";
for (int i = 2; i < str.Length; i++)
{
ls = (ls + str[i] + " ").Trim();
}
receiver.lastName = ls;
}
else
{
receiver.firstName = receiver.fullName;
}
}
if (receiver.countryId == "16")
{
//JsonRxResponse rxResponse = new JsonRxResponse() { ErrorCode = "0", Extra2 = receiver.mobile };
//string mobileFirst = receiver.mobile.Substring(0, 1);
string MobN = receiver.mobile.Substring(4, 1);
if (MobN == "0")
{
if (receiver.mobile.Length < 14)
{
jsonResult.ErrorCode = "1";
jsonResult.Msg = "Invalid Mobile Number provided!";
return jsonResult;
}
else if (receiver.mobile.Length > 14)
{
jsonResult.ErrorCode = "1";
jsonResult.Msg = "Invalid Mobile Number length provided!";
return jsonResult;
}
}
}
if (receiver.payoutPartner == "394130" && receiver.paymentMethod.id == "13" && receiver.country == "BANGLADESH")
{
var mobileNumberValidate = Regex.Replace(receiver.agent.accountNo, @"[^\d]", "");
var countryCode = mobileNumberValidate.Substring(0, 3);
if (countryCode != "880")
{
jsonResult.SetResponse("1", "Invalid country code passed in BKash Wallet Number!");
return jsonResult;
}
if (mobileNumberValidate.Length != 13)
{
jsonResult.SetResponse("1", "Invalid BKash Wallet Number!");
return jsonResult;
}
}
if (receiver.payoutPartner == "394434")
{
var mobileNumberValidate = Regex.Replace(receiver.mobile, @"[^\d]", "");
mobileNumberValidate = mobileNumberValidate.Replace("855", "");
var countryCode = mobileNumberValidate.Substring(0, 1);
if (countryCode != "0")
{
jsonResult.SetResponse("1", "Invalid Cambodia Number format!");
return jsonResult;
}
if (mobileNumberValidate.Length < 9 | mobileNumberValidate.Length > 12)
{
jsonResult.SetResponse("1", "Invalid Cambodia Number Length!");
return jsonResult;
}
}
//if (receiver.address.Contains("@") && receiver.address.IsValidEmail())
//{
// jsonResult.SetResponse("1", "Please input valid receiver address!");
// return jsonResult;
//}
jsonResult = _requestServices.AddReceiver(customerId, receiver);
if (jsonResult.ErrorCode == "0")
{
var rec = _requestServices.GetReceiver(customerId, jsonResult.Id);
jsonResult.Data = rec;
Log.DebugFormat("AddReceiver | RESPONSE : {0}", JsonConvert.SerializeObject(jsonResult));
}
else
{
Log.Debug("receiver ReceiverField failed. | " + JsonConvert.SerializeObject(jsonResult));
}
}
catch (Exception ex)
{
Log.Error("AddReceiver", ex);
jsonResult.SetResponse("1", "Something Went Wrong, Please Try Again!!");
return jsonResult;
}
return jsonResult;
}
private Dictionary<string, string> GetmappingList()
{
Dictionary<string, string> mapping = new Dictionary<string, string>();
mapping.Add("Bank Name", "agent.id");
mapping.Add("Account No.", "agent.accountNo");
mapping.Add("Full Name", "fullName");
mapping.Add("First Name", "firstName");
mapping.Add("Middle Name", "middleName");
mapping.Add("Last Name", "lastName");
mapping.Add("Mobile Number", "mobile");
mapping.Add("City", "city");
mapping.Add("Address", "address");
mapping.Add("District", "district");
mapping.Add("Province", "state");
mapping.Add("Branch Name", "agent.branch.id");
mapping.Add("Id Type", "idType");
mapping.Add("ID Number", "idNumber");
mapping.Add("Realation Group", "relationship");
mapping.Add("Native Country", "nativeCountry");
// mapping.Add("Transfer Reason", "transferReason");
return mapping;
}
private string findMapString(string s)
{
string result = string.Empty;
var d = GetmappingList();
if (d.ContainsKey(s))
{
result = d.FirstOrDefault(x => x.Key.Equals(s)).Value;
}
return result;
}
private string findMapKeyValue(string s)
{
string result = string.Empty;
var d = GetmappingList();
if (d.ContainsValue(s))
{
result = d.FirstOrDefault(x => x.Value.Equals(s)).Key;
}
return result.Replace("Realation Group", "Relationship");
}
public JsonRxResponse ModifyReceiver(string customerId, string receiverId, ReceiverInfoModel receiver)
{
var jsonResult = new JsonRxResponse();
try
{
if (receiver.deviceType.ToLower().Equals("ios"))
{
List<DymanicField> dymanicFields = new List<DymanicField>();
List<ReceiverField> list = new List<ReceiverField>();
var dt = _requestServices.GetReceiverFields(receiver);
if (dt != null)
{
foreach (DataRow item in dt.Rows)
{
list.Add(new ReceiverField()
{
Field = findMapString(item["field"].ToString()),
FieldRequired = item["fieldRequired"].ToString(),
MinLength = int.Parse(item["minFieldLength"].ToString()),
MaxLength = int.Parse(item["maxFieldLength"].ToString())
});
}
}
var props = Utilities.GetPropertiesNameOfClass(receiver);
var requiredList = props.Where(x => list.Any(z => x.Key.ToLower() == z.Field.ToLower()))
.Where(y => string.IsNullOrEmpty(y.Value)).ToList(); // case when Field Value empty
//var pLength = props.SingleOrDefault(p => p.Key.ToLower().Equals("mobile")).Value.Length;
//var rLength = list.SingleOrDefault(p => p.Field.ToLower().Equals("mobile")).MinLength;
//if (pLength < rLength)
// requiredList.Add(new KeyValuePair() { Key = "mobile" });
if (requiredList.Count > 0)
{
// string.Format("Required Fields:-" , string.Join(", ", requiredList.Select(x => x.Key).ToList()));
jsonResult.SetResponse("1", string.Format("Required Fields:- {0}", string.Join(", ", requiredList.Select(x => findMapKeyValue(x.Key)).ToList())));
Log.Debug($"Receiver modify validation failed. { JsonConvert.SerializeObject(jsonResult)}");
return jsonResult;
}
}
if (!string.IsNullOrWhiteSpace(receiver.fullName))
{
var str = receiver.fullName.Split(' ');
if (str.Length.Equals(2))
{
receiver.firstName = str[0];
receiver.lastName = str[1];
}
else if (str.Length > 2)
{
receiver.firstName = str[0];
receiver.middleName = str[1];
var ls = "";
for (int i = 2; i < str.Length; i++)
{
ls = (ls + str[i] + " ").Trim();
}
receiver.lastName = ls;
}
else
{
receiver.firstName = receiver.fullName;
}
}
if (receiver.countryId == "16")
{
string MobN = receiver.mobile.Substring(4, 1);
if (MobN == "0")
{
if (receiver.mobile.Length < 14)
{
jsonResult.ErrorCode = "1";
jsonResult.Msg = "Invalid Mobile Number provided!";
return jsonResult;
}
else if (receiver.mobile.Length > 14)
{
jsonResult.ErrorCode = "1";
jsonResult.Msg = "Invalid Mobile Number length provided!";
return jsonResult;
}
}
}
if (receiver.payoutPartner == "394130" && receiver.paymentMethod.id == "13" && receiver.country == "BANGLADESH")
{
var mobileNumberValidate = Regex.Replace(receiver.agent.accountNo, @"[^\d]", "");
var countryCode = mobileNumberValidate.Substring(0, 3);
if (countryCode != "880")
{
jsonResult.SetResponse("1", "Invalid country code passed in BKash Wallet Number!");
return jsonResult;
}
if (mobileNumberValidate.Length != 13)
{
jsonResult.SetResponse("1", "Invalid BKash Wallet Number!");
return jsonResult;
}
}
if (receiver.payoutPartner == "394434")
{
var mobileNumberValidate = Regex.Replace(receiver.mobile, @"[^\d]", "");
mobileNumberValidate = mobileNumberValidate.Replace("855", "");
var countryCode = mobileNumberValidate.Substring(0, 1);
//if (countryCode != "0")
//{
// jsonResult.SetResponse("1", "Invalid Cambodia Number format!");
// return jsonResult;
//}
if (mobileNumberValidate.Length < 9 | mobileNumberValidate.Length > 12)
{
jsonResult.SetResponse("1", "Invalid Cambodia Number Length!");
return jsonResult;
}
}
jsonResult = _requestServices.ModifyReceiver(customerId, receiverId, receiver);
if (jsonResult.ErrorCode == "0")
{
Log.Debug($"receiver modified success. { JsonConvert.SerializeObject(jsonResult)}");
var rec = _requestServices.GetReceiver(customerId, jsonResult.Id);
jsonResult.Data = rec;
}
else
{
Log.Debug($"receiver modified failed. { JsonConvert.SerializeObject(jsonResult)}");
}
}
catch (Exception ex)
{
Log.Error("ModifyReceiver", ex);
jsonResult.SetResponse("1", "Something Went Wrong, Please Try Again!!");
return jsonResult;
}
return jsonResult;
}
public JsonRxResponse GetCountryServiceTypeList()
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var listCountriesServices = _requestServices.GetCountryServiceTypeList();
if (listCountriesServices == null || listCountriesServices.Count < 1)
{
Log.Debug("GetCountriesServices | Returning null while calling the GetCountriesServices to fetch the countries services.");
jsonRx.SetResponse("1", "Could not fetch the exrate data.");
return jsonRx;
}
jsonRx.SetResponse("0", "Success");
//var path = GetStatic.ReadWebConfig("ServiceType_Resource", "");
//var text = File.ReadAllText(path);
//List<ServiceTypeDetails> sd = JsonConvert.DeserializeObject<List<ServiceTypeDetails>>(text);
//line commented by arjun
//foreach (var item in listCountriesServices)
//{
// foreach (var countryName in item.countryName)
// {
// var lang = CallContext.GetData("lang").ToString();
// if (string.IsNullOrWhiteSpace(lang))
// {
// lang = "en";
// }
// foreach (var product in item.servicetypeAvailable) { var country =
// item.countryName ?? "English";
// var idx = sd.FindIndex(x => x.countryCode.ToLower() == lang.ToLower());
// var data = new ServiceTypeDetails(); if (idx < 0) { data = sd[sd.FindIndex(x =>
// x.countryCode == "en")]; } else { data = sd[idx]; }
// if (product.text.ToLower().Equals("Cash Payment".ToLower()))
// {
// product.description = data.cashPayment;
// }
// else if (product.text.ToLower().Equals("Bank Deposit".ToLower()))
// {
// product.description = data.bankDeposit;
// }
// else if (product.text.ToLower().Equals("Mobile Wallet".ToLower()))
// {
// product.description = data.mobileWallet;
// }
// else if (product.text.ToLower().Equals("Home Delivery".ToLower()))
// {
// product.description = data.homeDelivery;
// }
// else if (product.text.ToLower().Equals("Card Payment".ToLower()))
// {
// product.description = data.cardPayment;
// }
// }
// }
//}
jsonRx.Data = listCountriesServices;
Log.Debug("GetCountriesServices | Calling GetCountriesServices Success...");
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Could not fetch the countries service details.");
return jsonRx;
}
}
/* 2019.09 @Dana */
public JsonRxResponse GetDomesticTransactionHistory(DateFilterParams search, string userId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
if (search == null)
{
search = new DateFilterParams();
}
try
{
jsonRx.SetResponse("1", "No transaction details found.");
var litranHistoryResponse = _requestServices.GetDomesticTransactionHistory(search, userId);
if (litranHistoryResponse == null)
{
Log.Debug("GetDomesticTransactionHistory | Returning null while fetching the list of transaction details.");
return jsonRx;
}
jsonRx.SetResponse("0", litranHistoryResponse.Count.ToString() + " remittance txn");
jsonRx.Data = litranHistoryResponse;
Log.Debug("GetDomesticTransactionHistory | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while fetching the list of transaction details.");
return jsonRx;
}
}
public JsonRxResponse GenerateDomesticReceipt(string tranId)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
var tranResponse = _requestServices.GenerateDomesticReceipt(tranId);
if (tranResponse != null)
{
jsonRx.SetResponse("0", "Success");
jsonRx.Data = tranResponse;
Log.Debug("GenerateDomesticReceipt | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug("GenerateDomesticReceipt | Returning null while fetching the receipt details.");
jsonRx.SetResponse("1", "Unable to fetch the Domestic Receipt details.");
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Unable to fetch the Domestic Receipt details.");
return jsonRx;
}
}
//public JsonRxResponse GetCouponList(CouponuserInfo list)
//{
// JsonRxResponse res = new JsonRxResponse();
//// var couponlist = _requestServices.GetCouponList(list.customerId);
//// res.ErrorCode = "0";
//// res.Msg = "SUCCESS";
//// res.Data = couponlist;
// return res;
//}
public JsonRxResponse LoadFormStaticData_V3(string type, string customerId)
{
JsonRxResponse jsonRx = new JsonRxResponse
{
ErrorCode = "1",
Msg = "Error"
};
try
{
if (type.ToLower().Equals("kyc"))
{
KycStaticDataV3 sd = _requestServices.LoadKycStaticData_V3("kycV3", customerId);
if (sd != null)
{
Log.Debug("LoadFormStaticData | DB RESPONSE SUCCESS!");
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = sd;
return jsonRx;
}
Log.Debug("LoadFormStaticData | Returning null while calling LoadFormStaticData to fetch the static data related to " + type);
jsonRx.SetResponse("1", "Error occured", null);
}
else if (type.ToLower().Equals("kycexistingcustomer"))
{
KycStaticDataV3 sd = _requestServices.LoadKycStaticData_V3("kycV3-existing", customerId);
if (sd != null)
{
Log.Debug("LoadFormStaticData | DB RESPONSE SUCCESS!");
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = sd;
return jsonRx;
}
Log.Debug("LoadFormStaticData | Returning null while calling LoadFormStaticData to fetch the static data related to " + type);
jsonRx.SetResponse("1", "Error occured", null);
}
Log.Debug("LoadFormStaticData | Error occurred while specifying the type, Type mismatch error.");
return jsonRx;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while loading static data for." + type);
return jsonRx;
}
}
public JsonRxResponse RegisterKYC_V4()
{
throw new NotImplementedException();
}
public JsonRxResponse GetFieldsByProduct(Common.Model.Config.MappingType type, string customerId, string receiverId, string payoutPartner)
{
JsonRxResponse jsonRx = new JsonRxResponse
{
ErrorCode = "1",
Msg = "Error"
};
try
{
if (type == Common.Model.Config.MappingType.REWARD_TYPE)
{
var response1 = _requestServices.GetRewardDetails(customerId);
if (response1 != null)
{
Log.Debug("GetFieldsByProduct | DB RESPONSE SUCCESS!");
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = response1;
return jsonRx;
}
Log.Debug("GetRewardDetails | DB RESPONSE : " + JsonConvert.SerializeObject(response1));
jsonRx.SetResponse("1", "No Reward Details", null);
return jsonRx;
}
else if (type == Common.Model.Config.MappingType.REWARD_POINT)
{
var response1 = _requestServices.GetRewardFee(customerId);
response1.PaymentOptions = new PaymentOptions() { Options = GetPaymentMethods(receiverId, payoutPartner), HeaderText = "How do you like to pay ?" };
if (response1 != null)
{
Log.Debug("GetFieldsByProduct | DB RESPONSE SUCCESS!");
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = response1;
return jsonRx;
}
Log.Debug("GetRewardFee | DB RESPONSE : " + JsonConvert.SerializeObject(response1));
jsonRx.SetResponse("1", "No Reward Points", null);
return jsonRx;
}
else if (type == Common.Model.Config.MappingType.LOYALTY_POINT)
{
var loayaltyResponse = _requestServices.GetLoyaltyPoint(customerId);
Log.Debug("GetLoyaltyPoint | DB RESPONSE : " + JsonConvert.SerializeObject(loayaltyResponse));
if (loayaltyResponse != null)
{
jsonRx.ErrorCode = "0";
jsonRx.Msg = "success";
jsonRx.Data = loayaltyResponse;
return jsonRx;
}
jsonRx.SetResponse("1", "No Loyalty Points", null);
return jsonRx;
}
else
{
var response = Utilities.GetReferenceMaps(type);
if (response != null)
{
jsonRx.SetResponse("0", "Success");
jsonRx.Data = response;
Log.Debug("GetFieldsByProduct | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
return jsonRx;
}
Log.Debug($"GetFieldsByProduct | Error occurred while specifying the type {Common.Model.Config.MappingType.MODIFICATION_REQUEST}");
return jsonRx;
}
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!", ex);
jsonRx.SetResponse("1", "Error occurred while loading GetFieldsByProduct data for." + type);
return jsonRx;
}
}
public List<Option> GetPaymentMethods(string receiverId, string pcountryid)
{
var paymentMethods = _requestServices.GetPaymentMethod(receiverId, pcountryid);
List<Option> options;
string mappingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["PaymentConfigFilePath"].ToString());
using (StreamReader reader = File.OpenText(mappingPath))
{
var jsonS = reader.ReadToEnd();
options = JsonConvert.DeserializeObject<List<Option>>(jsonS);
}
List<Option> matchingOptions = new List<Option>();
foreach (var paymentMethod in paymentMethods)
{
var matchingOption = options.FirstOrDefault(option => option.Code == paymentMethod.Key);
if (matchingOption != null)
{
matchingOption.Value = paymentMethod.Value;
matchingOptions.Add(matchingOption);
}
}
return matchingOptions;
}
public JsonRxResponse ValidateReferralCode(string referralCode)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = _requestServices.ValidateReferralCode(referralCode);
return jsonRx;
}
catch (Exception ex)
{
Log.Error("ValidateReferralCode Error", ex);
jsonRx.SetResponse("1", "Error occured" + referralCode);
return jsonRx;
}
}
public JsonRxResponse TempUserRegister(TempUserRegisterModel tempUserRegister)
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse res = new JsonRxResponse();
try
{
string fullName = tempUserRegister.FullName;
string mobileNo = tempUserRegister.MobileNumber;
string enumString = string.Empty;
string regStep = tempUserRegister.RegStep;
if (regStep == "1")
{
var ds = _requestServices.GetCustId();
string custId = "";
if (ds.Tables[0].Rows.Count > 0)
{
custId = ds.Tables[0].Rows[0]["tempCustId"]?.ToString();
}
int newCustId = 1;
tempUserRegister.tempCustId = newCustId.ToString();
if (!string.IsNullOrEmpty(custId))
{
newCustId = int.Parse(custId) + 1;
tempUserRegister.tempCustId = newCustId.ToString();
}
}
else if (regStep == "2")
{
if (!tempUserRegister.Email.IsValidEmail())
{
enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_4.ToString(); ;
var map = Utilities.GetLanguageMapping(enumString, lang);
res.SetResponse("100", map.Message);
return res;
}
}
tempUserRegister.MobileNumber = tempUserRegister.MobileNumber.getUKFormattedNumber();
res = _requestServices.TempUserRegister(tempUserRegister);
Log.Debug("TempUserRegister | completed with db response. " + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
return res;
}
catch (Exception ex)
{
Log.Error("Something Went Wrong, Please Try Again!!", ex);
res.SetResponse("1", "Error occurred while registering the customer.");
return res;
}
}
}
}