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.

3120 lines
131 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 months ago
3 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. using Business.KftcPasswordRule;
  2. using System.Linq;
  3. using Business.PennyTest;
  4. using Business.TPApi;
  5. using Common;
  6. using Common.Helper;
  7. using Common.KFTC;
  8. using Common.Language;
  9. using Common.Model;
  10. using Common.Model.Config;
  11. using Common.Model.Customer;
  12. using Common.Model.CustomerRegister;
  13. using Common.Model.Notification;
  14. using Common.Model.Remit;
  15. using Common.Model.RequestOTP;
  16. using log4net;
  17. using Newtonsoft.Json;
  18. using PushNotification;
  19. using Repository.Mobile;
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Data;
  23. using System.IO;
  24. using System.Runtime.Remoting.Messaging;
  25. using System.Text.RegularExpressions;
  26. using System.Threading.Tasks;
  27. using System.Web;
  28. using static Common.Model.DynamicReceiverSetup.DynamicReceiver;
  29. using Notify = Common.Model.Notification;
  30. using System.Collections;
  31. using Repository;
  32. using System.Configuration;
  33. using Business.TrustDoc;
  34. using Business.Addressy;
  35. using System.Text;
  36. namespace Business.Mobile
  37. {
  38. public class MobileServices : IMobileServices
  39. {
  40. private readonly IMobileServicesRepo _requestServices;
  41. private readonly Dao _dao = new Dao();
  42. private static readonly ILog Log = LogManager.GetLogger(typeof(MobileServices));
  43. private readonly PennyTestBusiness _pennyTestBusiness;
  44. private ITrustDocBusiness _trustDocBusiness;
  45. public MobileServices(IMobileServicesRepo requestServices, PennyTestBusiness pennyTestBusiness, ITrustDocBusiness trustDocBusiness)
  46. {
  47. _requestServices = requestServices;
  48. _pennyTestBusiness = pennyTestBusiness;
  49. _trustDocBusiness = trustDocBusiness;
  50. }
  51. public JsonRxResponse GetCountriesServices()
  52. {
  53. JsonRxResponse jsonRx = new JsonRxResponse();
  54. try
  55. {
  56. var listCountriesServices = _requestServices.GetCountriesServices();
  57. if (listCountriesServices == null || listCountriesServices.Count < 1)
  58. {
  59. Log.Debug("GetCountriesServices | Returning null while calling the GetCountriesServices to fetch the countries services.");
  60. jsonRx.SetResponse("1", "Could not fetch the exrate data.");
  61. return jsonRx;
  62. }
  63. jsonRx.SetResponse("0", "Success");
  64. var path = GetStatic.ReadWebConfig("ServiceType_Resource", "");
  65. var text = File.ReadAllText(path);
  66. List<ServiceTypeDetails> sd = JsonConvert.DeserializeObject<List<ServiceTypeDetails>>(text);
  67. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  68. if (string.IsNullOrEmpty(lang))
  69. {
  70. lang = "en";
  71. }
  72. var idx = sd.FindIndex(x => x.countryCode == lang);
  73. var data = new ServiceTypeDetails();
  74. if (idx < 0)
  75. {
  76. data = sd[sd.FindIndex(x => x.countryCode == "en")];
  77. }
  78. else
  79. {
  80. data = sd[idx];
  81. }
  82. foreach (var item in listCountriesServices)
  83. {
  84. foreach (var product in item.serviceAvailable)
  85. {
  86. switch (product.text.ToLower())
  87. {
  88. case "cash payment":
  89. product.description = data.cashPayment;
  90. break;
  91. case "bank deposit":
  92. product.description = data.bankDeposit;
  93. break;
  94. case "mobile wallet":
  95. product.description = data.mobileWallet;
  96. break;
  97. case "home delivery":
  98. product.description = data.homeDelivery;
  99. break;
  100. case "card payment":
  101. product.description = data.cardPayment;
  102. break;
  103. }
  104. }
  105. }
  106. jsonRx.Data = listCountriesServices;
  107. Log.Debug("GetCountriesServices | DB RESPONSE AFTER PARSING : " + JsonConvert.SerializeObject(jsonRx));
  108. return jsonRx;
  109. }
  110. catch (Exception ex)
  111. {
  112. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  113. jsonRx.SetResponse("1", "Could not fetch the countries service details.");
  114. return jsonRx;
  115. }
  116. }
  117. public JsonRxResponse GetNotifyInfo(NotifiCationInfo info)
  118. {
  119. JsonRxResponse res = new JsonRxResponse();
  120. res = _requestServices.GetNotifyInfo(info.customerId);
  121. return res;
  122. }
  123. public JsonRxResponse GetNotifyDetailInfo(NotifiCationDetailInfo info)
  124. {
  125. JsonRxResponse res = new JsonRxResponse();
  126. res = _requestServices.GetNotifyDetailInfo(info.rowId);
  127. return res;
  128. }
  129. public JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel)
  130. {
  131. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  132. JsonRxResponse jsonRx = new JsonRxResponse();
  133. try
  134. {
  135. requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile.
  136. jsonRx = _requestServices.RequestOTP(requestOTPModel);
  137. Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  138. if (jsonRx.ErrorCode == "0")
  139. {
  140. bool emailSent = false;
  141. bool smsSent = false;
  142. if (requestOTPModel.userId.IsValidEmail() & (jsonRx.Extra3.Equals("0") | jsonRx.Extra3.Equals("100")))
  143. {
  144. if (!string.IsNullOrEmpty(jsonRx.ErrorCode) && jsonRx.ErrorCode.Equals("0"))
  145. {
  146. List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
  147. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = jsonRx.Extra });
  148. bodyMappings.Add(new Notify.Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP });
  149. bodyMappings.Add(new Notify.Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" });
  150. try
  151. {
  152. SendNotificationRequest request = new SendNotificationRequest()
  153. {
  154. IsBulkNotification = false,
  155. UserName = requestOTPModel.userId,
  156. ControlNo = requestOTPModel.receiverId,
  157. ProviderId = "REQUESTOTP_EMAIL",
  158. Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL,
  159. Recipients = new List<RecipientViewModel>()
  160. {
  161. new RecipientViewModel()
  162. {
  163. NotificationContent = new NotificationDTO() {
  164. Body = JsonConvert.SerializeObject(bodyMappings),
  165. //Title will be set by mapping json
  166. },
  167. Address= requestOTPModel.userId,
  168. DeviceType = requestOTPModel.DeviceType,
  169. } }
  170. };
  171. Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
  172. var jsonRx1 = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  173. Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(jsonRx1));
  174. emailSent = true;
  175. }
  176. catch (Exception emailException)
  177. {
  178. Log.Error("Error sending email", emailException);
  179. }
  180. try
  181. {
  182. string mobileNum = jsonRx.Extra2;
  183. var mobNum = getSenderFormattedNumber(mobileNum);
  184. SendSMSApiService _sendAPI = new SendSMSApiService();
  185. StringBuilder s = new StringBuilder();
  186. s.AppendLine($"Dear { jsonRx.Extra}");
  187. s.AppendLine($"Your OTP code for Customer Registration is {requestOTPModel.OTP }.");
  188. s.AppendLine("Regards, IME London");
  189. SMSRequestModel _req = new SMSRequestModel
  190. {
  191. ProviderId = "ProcessId",
  192. MobileNumber = mobileNum,
  193. SMSBody = s.ToString(),
  194. ProcessId = requestOTPModel.ProcessId,
  195. RequestedBy = requestOTPModel.userId,
  196. UserName = requestOTPModel.userId,
  197. method = "send",
  198. ControlNo = "", // GetControlNo()
  199. };
  200. Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
  201. APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
  202. Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
  203. smsSent = true;
  204. }
  205. catch (Exception smsException)
  206. {
  207. Log.Error("Error sending SMS", smsException);
  208. }
  209. if (emailSent || smsSent)
  210. {
  211. jsonRx.ErrorCode = "0";
  212. jsonRx.SetResponse("0", "OTP has been Sent.");
  213. return jsonRx;
  214. }
  215. }
  216. }
  217. else
  218. {
  219. if (jsonRx.Extra3 != null & jsonRx.Extra3.Equals("103"))
  220. {
  221. return new JsonRxResponse { ErrorCode = "0", Msg = "OTP Already Sent" };
  222. }
  223. jsonRx.ErrorCode = "1";
  224. // var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang);
  225. return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = jsonRx.Msg };
  226. }
  227. }
  228. jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used
  229. return jsonRx;
  230. }
  231. catch (Exception ex)
  232. {
  233. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  234. jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
  235. return jsonRx;
  236. }
  237. }
  238. public string getSenderFormattedNumber(string number)
  239. {
  240. string finalNo = number;
  241. if (!number.Contains("+44"))
  242. {
  243. string mobileFirst = number.Substring(0, 1);
  244. if (mobileFirst == "0")
  245. {
  246. if (number.Length == 11)
  247. {
  248. finalNo = "+44" + number.Substring(1, number.Length - 1);
  249. return finalNo;
  250. }
  251. else if (number.Length < 11)
  252. {
  253. finalNo = $"+44{number}";
  254. }
  255. }
  256. else if (number.Substring(0, 1) != "0" && number.Length == 10)
  257. {
  258. finalNo = $"+44{number}";
  259. }
  260. }
  261. else if (number.Contains("+44"))
  262. {
  263. string MobN = number.Substring(4, 1);
  264. if (MobN == "0" && number.Length > 14)
  265. {
  266. finalNo = number.Remove(4, 1);
  267. }
  268. }
  269. if (!finalNo.Substring(0, 1).Contains("+"))
  270. {
  271. finalNo = $"+{finalNo}";
  272. }
  273. return finalNo;
  274. }
  275. public JsonRxResponse VerifyIdNumber(IDValidateModel iDValidate)
  276. {
  277. JsonRxResponse jsonRx = new JsonRxResponse();
  278. try
  279. {
  280. jsonRx = _requestServices.VerifyIdNumber(iDValidate);
  281. Log.Debug("VerifyIdNumber | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  282. return jsonRx;
  283. }
  284. catch (Exception ex)
  285. {
  286. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  287. jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
  288. return jsonRx;
  289. }
  290. }
  291. public JsonRxResponse SubmitOTP(RequestOTPModel requestOTPModel)
  292. {
  293. JsonRxResponse jsonRx = new JsonRxResponse();
  294. try
  295. {
  296. jsonRx = _requestServices.SubmitOTP(requestOTPModel);
  297. Log.Debug("SubmitOTP | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  298. if (jsonRx.ErrorCode.Equals("0"))
  299. {
  300. string email = requestOTPModel.userId;
  301. UserDetails userDetails = _requestServices.GetUserDetails(email);
  302. List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
  303. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = userDetails.FullName });
  304. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerId", SText = userDetails.CustomerId.ToString() });
  305. bodyMappings.Add(new Notify.Mapping() { SValue = "UserId", SText = userDetails.MembershipId });
  306. bodyMappings.Add(new Notify.Mapping() { SValue = "FirstName", SText = userDetails.FirstName });
  307. bodyMappings.Add(new Notify.Mapping() { SValue = "MiddleName", SText = userDetails.MiddleName });
  308. bodyMappings.Add(new Notify.Mapping() { SValue = "LastName", SText = userDetails.LastName });
  309. bodyMappings.Add(new Notify.Mapping() { SValue = "MobileNo", SText = userDetails.Mobile });
  310. bodyMappings.Add(new Notify.Mapping() { SValue = "Address", SText = userDetails.Address });
  311. bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = userDetails.Email });
  312. bodyMappings.Add(new Notify.Mapping() { SValue = "RegisteredDate", SText = Convert.ToString(userDetails.RegisteredDate) });
  313. bodyMappings.Add(new Notify.Mapping() { SValue = "rewardPoint", SText = userDetails.TotalPoints });
  314. bodyMappings.Add(new Notify.Mapping() { SValue = "RegReward", SText = userDetails.RegPoints });
  315. bodyMappings.Add(new Notify.Mapping() { SValue = "TranReward", SText = userDetails.TranPoints });
  316. SendNotificationRequest request = new SendNotificationRequest()
  317. {
  318. IsBulkNotification = false,
  319. UserName = userDetails.Email,
  320. ProviderId = "BasicRegistration",
  321. NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  322. Template = Common.Model.Enum.NotifyTemplate.BASIC_REGISTRATION_EMAIL,
  323. Recipients = new List<RecipientViewModel>()
  324. {
  325. new RecipientViewModel()
  326. {
  327. NotificationContent = new NotificationDTO() {
  328. Body = JsonConvert.SerializeObject(bodyMappings),
  329. //Title will be set by mapping json
  330. },
  331. Address= userDetails.Email
  332. }
  333. }
  334. };
  335. jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  336. }
  337. return jsonRx;
  338. }
  339. catch (Exception ex)
  340. {
  341. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  342. jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
  343. return jsonRx;
  344. }
  345. }
  346. public JsonRxResponse CalculateExRate(ExRateCalculateRequest m)
  347. {
  348. ThirdPartyAPI _tpApi = new ThirdPartyAPI();
  349. JsonRxResponse response = new JsonRxResponse();
  350. APIJsonResponse jsonResponse = new APIJsonResponse();
  351. try
  352. {
  353. ExRateCalculate exRequest = new ExRateCalculate()
  354. {
  355. AgentRefId = "",
  356. CalcBy = m.calcBy,
  357. CAmount = Convert.ToDecimal(m.cAmount == "" ? "0" : m.cAmount),
  358. CardOnline = "",
  359. CollCurrency = m.sCurrency,
  360. CouponCode = m.DeviceType,
  361. CustomerId = 0,
  362. IsExRateCalcByPartner = false,
  363. IsManualSc = false,
  364. IsOnline = false,
  365. ManualSc = 0,
  366. //PAgentId = Convert.ToInt32(m.pAgent == "" || m.pAgent==null ? "0" : m.pAgent),
  367. PAgentName = "",
  368. PAmount = Convert.ToDecimal(m.pAmount == "" || m.pAmount == null ? "0" : m.pAmount),
  369. PaymentType = m.paymentType,
  370. PayoutPartner = 0,
  371. PCountry = Convert.ToInt32(m.pCountry == "" || m.pCountry == null ? "0" : m.pCountry),
  372. pCountryCode = m.pCountryName,
  373. PCountryName = m.pCountryName,
  374. PCurrency = m.pCurrency,
  375. ProcessId = m.processId,
  376. ProviderId = "",
  377. RequestedBy = "mobile",
  378. SAgent = 0,
  379. SBranch = Convert.ToInt32(GetStatic.ReadWebConfig("sBranch", "")),
  380. SchemeId = m.schemeId,
  381. SCountry = Convert.ToInt32(m.sCountry == "" || m.sCountry == null ? "0" : m.sCountry),
  382. SCurrency = m.sCurrency,
  383. ServiceType = m.serviceType,
  384. SessionId = "",
  385. SSuperAgent = Convert.ToInt32(GetStatic.ReadWebConfig("sSuperAgent", "")),
  386. tPExRate = m.tpExRate,
  387. UserName = m.userId,
  388. ProcessFor = "dashboard",
  389. };
  390. Log.Debug("CalculateExRate | TPAPI REQUEST : " + JsonConvert.SerializeObject(exRequest));
  391. var result = _tpApi.ThirdPartyApiGetDataOnly<ExRateCalculate, APIJsonResponse>(exRequest, "TP/ExRate", out jsonResponse);
  392. Log.Debug("CalculateExRate | TPAPI RESPONSE : " + JsonConvert.SerializeObject(result));
  393. response = new JsonRxResponse()
  394. {
  395. ErrorCode = result.ResponseCode,
  396. Id = result.Id,
  397. Msg = result.Msg,
  398. Data = result.Data,
  399. Extra = result.Extra,
  400. Extra2 = result.Extra1,
  401. FootNoteMessage = result.FootNoteMessage
  402. };
  403. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  404. string enumString = string.Empty;
  405. response.FootNoteMessage = response.ErrorCode.Equals("0") ? Utilities.GetLanguageMapping(ConfigurationManager.AppSettings["footNote_calculateDashboard"].ToString(), lang).Message : "";
  406. //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 };
  407. return response;
  408. }
  409. catch (Exception ex)
  410. {
  411. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  412. response.SetResponse("1", "Error occured while calculating ex-rate");
  413. return response;
  414. }
  415. }
  416. public JsonRxResponse ChangeTxnPin(ChangeTxnPinModel changeTxnPin)
  417. {
  418. JsonRxResponse jsonRx = new JsonRxResponse();
  419. try
  420. {
  421. jsonRx = _requestServices.ChangeTxnPin(changeTxnPin);
  422. Log.Debug("ChangeTxnPin | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  423. return jsonRx;
  424. }
  425. catch (Exception ex)
  426. {
  427. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  428. jsonRx.SetResponse("1", ex.ToString());
  429. return jsonRx;
  430. }
  431. }
  432. public JsonRxResponse ChangeSettings(ChangeSettingModel changeSettings)
  433. {
  434. JsonRxResponse jsonRx = new JsonRxResponse();
  435. try
  436. {
  437. jsonRx = _requestServices.ChangeSettings(changeSettings);
  438. Log.Debug("ChangeSettings | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  439. return jsonRx;
  440. }
  441. catch (Exception ex)
  442. {
  443. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  444. jsonRx.SetResponse("1", "Error occurred while ChangeSettings.");
  445. return jsonRx;
  446. }
  447. }
  448. public JsonRxResponse ChangePasswordAndTxnPin(ChangePasswordAndTxnPinModel changePasswordAndTxnPin)
  449. {
  450. JsonRxResponse jsonRx = new JsonRxResponse();
  451. try
  452. {
  453. if (string.IsNullOrEmpty(changePasswordAndTxnPin.CurrentPassword))
  454. {
  455. jsonRx.SetResponse("1", "Current Password cannot be empty!");
  456. return jsonRx;
  457. }
  458. if (string.IsNullOrEmpty(changePasswordAndTxnPin.NewPassword))
  459. {
  460. jsonRx.SetResponse("1", "New Password cannot be empty!");
  461. return jsonRx;
  462. }
  463. if (string.IsNullOrEmpty(changePasswordAndTxnPin.ConfirmNewPassword))
  464. {
  465. jsonRx.SetResponse("1", "Confirm New Password cannot be empty!");
  466. return jsonRx;
  467. }
  468. if (string.IsNullOrEmpty(changePasswordAndTxnPin.CurrentPin))
  469. {
  470. jsonRx.SetResponse("1", "Current Pin cannot be empty!");
  471. return jsonRx;
  472. }
  473. if (string.IsNullOrEmpty(changePasswordAndTxnPin.NewPin))
  474. {
  475. jsonRx.SetResponse("1", "New Pin cannot be empty!");
  476. return jsonRx;
  477. }
  478. if (string.IsNullOrEmpty(changePasswordAndTxnPin.ConfirmNewPin))
  479. {
  480. jsonRx.SetResponse("1", "Confirm New Pin cannot be empty!");
  481. return jsonRx;
  482. }
  483. if (changePasswordAndTxnPin.NewPin.Length < 6)
  484. {
  485. jsonRx.SetResponse("1", "PIN should be 6 digit number!");
  486. return jsonRx;
  487. }
  488. if (changePasswordAndTxnPin.ConfirmNewPin.Length < 6)
  489. {
  490. jsonRx.SetResponse("1", "PIN should be 6 digit number!");
  491. return jsonRx;
  492. }
  493. if (changePasswordAndTxnPin.NewPin.Length > 6)
  494. {
  495. jsonRx.SetResponse("1", "PIN cannot be greater than 6 digit!");
  496. return jsonRx;
  497. }
  498. if (changePasswordAndTxnPin.ConfirmNewPin.Length > 6)
  499. {
  500. jsonRx.SetResponse("1", "PIN cannot be greater than 6 digit!");
  501. return jsonRx;
  502. }
  503. jsonRx = _requestServices.ChangePasswordAndTxnPin(changePasswordAndTxnPin);
  504. Log.Debug("ChangePasswordAndTxnPin | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  505. return jsonRx;
  506. }
  507. catch (Exception ex)
  508. {
  509. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  510. jsonRx.SetResponse("1", "Error occurred while ChangeTxnPin.");
  511. return jsonRx;
  512. }
  513. }
  514. public JsonRxResponse RegisterKycExistingCustomer()
  515. {
  516. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  517. JsonRxResponse jsonRx = new JsonRxResponse();
  518. try
  519. {
  520. var httpRequest = HttpContext.Current.Request;
  521. var custKyc = new CustomerKYCModel()
  522. {
  523. userId = httpRequest["userId"],
  524. type = httpRequest["type"],
  525. employeerName = httpRequest["employeerName"],
  526. monthlyIncome = httpRequest["monthlyIncome"],
  527. businessType = httpRequest["businessType"],
  528. mobile = httpRequest["mobile"],
  529. additionalAddress = httpRequest["additionalAddress"],
  530. additionalIdType = httpRequest["additionalIdType"],
  531. visaStatus = httpRequest["visaStatus"],
  532. idType = httpRequest["idType"],
  533. occupation = httpRequest["occupation"],
  534. purposeOfRegistration = httpRequest["purposeOfRegistration"],
  535. otherOccupation = httpRequest["otherOccupation"],
  536. otherIdType = httpRequest["otherIdType"],
  537. ExistingCutomer = true
  538. };
  539. var idFrontUrl = httpRequest.Files["idFront"];
  540. var idBackUrl = httpRequest.Files["idBack"];
  541. var idSideUrl = httpRequest.Files["idSide"];
  542. Log.Debug($"RegisterKYCExistingCustomer | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}");
  543. if (custKyc.type.Equals("1") && httpRequest.Files.Count < 1) //documents
  544. {
  545. Log.Debug("RegisterKycExistingCustomer | Validate Image : Failed" + JsonConvert.SerializeObject(jsonRx));
  546. jsonRx.SetResponse("1", "Primary Id documents are required.");
  547. return jsonRx;
  548. }
  549. jsonRx = ValidateForm(custKyc, idFrontUrl, idBackUrl, idSideUrl);
  550. if (!jsonRx.ErrorCode.Equals("0"))
  551. {
  552. Log.Debug("RegisterKYC | Validate form failed : " + JsonConvert.SerializeObject(jsonRx));
  553. jsonRx.SetResponse("1", jsonRx.Msg);
  554. return jsonRx;
  555. }
  556. var rep = _requestServices.RegisterKYCExistingCustomer(custKyc);
  557. Log.Debug("RegisterKYCExistingCustomer | DB RESPONSE : " + JsonConvert.SerializeObject(rep));
  558. //if (rep.ErrorCode.Equals("0"))
  559. //{
  560. // var fireBaseId = Convert.ToString(CallContext.GetData(Constants.FcmId));
  561. // Task.Run(() => FcmNotifier.Notify(fireBaseId, Languages.GetMessage("kyc_submit_no_pennytest", lang), Languages.GetTitle("kyc", lang)));
  562. //}
  563. return rep;
  564. }
  565. catch (Exception ex)
  566. {
  567. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  568. jsonRx.SetResponse("1", "Could not register the customer Kyc.");
  569. return jsonRx;
  570. }
  571. }
  572. public JsonRxResponse RegisterKYC(string deviceType = "")
  573. {
  574. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  575. bool isKyc = false;
  576. JsonRxResponse jsonRx = new JsonRxResponse();
  577. try
  578. {
  579. var httpRequest = HttpContext.Current.Request;
  580. var idFrontUrl = httpRequest.Files["idFront"];
  581. var idBackUrl = httpRequest.Files["idBack"];
  582. var idSideUrl = httpRequest.Files["idSide"];
  583. var additionalIdUrl = httpRequest.Files["additionalId"];
  584. var additionalIdBackUrl = httpRequest.Files["additionalIdBack"];
  585. var facePictureUrl = httpRequest.Files["faceImageFile"];
  586. var custKyc = new CustomerKYCModel()
  587. {
  588. userId = httpRequest["userId"],
  589. type = httpRequest["type"],
  590. monthlyIncome = httpRequest["monthlyIncome"],
  591. businessType = httpRequest["businessType"],
  592. mobile = httpRequest["mobile"],
  593. additionalAddress = httpRequest["additionalAddress"],
  594. idType = httpRequest["idType"],
  595. idNumber = httpRequest["IdNumber"] != null ? httpRequest["IdNumber"] : "",
  596. idIssuingCountry = httpRequest["IdIssuedCountry"] != null ? httpRequest["IdIssuedCountry"] : "",
  597. idStartDate = httpRequest["idStartDate"] != null ? httpRequest["idStartDate"] : "",
  598. idExpiryDate = httpRequest["IdEndDate"] != null ? httpRequest["IdEndDate"] : "",
  599. additionalIdType = httpRequest["additionalIdType"],
  600. employeerName = httpRequest["employeerName"],
  601. occupation = httpRequest["occupation"],
  602. purposeOfRegistration = httpRequest["purposeOfRegistration"],
  603. otherOccupation = httpRequest["otherOccupation"],
  604. otherIdType = httpRequest["otherIdType"],
  605. RegistrationType = httpRequest["RegistrationType"] != null ? httpRequest["RegistrationType"] : "",
  606. TrustDocId = httpRequest["TrustDocId"] != null ? httpRequest["TrustDocId"] : "",
  607. customerType = httpRequest["customerType"],
  608. idFront = idFrontUrl != null ? idFrontUrl.FileName : "",
  609. idBack = idBackUrl != null ? idBackUrl.FileName : "",
  610. additionalId = additionalIdUrl != null ? additionalIdUrl.FileName : "",
  611. additionalIdBack = additionalIdBackUrl != null ? additionalIdBackUrl.FileName : "",
  612. };
  613. if (deviceType.ToLower().Equals("ios") & !string.IsNullOrEmpty(custKyc.customerType))
  614. {
  615. custKyc.idType = custKyc.customerType;
  616. }
  617. else if (!string.IsNullOrEmpty(custKyc.customerType) && (!string.IsNullOrEmpty(custKyc.RegistrationType)) && custKyc.RegistrationType.Equals("EKYC"))
  618. {
  619. custKyc.idType = custKyc.customerType;
  620. }
  621. if (!string.IsNullOrEmpty(custKyc.RegistrationType) && custKyc.RegistrationType.Equals("EKYC"))
  622. {
  623. isKyc = true;
  624. }
  625. var isBackRequired = "0";
  626. //if (httpRequest.Files.Count > 0 && Utilities.IsCheckAdditionalId())
  627. //{
  628. // var id = _requestServices.checkAdditionalId(custKyc.additionalIdType);
  629. // if (id != null)
  630. // {
  631. // isBackRequired = id["isBackRequired"].ToString();
  632. // }
  633. //}
  634. //Log.Debug($"RegisterKYC | httpRequest : {httpRequest.Params}");
  635. Log.Debug($"RegisterKYC | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}");
  636. //if (httpRequest.Files.Count <= 1) //documents
  637. //{
  638. // Log.Debug("RegisterKYC | Validate Image : Failed" + JsonConvert.SerializeObject(jsonRx));
  639. // jsonRx.SetResponse("1", "Primary Id documents are required.");
  640. // return jsonRx;
  641. //}
  642. jsonRx = ValidateForm(custKyc, idFrontUrl, idBackUrl, idSideUrl, additionalIdUrl, facePictureUrl, additionalIdBackUrl, isBackRequired, isKyc);
  643. if (!jsonRx.ErrorCode.Equals("0"))
  644. {
  645. Log.Debug("RegisterKYC | Validate form failed : " + JsonConvert.SerializeObject(jsonRx));
  646. jsonRx.SetResponse("100", jsonRx.Msg);
  647. return jsonRx;
  648. }
  649. var rep = _requestServices.RegisterKYC(custKyc);
  650. SendNotificationRequest pushNotificationRequest = new SendNotificationRequest()
  651. {
  652. IsBulkNotification = false,
  653. UserName = custKyc.userId,
  654. ProcessId = Guid.NewGuid().ToString(),
  655. ProviderId = "RegisterKYC",
  656. NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(),
  657. Recipients = new List<RecipientViewModel>()
  658. {
  659. new RecipientViewModel()
  660. {
  661. NotificationContent = new NotificationDTO() {
  662. 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.",
  663. Title = "KYC Processing",
  664. },
  665. Address= rep.Extra2,
  666. DeviceType = rep.Extra3
  667. }
  668. },
  669. Language = Convert.ToString(CallContext.GetData(Constants.Language))
  670. };
  671. Log.Debug("RegisterKYC | DB RESPONSE" + JsonConvert.SerializeObject(rep));
  672. return rep;
  673. }
  674. catch (Exception ex)
  675. {
  676. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  677. jsonRx.SetResponse("1", "Could not register the customer Kyc.");
  678. return jsonRx;
  679. }
  680. }
  681. public JsonRxResponse RenewID()
  682. {
  683. JsonRxResponse jsonRx = new JsonRxResponse();
  684. try
  685. {
  686. var httpRequest = HttpContext.Current.Request;
  687. RenewID renewId = new RenewID();
  688. renewId.userId = httpRequest["userId"];
  689. var idFrontUrl = httpRequest.Files["idFront"];
  690. var idBackUrl = httpRequest.Files["idBack"];
  691. if (!IsValidImageIdRequest(ref renewId, idFrontUrl, idBackUrl))
  692. {
  693. Log.Debug("RenewID.IsValidImageIdRequest | Validate Image : Failed");
  694. jsonRx.SetResponse("1", "Invalid image file.");
  695. }
  696. var rep = _requestServices.RenewID(renewId);
  697. Log.Debug("RenewID | DB RESPONSE | " + JsonConvert.SerializeObject(rep));
  698. return rep;
  699. }
  700. catch (Exception ex)
  701. {
  702. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  703. jsonRx.SetResponse("1", "Could not RenewID.");
  704. return jsonRx;
  705. }
  706. }
  707. public JsonRxResponse DepositSlip(DepositSlip depoSlip)
  708. {
  709. JsonRxResponse jsonRx = new JsonRxResponse();
  710. try
  711. {
  712. var httpRequest = HttpContext.Current.Request;
  713. var slipUrl = httpRequest.Files["DepositSlip"];
  714. if (!IsValidImageASlipIdRequest(ref depoSlip, slipUrl))
  715. {
  716. Log.Debug("DepositSlip.IsValidImageASlipIdRequest | Validate Image : Failed");
  717. jsonRx.SetResponse("1", "Invalid image file.");
  718. }
  719. var rep = _requestServices.DepositSlip(depoSlip);
  720. Log.Debug("DepositSlip | DB RESPONSE | " + JsonConvert.SerializeObject(rep));
  721. return rep;
  722. }
  723. catch (Exception ex)
  724. {
  725. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  726. jsonRx.SetResponse("1", "Couldnot upload Deposit Slip!");
  727. return jsonRx;
  728. }
  729. }
  730. public bool IsValidImageASlipIdRequest(ref DepositSlip depoSlip, HttpPostedFile slipUrl)
  731. {
  732. bool isValidated = true;
  733. string fileName = "";
  734. var extension = "";
  735. if (slipUrl != null)
  736. {
  737. extension = Path.GetExtension(slipUrl.FileName);
  738. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && slipUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  739. {
  740. isValidated = false;
  741. }
  742. else
  743. {
  744. fileName = SaveIdFileToPath(slipUrl, depoSlip.UserId, extension, "slip", "deposit");
  745. depoSlip.Slip = fileName;
  746. }
  747. }
  748. if (!isValidated)
  749. {
  750. return isValidated;
  751. }
  752. return isValidated;
  753. }
  754. public bool IsValidImageIdRequest(ref RenewID renewID, HttpPostedFile idFrontUrl, HttpPostedFile idBackUrl)
  755. {
  756. bool isValidated = true;
  757. string fileName = "";
  758. var extension = "";
  759. if (idFrontUrl != null)
  760. {
  761. extension = Path.GetExtension(idFrontUrl.FileName);
  762. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idFrontUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  763. {
  764. isValidated = false;
  765. }
  766. else
  767. {
  768. fileName = SaveIdFileToPath(idFrontUrl, renewID.userId, extension, "id_front");
  769. renewID.idFront = fileName;
  770. }
  771. }
  772. if (!isValidated)
  773. {
  774. return isValidated;
  775. }
  776. if (idBackUrl != null)
  777. {
  778. extension = Path.GetExtension(idBackUrl.FileName);
  779. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  780. {
  781. isValidated = false;
  782. }
  783. else
  784. {
  785. fileName = SaveIdFileToPath(idBackUrl, renewID.userId, extension, "id_back");
  786. renewID.idBack = fileName;
  787. }
  788. }
  789. return isValidated;
  790. }
  791. private static string SaveIdFileToPath(HttpPostedFile file, string user, string extension, string img, string type = null)
  792. {
  793. string fileName = "";
  794. string docUploadPath = ApplicationConfig.GetDocumentUploadPath();
  795. // Get the file size
  796. int fileSize = file.ContentLength;
  797. fileName = "upload-" + img + "-" + user + "-" + GetTimestamp(DateTime.Now) + extension;
  798. if (type == "deposit")
  799. {
  800. docUploadPath = docUploadPath + "/CustomerDocument/DepositSlip/";
  801. }
  802. else
  803. {
  804. docUploadPath = docUploadPath + "/CustomerDocument/VerifyDocumentUpload/";
  805. }
  806. Log.Debug("Preparing file to save in dir " + docUploadPath);
  807. if (!Directory.Exists(docUploadPath))
  808. Directory.CreateDirectory(docUploadPath);
  809. string fileToSave = Path.Combine(docUploadPath, fileName);
  810. Log.Debug("Saving file as " + fileToSave);
  811. file.SaveAs(fileToSave);
  812. Log.Debug("Done with Saving ");
  813. return fileName;
  814. }
  815. public JsonRxResponse ValidateMobile(string mobile)
  816. {
  817. JsonRxResponse rxResponse = new JsonRxResponse() { ErrorCode = "0", Extra2 = mobile };
  818. if (string.IsNullOrEmpty(mobile))
  819. {
  820. rxResponse.ErrorCode = "1";
  821. rxResponse.Msg = "Mobile Number is missing!";
  822. return rxResponse;
  823. }
  824. if (!mobile.IsValidMobileNumber())
  825. {
  826. rxResponse.ErrorCode = "1";
  827. rxResponse.Msg = "Invalid Mobile Number format!";
  828. return rxResponse;
  829. }
  830. if (!mobile.Contains("+81"))
  831. {
  832. string mobileFirst = mobile.Substring(0, 1);
  833. if (mobileFirst == "0")
  834. {
  835. if (mobile.Length == 11)
  836. {
  837. rxResponse.Extra = "+81" + mobile.Substring(1, mobile.Length - 1);
  838. return rxResponse;
  839. }
  840. else if (mobile.Length < 11)
  841. {
  842. rxResponse.ErrorCode = "1";
  843. rxResponse.Msg = "Invalid Mobile Number provided!";
  844. return rxResponse;
  845. }
  846. else if (mobile.Length > 11)
  847. {
  848. rxResponse.ErrorCode = "1";
  849. rxResponse.Msg = "Invalid Mobile Number length provided!";
  850. return rxResponse;
  851. }
  852. }
  853. else if (mobile.Substring(0, 1) != "0" && mobile.Length == 10)
  854. {
  855. rxResponse.Extra = $"+81{mobile}";
  856. return rxResponse;
  857. }
  858. else if (mobile.Substring(0, 1) == "0" && mobile.Length > 11)
  859. {
  860. rxResponse.ErrorCode = "1";
  861. rxResponse.Msg = "Invalid Mobile Number length!";
  862. return rxResponse;
  863. }
  864. }
  865. else if (mobile.Contains("+81"))
  866. {
  867. string MobN = mobile.Substring(3, 1);
  868. if (MobN == "0")
  869. {
  870. if (mobile.Length == 14)
  871. {
  872. rxResponse.Extra = mobile.Remove(3, 1);
  873. return rxResponse;
  874. }
  875. else if (mobile.Length < 14)
  876. {
  877. rxResponse.ErrorCode = "1";
  878. rxResponse.Msg = "Invalid Mobile Number provided!";
  879. return rxResponse;
  880. }
  881. else if (mobile.Length > 14)
  882. {
  883. rxResponse.ErrorCode = "1";
  884. rxResponse.Msg = "Invalid Mobile Number length provided!";
  885. return rxResponse;
  886. }
  887. }
  888. else if (mobile.Substring(3, 1) != "0" && mobile.Length == 13)
  889. {
  890. rxResponse.Extra = mobile;
  891. }
  892. else if (mobile.Substring(3, 1) == "1" && mobile.Length == 14)
  893. {
  894. rxResponse.ErrorCode = "1";
  895. rxResponse.Msg = "Invalid Mobile Number length or format!";
  896. return rxResponse;
  897. }
  898. else if (mobile.Substring(3, 1) == "0" && mobile.Length > 11)
  899. {
  900. rxResponse.ErrorCode = "1";
  901. rxResponse.Msg = "Invalid Mobile Number length!";
  902. return rxResponse;
  903. }
  904. }
  905. //else
  906. //{
  907. // rxResponse.Extra = mobile;
  908. //}
  909. return rxResponse;
  910. }
  911. 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)
  912. {
  913. string enumString = string.Empty;
  914. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  915. JsonRxResponse jsonRx = new JsonRxResponse() { ErrorCode = "0", Msg = "Kyc Form validation success." };
  916. Log.Debug("IsValidatedForm | Requested parameters : " + JsonConvert.SerializeObject(kyc));
  917. //NULL validation
  918. //var jsonRxMobile = ValidateMobile(kyc.mobile);
  919. //if (!jsonRxMobile.ErrorCode.Equals("0"))
  920. //{
  921. // Log.Debug($"RegisterKYC | Mobile : {kyc.mobile} | ValidateMobile failed : { JsonConvert.SerializeObject(jsonRxMobile)}");
  922. // jsonRx.SetResponse("1", jsonRxMobile.Msg);
  923. // return jsonRx;
  924. //}
  925. //else
  926. //{
  927. // Log.Debug($"RegisterKYC | ValidateMobile Response : { JsonConvert.SerializeObject(jsonRxMobile)}");
  928. // kyc.mobile = jsonRxMobile.Extra;
  929. //}
  930. if (kyc.type.Equals("0"))
  931. {
  932. if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation))
  933. {
  934. enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString();
  935. var map = Utilities.GetLanguageMapping(enumString, lang);
  936. jsonRx.SetResponse("100", map.Message);
  937. return jsonRx;
  938. }
  939. else if (string.IsNullOrEmpty(kyc.occupation))
  940. {
  941. if (string.IsNullOrEmpty(kyc.otherOccupation))
  942. {
  943. enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString();
  944. var map = Utilities.GetLanguageMapping(enumString, lang);
  945. jsonRx.SetResponse("100", map.Message);
  946. return jsonRx;
  947. }
  948. }
  949. if (string.IsNullOrEmpty(kyc.idExpiryDate))
  950. {
  951. jsonRx.SetResponse("100", "IdExpiryDate is required");
  952. return jsonRx;
  953. }
  954. if (string.IsNullOrEmpty(kyc.idStartDate))
  955. {
  956. jsonRx.SetResponse("100", "Idissue Date is required");
  957. return jsonRx;
  958. }
  959. if (string.IsNullOrEmpty(kyc.idIssuingCountry))
  960. {
  961. jsonRx.SetResponse("100", "idIssuingCountry is required");
  962. return jsonRx;
  963. }
  964. }
  965. //if (string.IsNullOrEmpty(kyc.idNumber))
  966. //{
  967. // jsonRx.SetResponse("1", "Id number is required");
  968. // return jsonRx;
  969. //}
  970. //if (string.IsNullOrEmpty(kyc.additionalAddress))
  971. //{
  972. // enumString = RESPONSE_MSG.VALIDATE_FORM_4.ToString();
  973. // var map = Utilities.GetLanguageMapping(enumString, lang);
  974. // jsonRx.SetResponse("1", map.Message);
  975. // return jsonRx;
  976. //}
  977. //if (kyc.additionalAddress.Length > 50)
  978. //{
  979. // enumString = RESPONSE_MSG.VALIDATE_FORM_11.ToString();
  980. // var map = Utilities.GetLanguageMapping(enumString, lang);
  981. // jsonRx.SetResponse("1", map.Message);
  982. // return jsonRx;
  983. //}
  984. //if (string.IsNullOrEmpty(kyc.businessType))
  985. //{
  986. // enumString = RESPONSE_MSG.VALIDATE_FORM_5.ToString();
  987. // var map = Utilities.GetLanguageMapping(enumString, lang);
  988. // jsonRx.SetResponse("1", map.Message);
  989. // return jsonRx;
  990. //}
  991. //if (string.IsNullOrEmpty(kyc.mobile))
  992. //{
  993. // enumString = RESPONSE_MSG.VALIDATE_FORM_6.ToString();
  994. // var map = Utilities.GetLanguageMapping(enumString, lang);
  995. // jsonRx.SetResponse("1", map.Message);
  996. // return jsonRx;
  997. //}
  998. //if (string.IsNullOrEmpty(kyc.purposeOfRegistration))
  999. //{
  1000. // enumString = RESPONSE_MSG.VALIDATE_FORM_7.ToString();
  1001. // var map = Utilities.GetLanguageMapping(enumString, lang);
  1002. // jsonRx.SetResponse("1", map.Message);
  1003. // return jsonRx;
  1004. //}
  1005. if (!isEkyc && string.IsNullOrEmpty(kyc.idType))
  1006. {
  1007. if (string.IsNullOrEmpty(kyc.otherIdType))
  1008. {
  1009. enumString = RESPONSE_MSG.VALIDATE_FORM_1.ToString();
  1010. var map = Utilities.GetLanguageMapping(enumString, lang);
  1011. jsonRx.SetResponse("100", map.Message);
  1012. return jsonRx;
  1013. }
  1014. }
  1015. else if (!isEkyc && string.IsNullOrEmpty(kyc.idType) && string.IsNullOrEmpty(kyc.otherIdType))
  1016. {
  1017. enumString = RESPONSE_MSG.VALIDATE_FORM_10.ToString();
  1018. var map = Utilities.GetLanguageMapping(enumString, lang);
  1019. jsonRx.SetResponse("100", map.Message);
  1020. return jsonRx;
  1021. }
  1022. if (!isEkyc && !kyc.ExistingCutomer)
  1023. {
  1024. if (isBackRequired == "1" && additionalIdBackUrl == null)
  1025. {
  1026. jsonRx.SetResponse("100", "Additional ID Back is required!");
  1027. return jsonRx;
  1028. }
  1029. if (string.IsNullOrEmpty(kyc.additionalIdType))
  1030. {
  1031. enumString = RESPONSE_MSG.VALIDATE_FORM_8.ToString();
  1032. var map = Utilities.GetLanguageMapping(enumString, lang);
  1033. jsonRx.SetResponse("100", map.Message);
  1034. return jsonRx;
  1035. }
  1036. }
  1037. if (!IsValidImage(ref kyc, idFrontUrl, idBackUrl, idSideUrl, additionalIdUrl, facePictureUrl, additionalIdBackUrl))
  1038. {
  1039. Log.Debug("IsValidatedForm | Validate Image : Failed");
  1040. jsonRx.SetResponse("100", "Invalid image file.");
  1041. return jsonRx;
  1042. }
  1043. return jsonRx;
  1044. }
  1045. public bool IsValidImage(ref CustomerKYCModel kyc, HttpPostedFile idFrontUrl, HttpPostedFile idBackUrl, HttpPostedFile idSideUrl, HttpPostedFile additionalIdUrl, HttpPostedFile facePictureUrl, HttpPostedFile additionalIdBackUrl)
  1046. {
  1047. bool isValidated = true;
  1048. string fileName = "";
  1049. var extension = "";
  1050. DataRow dirDetails = _requestServices.GetCustomerImageSavePath(kyc.userId);
  1051. if (null == dirDetails)
  1052. {
  1053. return false;
  1054. }
  1055. string registrationDate = dirDetails["REGISTERED_DATE"].ToString();
  1056. string membershipId = dirDetails["MEMBERSHIPID"].ToString();
  1057. if (string.IsNullOrEmpty(registrationDate) || string.IsNullOrEmpty(membershipId))
  1058. {
  1059. return false;
  1060. }
  1061. if (idFrontUrl != null)
  1062. {
  1063. extension = Path.GetExtension(idFrontUrl.FileName);
  1064. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idFrontUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1065. {
  1066. isValidated = false;
  1067. }
  1068. else
  1069. {
  1070. fileName = SaveFileToPath(idFrontUrl, membershipId, extension, "id_front", registrationDate);
  1071. kyc.idFront = fileName;
  1072. }
  1073. }
  1074. if (!isValidated)
  1075. {
  1076. return isValidated;
  1077. }
  1078. if (idBackUrl != null)
  1079. {
  1080. extension = Path.GetExtension(idBackUrl.FileName);
  1081. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1082. {
  1083. isValidated = false;
  1084. }
  1085. else
  1086. {
  1087. fileName = SaveFileToPath(idBackUrl, membershipId, extension, "id_back", registrationDate);
  1088. kyc.idBack = fileName;
  1089. }
  1090. }
  1091. if (!isValidated)
  1092. {
  1093. return isValidated;
  1094. }
  1095. if (idSideUrl != null)
  1096. {
  1097. extension = Path.GetExtension(idSideUrl.FileName);
  1098. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && idSideUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1099. {
  1100. isValidated = false;
  1101. }
  1102. else
  1103. {
  1104. fileName = SaveFileToPath(idSideUrl, membershipId, extension, "id_side", registrationDate);
  1105. kyc.idSide = fileName;
  1106. }
  1107. }
  1108. if (!isValidated)
  1109. {
  1110. return isValidated;
  1111. }
  1112. if (additionalIdUrl != null)
  1113. {
  1114. extension = Path.GetExtension(additionalIdUrl.FileName);
  1115. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && additionalIdUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1116. {
  1117. isValidated = false;
  1118. }
  1119. else
  1120. {
  1121. fileName = SaveFileToPath(additionalIdUrl, membershipId, extension, "id_additional_front", registrationDate);
  1122. kyc.additionalId = fileName;
  1123. }
  1124. }
  1125. if (additionalIdBackUrl != null)
  1126. {
  1127. extension = Path.GetExtension(additionalIdBackUrl.FileName);
  1128. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && additionalIdBackUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1129. {
  1130. isValidated = false;
  1131. }
  1132. else
  1133. {
  1134. fileName = SaveFileToPath(additionalIdBackUrl, membershipId, extension, "id_additional_back", registrationDate);
  1135. kyc.additionalIdBack = fileName;
  1136. }
  1137. }
  1138. if (!isValidated)
  1139. {
  1140. return isValidated;
  1141. }
  1142. if (facePictureUrl != null)
  1143. {
  1144. extension = Path.GetExtension(facePictureUrl.FileName);
  1145. if (!(extension == ".jpg" || extension == ".jpeg" || extension == ".png") && facePictureUrl.ContentLength > Convert.ToInt32(ApplicationConfig.GetMaximumFileSize()))
  1146. {
  1147. isValidated = false;
  1148. }
  1149. else
  1150. {
  1151. fileName = SaveFileToPath(facePictureUrl, membershipId, extension, "face_picture", registrationDate);
  1152. kyc.facePicture = fileName;
  1153. }
  1154. }
  1155. return isValidated;
  1156. }
  1157. private static string SaveFileToPath(HttpPostedFile file, string membershipId, string extension, string img, string registrationDate)
  1158. {
  1159. string fileName = "";
  1160. string folderName = membershipId;
  1161. string docUploadPath = ApplicationConfig.GetDocumentUploadPath();
  1162. // Get the file size
  1163. int fileSize = file.ContentLength;
  1164. fileName = "upload-" + img + "-" + GetTimestamp(DateTime.Now) + extension;
  1165. docUploadPath = docUploadPath + "/CustomerDocument/" + registrationDate.Replace("_", "/") + "/" + folderName;
  1166. Log.Debug("Preparing file to save in dir " + docUploadPath);
  1167. if (!Directory.Exists(docUploadPath))
  1168. Directory.CreateDirectory(docUploadPath);
  1169. //var tempDocUploadPath = docUploadPath + "/temp";
  1170. //if (!Directory.Exists(tempDocUploadPath))
  1171. // Directory.CreateDirectory(tempDocUploadPath);
  1172. //CompressImageDao ci = new CompressImageDao();
  1173. //string tempFileUploadPath = Path.Combine(tempDocUploadPath, fileName);
  1174. //file.SaveAs(tempFileUploadPath);
  1175. string fileToSave = Path.Combine(docUploadPath, fileName);
  1176. Log.Debug("Saving file as " + fileToSave);
  1177. file.SaveAs(fileToSave);
  1178. //if (!ci.CompressImageAndSave((fileSize / 1024), tempFileUploadPath, fileToSave))
  1179. //{
  1180. // file.SaveAs(fileToSave);
  1181. //}
  1182. //if (Directory.Exists(tempDocUploadPath))
  1183. // Directory.Delete(tempDocUploadPath, true);
  1184. Log.Debug("Done with Saving ");
  1185. return fileName;
  1186. }
  1187. public static string GetTimestamp(DateTime value)
  1188. {
  1189. return value.ToString("yyyyMMddHHmmssffff");
  1190. }
  1191. public JsonRxResponse LoadFormStaticData(string type)
  1192. {
  1193. JsonRxResponse jsonRx = new JsonRxResponse
  1194. {
  1195. ErrorCode = "1",
  1196. Msg = "Error"
  1197. };
  1198. try
  1199. {
  1200. if (type.ToLower().Equals("receiver"))
  1201. {
  1202. StaticData sd = _requestServices.LoadFormStaticData("receiver");
  1203. if (sd != null)
  1204. {
  1205. jsonRx.ErrorCode = "0";
  1206. jsonRx.Msg = "success";
  1207. jsonRx.Data = sd;
  1208. Log.Debug("LoadFormStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1209. return jsonRx;
  1210. }
  1211. Log.Debug("LoadFormStaticData | Returning null while calling DB");
  1212. jsonRx.SetResponse("1", "Error occured", null);
  1213. return jsonRx;
  1214. }
  1215. else if (type.ToLower().Equals("kyc"))
  1216. {
  1217. KycStaticData sd = _requestServices.LoadKycStaticData("kyc");
  1218. if (sd != null)
  1219. {
  1220. jsonRx.ErrorCode = "0";
  1221. jsonRx.Msg = "success";
  1222. jsonRx.Data = sd;
  1223. Log.Debug("LoadFormStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1224. return jsonRx;
  1225. }
  1226. Log.Debug("LoadFormStaticData | Returning null while calling DB");
  1227. jsonRx.SetResponse("1", "Error occured", null);
  1228. return jsonRx;
  1229. }
  1230. else if (type.ToLower().Equals("login-kyc"))
  1231. {
  1232. LocateBusiness locateBusiness = new LocateBusiness();
  1233. var r = locateBusiness.LoadKycStaticData();
  1234. if (r != null)
  1235. {
  1236. jsonRx.ErrorCode = "0";
  1237. jsonRx.Msg = "success";
  1238. jsonRx.Data = r;
  1239. Log.Debug("LoadFormStaticData-login-kyc | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1240. return jsonRx;
  1241. }
  1242. Log.Debug("LoadFormStaticData | Returning null while calling DB");
  1243. jsonRx.SetResponse("1", "Error occured", null);
  1244. return jsonRx;
  1245. }
  1246. Log.Debug("LoadFormStaticData | Error occurred while specifying the type, Type mismatch error.");
  1247. return jsonRx;
  1248. }
  1249. catch (Exception ex)
  1250. {
  1251. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1252. jsonRx.SetResponse("1", "Error occurred while loading static data for." + type);
  1253. return jsonRx;
  1254. }
  1255. }
  1256. public JsonRxResponse SaveReceiver(ReceiverModel model, string userId)
  1257. {
  1258. JsonRxResponse jsonRx = new JsonRxResponse();
  1259. try
  1260. {
  1261. jsonRx.SetResponse("1", "error");
  1262. var receiver = _requestServices.SaveReceiver(model, userId);
  1263. Log.Debug("SaveReceiver | DB RESPONSE : " + JsonConvert.SerializeObject(receiver));
  1264. if (!receiver.ErrorCode.Equals("0"))
  1265. {
  1266. jsonRx.SetResponse("1", receiver.Msg);
  1267. jsonRx.Data = null;
  1268. return jsonRx;
  1269. }
  1270. jsonRx.SetResponse("0", "success");
  1271. jsonRx.Data = receiver;
  1272. return jsonRx;
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1277. jsonRx.SetResponse("1", "Error occurred while saving the receiver details.");
  1278. jsonRx.Data = null;
  1279. return jsonRx;
  1280. }
  1281. }
  1282. public JsonRxResponse GetReceiverDetail(string id)
  1283. {
  1284. JsonRxResponse jsonRx = new JsonRxResponse();
  1285. try
  1286. {
  1287. jsonRx.SetResponse("1", "No receiver", null);
  1288. var receiver = _requestServices.GetReceiverDetail(id);
  1289. Log.Debug("GetReceiverDetail | DB RESPONSE : " + JsonConvert.SerializeObject(receiver));
  1290. if (receiver != null)
  1291. {
  1292. jsonRx.SetResponse("0", "Success", null);
  1293. jsonRx.Data = receiver;
  1294. }
  1295. return jsonRx;
  1296. }
  1297. catch (Exception ex)
  1298. {
  1299. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1300. jsonRx.SetResponse("1", "Error occurred while fetching the specific receiver details.");
  1301. return jsonRx;
  1302. }
  1303. }
  1304. public JsonRxResponse GetReceiversByCustomer(string customer, string customerId, string search)
  1305. {
  1306. JsonRxResponse jsonRx = new JsonRxResponse();
  1307. try
  1308. {
  1309. jsonRx.SetResponse("1", "No receiver", null);
  1310. var ls = _requestServices.GetReceiversByCustomer(customer, search);
  1311. List<AccountDetails> lsAccount = GetCustomerPaymentMethods(customerId);
  1312. LoadReceiverAccount lra = new LoadReceiverAccount();
  1313. lra.AccountList = lsAccount;
  1314. lra.Receivers = ls;
  1315. if (lra == null)
  1316. {
  1317. Log.Debug("GetReceiversByCustomer | Returning null while fetching the list of receivers.");
  1318. return jsonRx;
  1319. }
  1320. jsonRx.SetResponse("0", ls.Count.ToString() + " receiver", null);
  1321. jsonRx.Data = lra;
  1322. Log.Debug("GetReceiversByCustomer | DB RESPONSE AFTER PARSING : " + JsonConvert.SerializeObject(jsonRx));
  1323. return jsonRx;
  1324. }
  1325. catch (Exception ex)
  1326. {
  1327. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1328. jsonRx.SetResponse("1", "Error occurred while fetching the list of receivers.");
  1329. return jsonRx;
  1330. }
  1331. }
  1332. public JsonRxResponse RemoveReceiver(string userId, string receiverId)
  1333. {
  1334. JsonRxResponse res = new JsonRxResponse();
  1335. try
  1336. {
  1337. res = _requestServices.RemoveReceiver(userId, receiverId);
  1338. Log.Debug("RemoveReceiver | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1339. if (res.ErrorCode == "0")
  1340. {
  1341. return res;
  1342. }
  1343. Log.Debug("RemoveReceiver | Error occurred while deleting the receiver." + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
  1344. return res;
  1345. }
  1346. catch (Exception ex)
  1347. {
  1348. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1349. res.SetResponse("1", "Error occurred while removing the receiver.");
  1350. return res;
  1351. }
  1352. }
  1353. public JsonRxResponse LoadKycStaticData(string type)
  1354. {
  1355. JsonRxResponse jsonRx = new JsonRxResponse();
  1356. try
  1357. {
  1358. var kycStaticData = _requestServices.LoadKycStaticData(type);
  1359. if (kycStaticData != null)
  1360. {
  1361. jsonRx.SetResponse("0", "Success");
  1362. jsonRx.Data = kycStaticData;
  1363. Log.Debug("LoadKycStaticData | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1364. return jsonRx;
  1365. }
  1366. Log.Debug("LoadKycStaticData | Returning null while fetching from DB.");
  1367. jsonRx.SetResponse("1", "Cound not fetch the data.");
  1368. return jsonRx;
  1369. }
  1370. catch (Exception ex)
  1371. {
  1372. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1373. jsonRx.SetResponse("1", "Cound not fetch the data.");
  1374. return jsonRx;
  1375. }
  1376. }
  1377. public JsonRxResponse GenerateReceipt(string tranId, string notice = "N")
  1378. {
  1379. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1380. JsonRxResponse jsonRx = new JsonRxResponse();
  1381. try
  1382. {
  1383. var tranResponse = _requestServices.GenerateReceipt(tranId, notice);
  1384. if (tranResponse != null)
  1385. {
  1386. jsonRx.SetResponse("0", "Success");
  1387. jsonRx.Data = tranResponse;
  1388. Log.Debug("GenerateReceipt | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1389. return jsonRx;
  1390. }
  1391. Log.Debug("GenerateReceipt | Returning null while fetching the receipt details.");
  1392. //jsonRx.SetResponse("1", "Unable to fetch the receipt details.");
  1393. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.GET_BRANCH_INFOS_SUCCESS.ToString(), lang);
  1394. return new JsonRxResponse { Msg = map.Message };
  1395. }
  1396. catch (Exception ex)
  1397. {
  1398. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1399. jsonRx.SetResponse("1", "Unable to fetch the receipt details.");
  1400. return jsonRx;
  1401. }
  1402. }
  1403. public JsonRxResponse GetNotificationList(string customerId)
  1404. {
  1405. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1406. JsonRxResponse jsonRx = new JsonRxResponse();
  1407. try
  1408. {
  1409. jsonRx = _requestServices.GetNotificationList(customerId);
  1410. Log.Debug("GetNotificationList | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1411. return jsonRx;
  1412. }
  1413. catch (Exception ex)
  1414. {
  1415. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1416. jsonRx.SetResponse("1", "Error occurred while loading notification.");
  1417. return jsonRx;
  1418. }
  1419. }
  1420. public JsonRxResponse UpdateNotification(string rowId)
  1421. {
  1422. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1423. JsonRxResponse jsonRx = new JsonRxResponse();
  1424. try
  1425. {
  1426. jsonRx = _requestServices.UpdateNotification(rowId);
  1427. Log.Debug("UpdateNotification | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1428. return jsonRx;
  1429. }
  1430. catch (Exception ex)
  1431. {
  1432. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1433. jsonRx.SetResponse("1", "Error occurred while loading notification.");
  1434. return jsonRx;
  1435. }
  1436. }
  1437. public JsonRxResponse GetTransactionHistory(DateFilterParams search, string userId)
  1438. {
  1439. JsonRxResponse jsonRx = new JsonRxResponse();
  1440. if (search == null)
  1441. {
  1442. search = new DateFilterParams();
  1443. }
  1444. try
  1445. {
  1446. jsonRx.SetResponse("1", "No transaction details found.");
  1447. var litranHistoryResponse = _requestServices.GetTransactionHistory(search, userId);
  1448. if (litranHistoryResponse == null)
  1449. {
  1450. Log.Debug("GetTransactionHistory | Returning null while fetching the list of transaction details.");
  1451. return jsonRx;
  1452. }
  1453. jsonRx.SetResponse("0", litranHistoryResponse.Count.ToString() + " paid txn");
  1454. jsonRx.Data = litranHistoryResponse;
  1455. Log.Debug("GetTransactionHistory | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1456. return jsonRx;
  1457. }
  1458. catch (Exception ex)
  1459. {
  1460. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1461. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.GET_TRANSACTION_HISTORY_FAIL.ToString(), lang);
  1462. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1463. jsonRx.SetResponse("1", map.Message);
  1464. return jsonRx;
  1465. }
  1466. }
  1467. public JsonRxResponse OldUserRegister(OldUserRegisterModel oldUserRegister)
  1468. {
  1469. //var lang ="EN";
  1470. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1471. JsonRxResponse res = new JsonRxResponse();
  1472. try
  1473. {
  1474. string pwd = oldUserRegister.Password;
  1475. string txnPwd = oldUserRegister.TxnPin;
  1476. string Confirmpwd = oldUserRegister.ConfirmPassword;
  1477. string txnConfirmpwd = oldUserRegister.ConfirmTxnPin;
  1478. string enumString = string.Empty;
  1479. if (!oldUserRegister.UserId.IsValidEmail())
  1480. {
  1481. Log.Debug("OldUserRegister.IsValidatedForm | Validate Email : Failed " + Convert.ToString(oldUserRegister.UserId));
  1482. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_7.ToString(), lang);
  1483. res.SetResponse("1", map.Message);
  1484. return res;
  1485. }
  1486. if (pwd != Confirmpwd)
  1487. {
  1488. // res.SetResponse("1", "Password does not match with confirm password");
  1489. enumString = RESPONSE_MSG.OLD_USER_REGISTER_FAIL_8.ToString();
  1490. var map = Utilities.GetLanguageMapping(enumString, lang);
  1491. res.SetResponse("1", map.Message);
  1492. }
  1493. var verifyPwdResp = ValidatePassword(Confirmpwd);
  1494. Log.Debug("OldUserRegister.IsValidPassword | RESPONSE : " + JsonConvert.SerializeObject(verifyPwdResp));
  1495. if (verifyPwdResp.ErrorCode != "0")
  1496. {
  1497. return verifyPwdResp;
  1498. }
  1499. if (txnPwd != txnConfirmpwd)
  1500. {
  1501. // res.SetResponse("1", "Txn pin does not match with confirm txn pin");
  1502. enumString = RESPONSE_MSG.OLD_USER_REGISTER_FAIL_9.ToString();
  1503. var map = Utilities.GetLanguageMapping(enumString, lang);
  1504. res.SetResponse("1", map.Message);
  1505. // return new JsonRxResponse { ErrorCode = "1", Msg = map.Message };
  1506. // var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_9.ToString(), lang);
  1507. // res.SetResponse("1", map.Message);
  1508. return res;
  1509. }
  1510. if (string.IsNullOrWhiteSpace(txnPwd) || string.IsNullOrWhiteSpace(txnConfirmpwd))
  1511. {
  1512. //res.SetResponse("1", "Txn pin is missing");
  1513. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_10.ToString(), lang);
  1514. res.SetResponse("1", map.Message);
  1515. return res;
  1516. }
  1517. if (txnPwd.Length < 6)
  1518. {
  1519. // res.SetResponse("1", "Txn pin cannot be less than 6 characters");
  1520. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang);
  1521. res.SetResponse("1", map.Message);
  1522. return res;
  1523. }
  1524. res = _requestServices.OldUserRegister(oldUserRegister);
  1525. Log.Debug("OldUserRegister | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1526. return res;
  1527. }
  1528. catch (Exception ex)
  1529. {
  1530. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1531. res.SetResponse("1", "Error occurred while registering the customer.");
  1532. return res;
  1533. }
  1534. }
  1535. private JsonRxResponse ValidatePassword(string confirmpwd)
  1536. {
  1537. JsonRxResponse _resp = new JsonRxResponse() { ErrorCode = "0", Msg = "Success" };
  1538. if (string.IsNullOrEmpty(confirmpwd))
  1539. {
  1540. _resp.SetResponse("100", "Password can not be empty!");
  1541. return _resp;
  1542. }
  1543. if (confirmpwd.Length < 6)
  1544. {
  1545. _resp.SetResponse("100", "Password must be of atleast 6 digits!");
  1546. return _resp;
  1547. }
  1548. //if (!Regex.Match(confirmpwd, @"\d+").Success)
  1549. //{
  1550. // _resp.SetResponse("1", "Password must contain 1 number!");
  1551. // return _resp;
  1552. //}
  1553. //if (!Regex.Match(confirmpwd, @"[A-Z]").Success)
  1554. //{
  1555. // _resp.SetResponse("1", "Password must contain atleaset one capital letter!");
  1556. // return _resp;
  1557. //}
  1558. //if (!Regex.Match(confirmpwd, @"[!@#$%&*_+\-]").Success)
  1559. //{
  1560. // _resp.SetResponse("1", "Password must contain atleaset one special character!");
  1561. // return _resp;
  1562. //}
  1563. return _resp;
  1564. }
  1565. private JsonRxResponse CalculateAge(string dob)
  1566. {
  1567. JsonRxResponse _resp = new JsonRxResponse() { ErrorCode = "0", Msg = "Success" };
  1568. if (DateTime.TryParse(dob, out DateTime dateOfBirth))
  1569. {
  1570. DateTime today = DateTime.Today;
  1571. int age = today.Year - dateOfBirth.Year;
  1572. if (dateOfBirth.Date > today.AddYears(-age))
  1573. age--;
  1574. if (age < 18)
  1575. {
  1576. _resp.SetResponse("100", "User must me at least 18 years old to register with IME London!");
  1577. return _resp;
  1578. }
  1579. }
  1580. return _resp;
  1581. }
  1582. public JsonRxResponse NewUserRegister(NewUserRegisterModel newUserRegister)
  1583. {
  1584. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1585. JsonRxResponse res = new JsonRxResponse();
  1586. try
  1587. {
  1588. string pwd = newUserRegister.Password;
  1589. string Confirmpwd = newUserRegister.ConfirmPassword;
  1590. string enumString = string.Empty;
  1591. string dob = newUserRegister.DOB;
  1592. if (!newUserRegister.UserId.IsValidEmail())
  1593. {
  1594. enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_4.ToString();
  1595. var map = Utilities.GetLanguageMapping(enumString, lang);
  1596. res.SetResponse("100", map.Message);
  1597. return res;
  1598. }
  1599. if (string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(Confirmpwd))
  1600. {
  1601. enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_6.ToString();
  1602. var map = Utilities.GetLanguageMapping(enumString, lang);
  1603. res.SetResponse("100", map.Message);
  1604. return res;
  1605. }
  1606. if (!String.Equals(pwd, Confirmpwd, StringComparison.CurrentCulture))
  1607. {
  1608. enumString = RESPONSE_MSG.NEW_USER_REGISTER_FAIL_5.ToString();
  1609. var map = Utilities.GetLanguageMapping(enumString, lang);
  1610. res.SetResponse("100", map.Message);
  1611. return res;
  1612. }
  1613. var verifyPwdResp = ValidatePassword(Confirmpwd);
  1614. Log.Debug("NewUserRegister.IsValidPassword | RESPONSE : " + JsonConvert.SerializeObject(verifyPwdResp));
  1615. if (verifyPwdResp.ErrorCode != "0")
  1616. {
  1617. return verifyPwdResp;
  1618. }
  1619. var calculateAge = CalculateAge(dob);
  1620. if (calculateAge.ErrorCode != "0")
  1621. {
  1622. Log.Debug("NewUserRegister.IsNotValidAge | RESPONSE : " + JsonConvert.SerializeObject(calculateAge));
  1623. return calculateAge;
  1624. }
  1625. //var calculateAge = CalculateAge(dob);
  1626. Log.Debug("NewUserRegister.IsValidAge | RESPONSE : " + JsonConvert.SerializeObject(calculateAge));
  1627. if (calculateAge.ErrorCode != "0")
  1628. {
  1629. return calculateAge;
  1630. }
  1631. newUserRegister.MobileNumber = newUserRegister.MobileNumber.getUKFormattedNumber();
  1632. res = _requestServices.NewUserRegister(newUserRegister);
  1633. Log.Debug("NewUserRegister | completed with db response. " + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
  1634. return res;
  1635. }
  1636. catch (Exception ex)
  1637. {
  1638. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1639. res.SetResponse("1", "Error occurred while registering the customer.");
  1640. return res;
  1641. }
  1642. }
  1643. public JsonRxResponse OldUserAccessRequest(OldUserAccessRequestModel oldUserAccessRequest)
  1644. {
  1645. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1646. JsonRxResponse res = new JsonRxResponse();
  1647. string enumString = string.Empty;
  1648. try
  1649. {
  1650. if (!Utilities.ConvertToGlobalFormat(oldUserAccessRequest.Dob))
  1651. {
  1652. Log.DebugFormat("OldUserAccessRequest.IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(oldUserAccessRequest.Dob));
  1653. res.SetResponse("1", "Please input your dob in correct format.");
  1654. return res;
  1655. }
  1656. if (!oldUserAccessRequest.IdNumber.IsValidNumber())
  1657. {
  1658. enumString = RESPONSE_MSG.OLD_USER_ACCESS_REQUEST_FAIL_4.ToString();
  1659. var map = Utilities.GetLanguageMapping(enumString, lang);
  1660. res.SetResponse("1", map.Message);
  1661. return res;
  1662. }
  1663. res = _requestServices.OldUserAccessRequest(oldUserAccessRequest);
  1664. Log.Debug("OldUserAccessRequest | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1665. if (res.ErrorCode == "0")
  1666. {
  1667. res.Data = new
  1668. {
  1669. referenceId = res.Id,
  1670. generatedUserId = res.Extra
  1671. };
  1672. }
  1673. return res;
  1674. }
  1675. catch (Exception ex)
  1676. {
  1677. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1678. res.SetResponse("1", "Error occurred while registering the customer.");
  1679. return res;
  1680. //var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_ACCESS_REQUEST_FAIL_1.ToString(), lang);
  1681. // return new JsonRxResponse { ErrorCode ="1", Msg = map.Message}; ;
  1682. }
  1683. }
  1684. public JsonRxResponse RegisterCustomer(CustomerRegisterParameters registerParam)
  1685. {
  1686. Log.Debug("RegisterCustomer | user trying to sign-up the system." + JsonConvert.SerializeObject(registerParam));
  1687. JsonRxResponse res = new JsonRxResponse();
  1688. try
  1689. {
  1690. if (!Utilities.ConvertToGlobalFormat(registerParam.Dob))
  1691. {
  1692. Log.DebugFormat("IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(registerParam.Dob));
  1693. res.SetResponse("1", "Please input your dob in correct format.");
  1694. return res;
  1695. }
  1696. //string pwd = StringExtension.ToVirtualKeyDecryptString(registerParam.Password);
  1697. string pwd = registerParam.Password;
  1698. //string Confirmpwd = StringExtension.ToVirtualKeyDecryptString(registerParam.ConfirmPassword);
  1699. string Confirmpwd = registerParam.ConfirmPassword;
  1700. if (pwd != Confirmpwd)
  1701. {
  1702. res.SetResponse("1", "Password does not match with confirm password");
  1703. return res;
  1704. }
  1705. if (string.IsNullOrWhiteSpace(pwd) || string.IsNullOrWhiteSpace(Confirmpwd))
  1706. {
  1707. res.SetResponse("1", "Password is missing");
  1708. return res;
  1709. }
  1710. if (pwd.Length < 6)
  1711. {
  1712. res.SetResponse("1", "Password cannot be less than 6 characters");
  1713. return res;
  1714. }
  1715. var regData = new ValidationModel
  1716. {
  1717. Dob = registerParam.Dob,
  1718. Email = registerParam.Username,
  1719. Password = pwd,
  1720. ConfirmPassword = Confirmpwd
  1721. };
  1722. registerParam.Password = pwd;
  1723. registerParam.ConfirmPassword = Confirmpwd;
  1724. res = _requestServices.RegisterCustomer(registerParam);
  1725. if (res.ErrorCode == "0")
  1726. {
  1727. Log.Debug("RegisterCustomer | Register Customer Success...");
  1728. if (registerParam.Username.IsValidEmail())
  1729. {
  1730. //EmailParameters _emailParams = new EmailParameters()
  1731. //{
  1732. // To = registerParam.Username,
  1733. // MsgSubject = "Customer Registration Sign Up",
  1734. // MsgBody = "Dear " + registerParam.Username + ",<br/>Thank you for registering, You are now successfully enrolled to the GME Remittance System."
  1735. //};
  1736. //Task.Run(() => GetStatic.SendEmail(_emailParams));
  1737. }
  1738. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1739. Task.Run(() => FcmNotifier.Notify(registerParam.fcmId, Languages.GetMessage("registration_success", lang), Languages.GetTitle("registration", lang)));
  1740. return res;
  1741. }
  1742. Log.Debug("RegisterCustomer | Error occurred while registering the customer." + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg);
  1743. return res;
  1744. }
  1745. catch (Exception ex)
  1746. {
  1747. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1748. res.SetResponse("1", "Error occurred while registering the customer.");
  1749. return res;
  1750. }
  1751. }
  1752. public JsonRxResponse CheckInfoAgree(string username)
  1753. {
  1754. JsonRxResponse res = new JsonRxResponse();
  1755. try
  1756. {
  1757. res = _requestServices.CheckInfoAgree(username);
  1758. Log.Debug("CheckInfoAgree | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1759. }
  1760. catch (Exception ex)
  1761. {
  1762. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1763. res.SetResponse("1", "Error occurred while password reset.");
  1764. return res;
  1765. }
  1766. return res;
  1767. }
  1768. public JsonRxResponse CustomerInfoAgree(string username, string agreeYn)
  1769. {
  1770. JsonRxResponse res = new JsonRxResponse();
  1771. try
  1772. {
  1773. if (string.IsNullOrEmpty(agreeYn))
  1774. {
  1775. return new JsonRxResponse { ErrorCode = "1", Msg = "The invalid agreeYn flag.", Id = username };
  1776. }
  1777. if (agreeYn.Equals("Y"))
  1778. {
  1779. // return new JsonRxResponse { ErrorCode = "1", Msg = "The user has not agreeded to the terms.", Id = username };
  1780. res = _requestServices.CustomerInfoAgree(username, "agree");
  1781. if (res.ErrorCode.Equals("0"))
  1782. {
  1783. // _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id);
  1784. res.Msg = "Thank you for completing your profile. You can now start sending transactions";
  1785. SendNotificationRequest pushNotificationRequest = new SendNotificationRequest()
  1786. {
  1787. IsBulkNotification = false,
  1788. UserName = username,
  1789. ProcessId = Guid.NewGuid().ToString(),
  1790. ProviderId = "CustomerInfoAgree",
  1791. NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(),
  1792. Recipients = new List<RecipientViewModel>()
  1793. {
  1794. new RecipientViewModel() { Address = res.Extra, NotificationContent = new NotificationDTO() }
  1795. },
  1796. Language = Convert.ToString(CallContext.GetData(Constants.Language))
  1797. };
  1798. //Task.Run(() => NotifierV2.SendNotification(pushNotificationRequest, NOTIFICATION_TYPE.PUSH_NOTIFICATION));
  1799. //SendNotificationRequest emailNotificationRequest = new SendNotificationRequest()
  1800. //{
  1801. // IsBulkNotification = false,
  1802. // UserName = username,
  1803. // ProcessId = Guid.NewGuid().ToString(),
  1804. // ProviderId = "CustomerInfoAgree",
  1805. // NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  1806. // Template = Common.Model.Enum.NotifyTemplate.KYC_VERIFICATION_EMAIL,
  1807. // Recipients = new List<RecipientViewModel>()
  1808. // {
  1809. // new RecipientViewModel() { Address= res.Extra , NotificationContent = new NotificationDTO() }
  1810. // },
  1811. // Language = Convert.ToString(CallContext.GetData(Constants.Language))
  1812. //};
  1813. //Task.Run(() => NotifierV2.SendNotification(emailNotificationRequest, NOTIFICATION_TYPE.EMAIL));
  1814. }
  1815. Log.Debug("CustomerInfoAgree.Agree | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1816. }
  1817. //else if (agreeYn.Equals("N"))
  1818. //{
  1819. // res = _requestServices.CustomerInfoAgree(username, "agree-manual");
  1820. // Log.Debug("CustomerInfoAgree.Manual | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1821. //}
  1822. }
  1823. catch (Exception ex)
  1824. {
  1825. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1826. res.SetResponse("1", "Error occurred CustomerInfoAgree.");
  1827. return res;
  1828. }
  1829. return res;
  1830. }
  1831. public JsonRxResponse ResetPassword(PasswordReset pwdReset, string processId = "")
  1832. {
  1833. var lang = Convert.ToString(CallContext.GetData(Constants.Language));
  1834. JsonRxResponse res = new JsonRxResponse();
  1835. try
  1836. {
  1837. if (!Utilities.ConvertToGlobalFormat(pwdReset.Dob))
  1838. {
  1839. Log.DebugFormat("ResetPassword.IsValidatedForm | Validate Dob : Failed, {0}", Convert.ToString(pwdReset.Dob));
  1840. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.INVALID_DOB_FOR_RESETPASSWORD.ToString(), lang);
  1841. res.SetResponse("1", map.Message);
  1842. return res;
  1843. }
  1844. DateTime dateTime;
  1845. if (DateTime.TryParseExact(pwdReset.Dob, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime))
  1846. {
  1847. pwdReset.Dob = dateTime.ToString("yyyy-MM-dd");
  1848. }
  1849. if (!pwdReset.Username.IsValidEmail())
  1850. {
  1851. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.INVALID_EMAIL_FOR_RESETPASSWORD.ToString(), lang);
  1852. res.SetResponse("1", map.Message);
  1853. return res;
  1854. };
  1855. // var randomPassword = PasswordGenerator.GenerateRandomPassword();
  1856. var randomPassword = Utilities.GenerateRandomPin();
  1857. pwdReset.RandomPassword = randomPassword;
  1858. res = _requestServices.ResetPassword(pwdReset);
  1859. Log.Debug("ResetPassword | DB RESPONSE : " + JsonConvert.SerializeObject(res));
  1860. if (res.ErrorCode == "0")
  1861. {
  1862. bool emailSent = false;
  1863. bool smsSent = false;
  1864. try
  1865. {
  1866. List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
  1867. bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = res.Extra2 });
  1868. bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = pwdReset.Username });
  1869. bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword });
  1870. SendNotificationRequest request = new SendNotificationRequest()
  1871. {
  1872. IsBulkNotification = false,
  1873. UserName = pwdReset.Username,
  1874. ProcessId = processId,
  1875. ProviderId = "ResetPassword",
  1876. NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  1877. Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL,
  1878. Recipients = new List<RecipientViewModel>()
  1879. {
  1880. new RecipientViewModel()
  1881. {
  1882. NotificationContent = new NotificationDTO() {
  1883. Body = JsonConvert.SerializeObject(bodyMappings),
  1884. //Title will be set by mapping json
  1885. },
  1886. Address= pwdReset.Username
  1887. }
  1888. }
  1889. };
  1890. Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
  1891. var resEmail = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  1892. Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(resEmail));
  1893. emailSent = true;
  1894. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms";
  1895. var mobileNo = "";
  1896. if (!string.IsNullOrEmpty(res.Extra3))
  1897. {
  1898. mobileNo = getSenderFormattedNumber(res.Extra3);
  1899. SendSMSApiService _sendAPI = new SendSMSApiService();
  1900. StringBuilder s = new StringBuilder();
  1901. s.AppendLine($"Dear { res.Extra2}");
  1902. s.AppendLine($"We received your password reset request and your new credentials are");
  1903. s.AppendLine($"Login ID: { pwdReset.Username}");
  1904. s.AppendLine($"Password: { pwdReset.RandomPassword}");
  1905. s.AppendLine("Regards, IME London");
  1906. SMSRequestModel _req = new SMSRequestModel
  1907. {
  1908. ProviderId = "onewaysms",
  1909. MobileNumber = mobileNo,
  1910. SMSBody = s.ToString(),
  1911. ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
  1912. RequestedBy = pwdReset.Username,
  1913. UserName = pwdReset.Username,
  1914. method = "send",
  1915. ControlNo = "", // GetControlNo()
  1916. };
  1917. Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
  1918. APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
  1919. Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
  1920. smsSent = true;
  1921. }
  1922. }
  1923. catch (Exception ex)
  1924. {
  1925. Log.Error("ResetPassword.SendNotification", ex);
  1926. }
  1927. if (emailSent || smsSent)
  1928. {
  1929. res.ErrorCode = "0";
  1930. res.SetResponse("0", "Reset password email/sms has been sent.");
  1931. return res;
  1932. }
  1933. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.SEND_EMAIL_FOR_RESETPASSWORD_SUCCESS.ToString(), lang);
  1934. return new JsonRxResponse { ErrorCode = "0", Msg = map.Message };
  1935. // return res;
  1936. }
  1937. return res;
  1938. }
  1939. catch (Exception ex)
  1940. {
  1941. Log.Error("ResetPassword", ex);
  1942. res.SetResponse("1", "Error occurred while password reset.");
  1943. return res;
  1944. }
  1945. }
  1946. public JsonRxResponse RefreshCustomerInformation(UserModel user)
  1947. {
  1948. JsonRxResponse jsonRx = new JsonRxResponse();
  1949. try
  1950. {
  1951. jsonRx = _requestServices.RefreshCustomerInformation(user);
  1952. Log.Debug("RefreshCustomerInformation | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1953. return jsonRx;
  1954. }
  1955. catch (Exception ex)
  1956. {
  1957. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1958. jsonRx.SetResponse("1", "Error occurred while calling the refresh customer information.");
  1959. return jsonRx;
  1960. }
  1961. }
  1962. public JsonRxResponse GetWalletStatement(DateFilterParams search, string userId)
  1963. {
  1964. JsonRxResponse jsonRx = new JsonRxResponse();
  1965. if (search == null)
  1966. {
  1967. search = new DateFilterParams();
  1968. }
  1969. try
  1970. {
  1971. //jsonRx.SetResponse("0", "No wallet statement found.");
  1972. var liWalletStmtResponse = _requestServices.GetWalletStatement(search, userId);
  1973. if (liWalletStmtResponse == null)
  1974. {
  1975. jsonRx.ErrorCode = "1";
  1976. jsonRx.Msg = "No Record(s) Found!";
  1977. jsonRx.Data = new System.Collections.ArrayList();
  1978. Log.Debug("GetWalletStatement | Returning null while fetching the list of wallet statements.");
  1979. return jsonRx;
  1980. }
  1981. jsonRx.ErrorCode = "0";
  1982. jsonRx.Data = liWalletStmtResponse;
  1983. return jsonRx;
  1984. }
  1985. catch (Exception ex)
  1986. {
  1987. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  1988. jsonRx.SetResponse("1", "Error occurred while fetching the list of transaction details.");
  1989. return jsonRx;
  1990. }
  1991. }
  1992. public JsonRxResponse ChangePassword(ChangePassword changePwd)
  1993. {
  1994. JsonRxResponse jsonRx = new JsonRxResponse();
  1995. try
  1996. {
  1997. jsonRx = _requestServices.ChangePassword(changePwd);
  1998. Log.Debug("ChangePassword | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  1999. return jsonRx;
  2000. }
  2001. catch (Exception ex)
  2002. {
  2003. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  2004. jsonRx.SetResponse("1", "Could not change the password.");
  2005. return jsonRx;
  2006. }
  2007. }
  2008. public List<AccountDetails> GetCustomerPaymentMethods(string customerId)
  2009. {
  2010. List<AccountDetails> lsAccount = _requestServices.GetPaymentAccountsByCustomer(customerId);
  2011. lsAccount.ForEach(x => x.KftcAccountId = Crypto.Encrypt(x.KftcAccountId, Utilities.ReadWebConfig("ktft_client_info_salt", "")));
  2012. return lsAccount;
  2013. }
  2014. public JsonRxResponse RealtimeValidation(RealtimeValidationModel model, string lang = "")
  2015. {
  2016. JsonRxResponse jsonRx = new JsonRxResponse();
  2017. try
  2018. {
  2019. if (string.IsNullOrEmpty(model.IdNumber))
  2020. {
  2021. jsonRx.ErrorCode = "1";
  2022. var map = Utilities.GetLanguageMapping(!string.IsNullOrEmpty(model.IdType) && model.IdType.Equals(ID_TYPE.DRIVING_LICENCE.ToString()) ?
  2023. RESPONSE_MSG.VALIDATION_FAIL_6.ToString() : RESPONSE_MSG.VALIDATION_FAIL_3.ToString(), lang);
  2024. jsonRx.Msg = map.Message;
  2025. return jsonRx;
  2026. }
  2027. if (!string.IsNullOrEmpty(model.IdType))
  2028. {
  2029. if (string.IsNullOrEmpty(model.FullName))
  2030. {
  2031. jsonRx.ErrorCode = "1";
  2032. jsonRx.Msg = "Full Name is required";
  2033. return jsonRx;
  2034. }
  2035. if (!string.IsNullOrEmpty(model.FullName))
  2036. {
  2037. if (!Regex.IsMatch(model.FullName, "^[A-Za-z]+[A-Za-z ]*$"))
  2038. {
  2039. jsonRx.ErrorCode = "1";
  2040. jsonRx.Msg = "Invalid Full name ";
  2041. return jsonRx;
  2042. }
  2043. }
  2044. if (string.IsNullOrEmpty(model.DOB))
  2045. {
  2046. jsonRx.ErrorCode = "1";
  2047. jsonRx.Msg = "DOB is empty.";
  2048. return jsonRx;
  2049. }
  2050. if (!string.IsNullOrEmpty(model.DOB))
  2051. {
  2052. DateTime data = new DateTime();
  2053. if (!DateTime.TryParse(model.DOB, out data))
  2054. {
  2055. jsonRx.ErrorCode = "1";
  2056. jsonRx.Msg = "Invalid DOB Format";
  2057. return jsonRx;
  2058. }
  2059. else
  2060. {
  2061. if (!Utilities.ConvertToGlobalFormat(model.DOB))
  2062. {
  2063. model.DOB = DateTime.Now.ToString("yyyyyMMdd");
  2064. }
  2065. else
  2066. model.DOB = data.ToString("yyyyyMMdd");
  2067. }
  2068. }
  2069. }
  2070. if (!string.IsNullOrEmpty(model.IdType) && model.IdType.Equals(ID_TYPE.DRIVING_LICENCE.ToString()))
  2071. {
  2072. if (!model.IdNumber.IsValidDrivingNumber())
  2073. {
  2074. jsonRx.ErrorCode = "1";
  2075. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.VALIDATION_FAIL_5.ToString(), lang);
  2076. jsonRx.Msg = map.Message;
  2077. return jsonRx;
  2078. }
  2079. }
  2080. else if (!model.IdNumber.IsValidNumber())
  2081. {
  2082. jsonRx.ErrorCode = "1";
  2083. var map = Utilities.GetLanguageMapping(RESPONSE_MSG.VALIDATION_FAIL_4.ToString(), lang);
  2084. jsonRx.Msg = map.Message;
  2085. return jsonRx;
  2086. }
  2087. jsonRx = _requestServices.RealtimeValidation(model);
  2088. return jsonRx;
  2089. }
  2090. catch (Exception ex)
  2091. {
  2092. Log.Error("RealtimeValidation Error", ex);
  2093. jsonRx.SetResponse("1", "Could not perform realtime validation.");
  2094. return jsonRx;
  2095. }
  2096. }
  2097. public JsonRxResponse GetCDDI(string userId)
  2098. {
  2099. JsonRxResponse jsonRx = new JsonRxResponse();
  2100. try
  2101. {
  2102. jsonRx = _requestServices.GetCDDI(userId);
  2103. Log.Debug("GetCDDI | DB RESPONSE: " + JsonConvert.SerializeObject(jsonRx));
  2104. return jsonRx;
  2105. }
  2106. catch (Exception ex)
  2107. {
  2108. Log.Error("GetCDDI | EXCEPTION: ", ex);
  2109. jsonRx.SetResponse("1", "Error occurred while fetching the CDDI Info.");
  2110. return jsonRx;
  2111. }
  2112. }
  2113. public JsonRxResponse DynamicReceiverField(DynamicReceiverRequest dynamicReceiverRequest, string customerId)
  2114. {
  2115. var jsonResult = _requestServices.DynamicReceiverField(dynamicReceiverRequest, customerId);
  2116. if (jsonResult.ErrorCode == "0")
  2117. {
  2118. Log.Debug("Dynamic ReceiverField success.");
  2119. }
  2120. else
  2121. {
  2122. Log.Debug("Dynamic ReceiverField failed.");
  2123. }
  2124. return jsonResult;
  2125. }
  2126. public JsonRxResponse GetReceiverInformation(string customerId)
  2127. {
  2128. var jsonResult = _requestServices.GetReceiverInformation(customerId);
  2129. if (jsonResult.ErrorCode == "0")
  2130. {
  2131. Log.Debug("receiver ReceiverField success.");
  2132. var reciver = jsonResult.Data;
  2133. List<AccountDetails> lsAccount = null;//GetCustomerPaymentMethods(customerId);
  2134. jsonResult.Data = new { Receivers = reciver, accounts = lsAccount };
  2135. }
  2136. else
  2137. {
  2138. Log.Debug("GetReceiverInformation | RESPONSE: " + JsonConvert.SerializeObject(jsonResult));
  2139. }
  2140. return jsonResult;
  2141. }
  2142. public JsonRxResponse AddReceiver(string customerId, ReceiverInfoModel receiver)
  2143. {
  2144. var jsonResult = new JsonRxResponse();
  2145. try
  2146. {
  2147. if (receiver.deviceType.ToLower().Equals("ios"))
  2148. {
  2149. List<DymanicField> dymanicFields = new List<DymanicField>();
  2150. List<ReceiverField> list = new List<ReceiverField>();
  2151. var dt = _requestServices.GetReceiverFields(receiver);
  2152. if (dt != null)
  2153. {
  2154. foreach (DataRow item in dt.Rows)
  2155. {
  2156. list.Add(new ReceiverField()
  2157. {
  2158. Field = findMapString(item["field"].ToString()),
  2159. FieldRequired = item["fieldRequired"].ToString(),
  2160. MinLength = int.Parse(item["minFieldLength"].ToString()),
  2161. MaxLength = int.Parse(item["maxFieldLength"].ToString())
  2162. });
  2163. }
  2164. }
  2165. var props = Utilities.GetPropertiesNameOfClass(receiver);
  2166. var requiredList = props.Where(x => list.Any(z => x.Key.ToLower() == z.Field.ToLower()))
  2167. .Where(y => string.IsNullOrEmpty(y.Value)).ToList(); // case when Field Value empty
  2168. //var pLength = props.SingleOrDefault(p => p.Key.ToLower().Equals("mobile")).Value.Length;
  2169. //var rLength = list.SingleOrDefault(p => p.Field.ToLower().Equals("mobile")).MinLength;
  2170. //if (pLength < rLength)
  2171. // requiredList.Add(new KeyValuePair() { Key = "mobile" });
  2172. if (requiredList.Count > 0)
  2173. {
  2174. // string.Format("Required Fields:-" , string.Join(", ", requiredList.Select(x => x.Key).ToList()));
  2175. jsonResult.SetResponse("100", string.Format("Required Fields:-\r\n{0}", string.Join("\r\n", requiredList.Select(x => findMapKeyValue(x.Key)).ToList())));
  2176. return jsonResult;
  2177. }
  2178. }
  2179. if (!string.IsNullOrWhiteSpace(receiver.fullName))
  2180. {
  2181. var str = receiver.fullName.Split(' ');
  2182. if (str.Length.Equals(2))
  2183. {
  2184. receiver.firstName = str[0];
  2185. receiver.lastName = str[1];
  2186. }
  2187. else if (str.Length > 2)
  2188. {
  2189. receiver.firstName = str[0];
  2190. receiver.middleName = str[1];
  2191. var ls = "";
  2192. for (int i = 2; i < str.Length; i++)
  2193. {
  2194. ls = (ls + str[i] + " ").Trim();
  2195. }
  2196. receiver.lastName = ls;
  2197. }
  2198. else
  2199. {
  2200. receiver.firstName = receiver.fullName;
  2201. }
  2202. }
  2203. if (receiver.countryId == "16")
  2204. {
  2205. //JsonRxResponse rxResponse = new JsonRxResponse() { ErrorCode = "0", Extra2 = receiver.mobile };
  2206. //string mobileFirst = receiver.mobile.Substring(0, 1);
  2207. string MobN = receiver.mobile.Substring(4, 1);
  2208. if (MobN == "0")
  2209. {
  2210. if (receiver.mobile.Length < 14)
  2211. {
  2212. jsonResult.ErrorCode = "1";
  2213. jsonResult.Msg = "Invalid Mobile Number provided!";
  2214. return jsonResult;
  2215. }
  2216. else if (receiver.mobile.Length > 14)
  2217. {
  2218. jsonResult.ErrorCode = "1";
  2219. jsonResult.Msg = "Invalid Mobile Number length provided!";
  2220. return jsonResult;
  2221. }
  2222. }
  2223. }
  2224. if (receiver.payoutPartner == "394130" && receiver.paymentMethod.id == "13" && receiver.country == "BANGLADESH")
  2225. {
  2226. var mobileNumberValidate = Regex.Replace(receiver.agent.accountNo, @"[^\d]", "");
  2227. var countryCode = mobileNumberValidate.Substring(0, 3);
  2228. if (countryCode != "880")
  2229. {
  2230. jsonResult.SetResponse("1", "Invalid country code passed in BKash Wallet Number!");
  2231. return jsonResult;
  2232. }
  2233. if (mobileNumberValidate.Length != 13)
  2234. {
  2235. jsonResult.SetResponse("1", "Invalid BKash Wallet Number!");
  2236. return jsonResult;
  2237. }
  2238. }
  2239. if (receiver.payoutPartner == "394434")
  2240. {
  2241. var mobileNumberValidate = Regex.Replace(receiver.mobile, @"[^\d]", "");
  2242. mobileNumberValidate = mobileNumberValidate.Replace("855", "");
  2243. var countryCode = mobileNumberValidate.Substring(0, 1);
  2244. if (countryCode != "0")
  2245. {
  2246. jsonResult.SetResponse("1", "Invalid Cambodia Number format!");
  2247. return jsonResult;
  2248. }
  2249. if (mobileNumberValidate.Length < 9 | mobileNumberValidate.Length > 12)
  2250. {
  2251. jsonResult.SetResponse("1", "Invalid Cambodia Number Length!");
  2252. return jsonResult;
  2253. }
  2254. }
  2255. //if (receiver.address.Contains("@") && receiver.address.IsValidEmail())
  2256. //{
  2257. // jsonResult.SetResponse("1", "Please input valid receiver address!");
  2258. // return jsonResult;
  2259. //}
  2260. jsonResult = _requestServices.AddReceiver(customerId, receiver);
  2261. if (jsonResult.ErrorCode == "0")
  2262. {
  2263. var rec = _requestServices.GetReceiver(customerId, jsonResult.Id);
  2264. jsonResult.Data = rec;
  2265. Log.DebugFormat("AddReceiver | RESPONSE : {0}", JsonConvert.SerializeObject(jsonResult));
  2266. }
  2267. else
  2268. {
  2269. Log.Debug("receiver ReceiverField failed. | " + JsonConvert.SerializeObject(jsonResult));
  2270. }
  2271. }
  2272. catch (Exception ex)
  2273. {
  2274. Log.Error("AddReceiver", ex);
  2275. jsonResult.SetResponse("1", "Something Went Wrong, Please Try Again!!");
  2276. return jsonResult;
  2277. }
  2278. return jsonResult;
  2279. }
  2280. private Dictionary<string, string> GetmappingList()
  2281. {
  2282. Dictionary<string, string> mapping = new Dictionary<string, string>();
  2283. mapping.Add("Bank Name", "agent.id");
  2284. mapping.Add("Account No.", "agent.accountNo");
  2285. mapping.Add("Full Name", "fullName");
  2286. mapping.Add("First Name", "firstName");
  2287. mapping.Add("Middle Name", "middleName");
  2288. mapping.Add("Last Name", "lastName");
  2289. mapping.Add("Mobile Number", "mobile");
  2290. mapping.Add("City", "city");
  2291. mapping.Add("Address", "address");
  2292. mapping.Add("District", "district");
  2293. mapping.Add("Province", "state");
  2294. mapping.Add("Branch Name", "agent.branch.id");
  2295. mapping.Add("Id Type", "idType");
  2296. mapping.Add("ID Number", "idNumber");
  2297. mapping.Add("Realation Group", "relationship");
  2298. mapping.Add("Native Country", "nativeCountry");
  2299. // mapping.Add("Transfer Reason", "transferReason");
  2300. return mapping;
  2301. }
  2302. private string findMapString(string s)
  2303. {
  2304. string result = string.Empty;
  2305. var d = GetmappingList();
  2306. if (d.ContainsKey(s))
  2307. {
  2308. result = d.FirstOrDefault(x => x.Key.Equals(s)).Value;
  2309. }
  2310. return result;
  2311. }
  2312. private string findMapKeyValue(string s)
  2313. {
  2314. string result = string.Empty;
  2315. var d = GetmappingList();
  2316. if (d.ContainsValue(s))
  2317. {
  2318. result = d.FirstOrDefault(x => x.Value.Equals(s)).Key;
  2319. }
  2320. return result.Replace("Realation Group", "Relationship");
  2321. }
  2322. public JsonRxResponse ModifyReceiver(string customerId, string receiverId, ReceiverInfoModel receiver)
  2323. {
  2324. var jsonResult = new JsonRxResponse();
  2325. try
  2326. {
  2327. if (receiver.deviceType.ToLower().Equals("ios"))
  2328. {
  2329. List<DymanicField> dymanicFields = new List<DymanicField>();
  2330. List<ReceiverField> list = new List<ReceiverField>();
  2331. var dt = _requestServices.GetReceiverFields(receiver);
  2332. if (dt != null)
  2333. {
  2334. foreach (DataRow item in dt.Rows)
  2335. {
  2336. list.Add(new ReceiverField()
  2337. {
  2338. Field = findMapString(item["field"].ToString()),
  2339. FieldRequired = item["fieldRequired"].ToString(),
  2340. MinLength = int.Parse(item["minFieldLength"].ToString()),
  2341. MaxLength = int.Parse(item["maxFieldLength"].ToString())
  2342. });
  2343. }
  2344. }
  2345. var props = Utilities.GetPropertiesNameOfClass(receiver);
  2346. var requiredList = props.Where(x => list.Any(z => x.Key.ToLower() == z.Field.ToLower()))
  2347. .Where(y => string.IsNullOrEmpty(y.Value)).ToList(); // case when Field Value empty
  2348. //var pLength = props.SingleOrDefault(p => p.Key.ToLower().Equals("mobile")).Value.Length;
  2349. //var rLength = list.SingleOrDefault(p => p.Field.ToLower().Equals("mobile")).MinLength;
  2350. //if (pLength < rLength)
  2351. // requiredList.Add(new KeyValuePair() { Key = "mobile" });
  2352. if (requiredList.Count > 0)
  2353. {
  2354. // string.Format("Required Fields:-" , string.Join(", ", requiredList.Select(x => x.Key).ToList()));
  2355. jsonResult.SetResponse("1", string.Format("Required Fields:- {0}", string.Join(", ", requiredList.Select(x => findMapKeyValue(x.Key)).ToList())));
  2356. Log.Debug($"Receiver modify validation failed. { JsonConvert.SerializeObject(jsonResult)}");
  2357. return jsonResult;
  2358. }
  2359. }
  2360. if (!string.IsNullOrWhiteSpace(receiver.fullName))
  2361. {
  2362. var str = receiver.fullName.Split(' ');
  2363. if (str.Length.Equals(2))
  2364. {
  2365. receiver.firstName = str[0];
  2366. receiver.lastName = str[1];
  2367. }
  2368. else if (str.Length > 2)
  2369. {
  2370. receiver.firstName = str[0];
  2371. receiver.middleName = str[1];
  2372. var ls = "";
  2373. for (int i = 2; i < str.Length; i++)
  2374. {
  2375. ls = (ls + str[i] + " ").Trim();
  2376. }
  2377. receiver.lastName = ls;
  2378. }
  2379. else
  2380. {
  2381. receiver.firstName = receiver.fullName;
  2382. }
  2383. }
  2384. if (receiver.countryId == "16")
  2385. {
  2386. string MobN = receiver.mobile.Substring(4, 1);
  2387. if (MobN == "0")
  2388. {
  2389. if (receiver.mobile.Length < 14)
  2390. {
  2391. jsonResult.ErrorCode = "1";
  2392. jsonResult.Msg = "Invalid Mobile Number provided!";
  2393. return jsonResult;
  2394. }
  2395. else if (receiver.mobile.Length > 14)
  2396. {
  2397. jsonResult.ErrorCode = "1";
  2398. jsonResult.Msg = "Invalid Mobile Number length provided!";
  2399. return jsonResult;
  2400. }
  2401. }
  2402. }
  2403. if (receiver.payoutPartner == "394130" && receiver.paymentMethod.id == "13" && receiver.country == "BANGLADESH")
  2404. {
  2405. var mobileNumberValidate = Regex.Replace(receiver.agent.accountNo, @"[^\d]", "");
  2406. var countryCode = mobileNumberValidate.Substring(0, 3);
  2407. if (countryCode != "880")
  2408. {
  2409. jsonResult.SetResponse("1", "Invalid country code passed in BKash Wallet Number!");
  2410. return jsonResult;
  2411. }
  2412. if (mobileNumberValidate.Length != 13)
  2413. {
  2414. jsonResult.SetResponse("1", "Invalid BKash Wallet Number!");
  2415. return jsonResult;
  2416. }
  2417. }
  2418. if (receiver.payoutPartner == "394434")
  2419. {
  2420. var mobileNumberValidate = Regex.Replace(receiver.mobile, @"[^\d]", "");
  2421. mobileNumberValidate = mobileNumberValidate.Replace("855", "");
  2422. var countryCode = mobileNumberValidate.Substring(0, 1);
  2423. //if (countryCode != "0")
  2424. //{
  2425. // jsonResult.SetResponse("1", "Invalid Cambodia Number format!");
  2426. // return jsonResult;
  2427. //}
  2428. if (mobileNumberValidate.Length < 9 | mobileNumberValidate.Length > 12)
  2429. {
  2430. jsonResult.SetResponse("1", "Invalid Cambodia Number Length!");
  2431. return jsonResult;
  2432. }
  2433. }
  2434. jsonResult = _requestServices.ModifyReceiver(customerId, receiverId, receiver);
  2435. if (jsonResult.ErrorCode == "0")
  2436. {
  2437. Log.Debug($"receiver modified success. { JsonConvert.SerializeObject(jsonResult)}");
  2438. var rec = _requestServices.GetReceiver(customerId, jsonResult.Id);
  2439. jsonResult.Data = rec;
  2440. }
  2441. else
  2442. {
  2443. Log.Debug($"receiver modified failed. { JsonConvert.SerializeObject(jsonResult)}");
  2444. }
  2445. }
  2446. catch (Exception ex)
  2447. {
  2448. Log.Error("ModifyReceiver", ex);
  2449. jsonResult.SetResponse("1", "Something Went Wrong, Please Try Again!!");
  2450. return jsonResult;
  2451. }
  2452. return jsonResult;
  2453. }
  2454. public JsonRxResponse GetCountryServiceTypeList()
  2455. {
  2456. JsonRxResponse jsonRx = new JsonRxResponse();
  2457. try
  2458. {
  2459. var listCountriesServices = _requestServices.GetCountryServiceTypeList();
  2460. if (listCountriesServices == null || listCountriesServices.Count < 1)
  2461. {
  2462. Log.Debug("GetCountriesServices | Returning null while calling the GetCountriesServices to fetch the countries services.");
  2463. jsonRx.SetResponse("1", "Could not fetch the exrate data.");
  2464. return jsonRx;
  2465. }
  2466. jsonRx.SetResponse("0", "Success");
  2467. //var path = GetStatic.ReadWebConfig("ServiceType_Resource", "");
  2468. //var text = File.ReadAllText(path);
  2469. //List<ServiceTypeDetails> sd = JsonConvert.DeserializeObject<List<ServiceTypeDetails>>(text);
  2470. //line commented by arjun
  2471. //foreach (var item in listCountriesServices)
  2472. //{
  2473. // foreach (var countryName in item.countryName)
  2474. // {
  2475. // var lang = CallContext.GetData("lang").ToString();
  2476. // if (string.IsNullOrWhiteSpace(lang))
  2477. // {
  2478. // lang = "en";
  2479. // }
  2480. // foreach (var product in item.servicetypeAvailable) { var country =
  2481. // item.countryName ?? "English";
  2482. // var idx = sd.FindIndex(x => x.countryCode.ToLower() == lang.ToLower());
  2483. // var data = new ServiceTypeDetails(); if (idx < 0) { data = sd[sd.FindIndex(x =>
  2484. // x.countryCode == "en")]; } else { data = sd[idx]; }
  2485. // if (product.text.ToLower().Equals("Cash Payment".ToLower()))
  2486. // {
  2487. // product.description = data.cashPayment;
  2488. // }
  2489. // else if (product.text.ToLower().Equals("Bank Deposit".ToLower()))
  2490. // {
  2491. // product.description = data.bankDeposit;
  2492. // }
  2493. // else if (product.text.ToLower().Equals("Mobile Wallet".ToLower()))
  2494. // {
  2495. // product.description = data.mobileWallet;
  2496. // }
  2497. // else if (product.text.ToLower().Equals("Home Delivery".ToLower()))
  2498. // {
  2499. // product.description = data.homeDelivery;
  2500. // }
  2501. // else if (product.text.ToLower().Equals("Card Payment".ToLower()))
  2502. // {
  2503. // product.description = data.cardPayment;
  2504. // }
  2505. // }
  2506. // }
  2507. //}
  2508. jsonRx.Data = listCountriesServices;
  2509. Log.Debug("GetCountriesServices | Calling GetCountriesServices Success...");
  2510. return jsonRx;
  2511. }
  2512. catch (Exception ex)
  2513. {
  2514. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  2515. jsonRx.SetResponse("1", "Could not fetch the countries service details.");
  2516. return jsonRx;
  2517. }
  2518. }
  2519. /* 2019.09 @Dana */
  2520. public JsonRxResponse GetDomesticTransactionHistory(DateFilterParams search, string userId)
  2521. {
  2522. JsonRxResponse jsonRx = new JsonRxResponse();
  2523. if (search == null)
  2524. {
  2525. search = new DateFilterParams();
  2526. }
  2527. try
  2528. {
  2529. jsonRx.SetResponse("1", "No transaction details found.");
  2530. var litranHistoryResponse = _requestServices.GetDomesticTransactionHistory(search, userId);
  2531. if (litranHistoryResponse == null)
  2532. {
  2533. Log.Debug("GetDomesticTransactionHistory | Returning null while fetching the list of transaction details.");
  2534. return jsonRx;
  2535. }
  2536. jsonRx.SetResponse("0", litranHistoryResponse.Count.ToString() + " remittance txn");
  2537. jsonRx.Data = litranHistoryResponse;
  2538. Log.Debug("GetDomesticTransactionHistory | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  2539. return jsonRx;
  2540. }
  2541. catch (Exception ex)
  2542. {
  2543. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  2544. jsonRx.SetResponse("1", "Error occurred while fetching the list of transaction details.");
  2545. return jsonRx;
  2546. }
  2547. }
  2548. public JsonRxResponse GenerateDomesticReceipt(string tranId)
  2549. {
  2550. JsonRxResponse jsonRx = new JsonRxResponse();
  2551. try
  2552. {
  2553. var tranResponse = _requestServices.GenerateDomesticReceipt(tranId);
  2554. if (tranResponse != null)
  2555. {
  2556. jsonRx.SetResponse("0", "Success");
  2557. jsonRx.Data = tranResponse;
  2558. Log.Debug("GenerateDomesticReceipt | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  2559. return jsonRx;
  2560. }
  2561. Log.Debug("GenerateDomesticReceipt | Returning null while fetching the receipt details.");
  2562. jsonRx.SetResponse("1", "Unable to fetch the Domestic Receipt details.");
  2563. return jsonRx;
  2564. }
  2565. catch (Exception ex)
  2566. {
  2567. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  2568. jsonRx.SetResponse("1", "Unable to fetch the Domestic Receipt details.");
  2569. return jsonRx;
  2570. }
  2571. }
  2572. //public JsonRxResponse GetCouponList(CouponuserInfo list)
  2573. //{
  2574. // JsonRxResponse res = new JsonRxResponse();
  2575. //// var couponlist = _requestServices.GetCouponList(list.customerId);
  2576. //// res.ErrorCode = "0";
  2577. //// res.Msg = "SUCCESS";
  2578. //// res.Data = couponlist;
  2579. // return res;
  2580. //}
  2581. public JsonRxResponse LoadFormStaticData_V3(string type, string customerId)
  2582. {
  2583. JsonRxResponse jsonRx = new JsonRxResponse
  2584. {
  2585. ErrorCode = "1",
  2586. Msg = "Error"
  2587. };
  2588. try
  2589. {
  2590. if (type.ToLower().Equals("kyc"))
  2591. {
  2592. KycStaticDataV3 sd = _requestServices.LoadKycStaticData_V3("kycV3", customerId);
  2593. if (sd != null)
  2594. {
  2595. Log.Debug("LoadFormStaticData | DB RESPONSE SUCCESS!");
  2596. jsonRx.ErrorCode = "0";
  2597. jsonRx.Msg = "success";
  2598. jsonRx.Data = sd;
  2599. return jsonRx;
  2600. }
  2601. Log.Debug("LoadFormStaticData | Returning null while calling LoadFormStaticData to fetch the static data related to " + type);
  2602. jsonRx.SetResponse("1", "Error occured", null);
  2603. }
  2604. else if (type.ToLower().Equals("kycexistingcustomer"))
  2605. {
  2606. KycStaticDataV3 sd = _requestServices.LoadKycStaticData_V3("kycV3-existing", customerId);
  2607. if (sd != null)
  2608. {
  2609. Log.Debug("LoadFormStaticData | DB RESPONSE SUCCESS!");
  2610. jsonRx.ErrorCode = "0";
  2611. jsonRx.Msg = "success";
  2612. jsonRx.Data = sd;
  2613. return jsonRx;
  2614. }
  2615. Log.Debug("LoadFormStaticData | Returning null while calling LoadFormStaticData to fetch the static data related to " + type);
  2616. jsonRx.SetResponse("1", "Error occured", null);
  2617. }
  2618. Log.Debug("LoadFormStaticData | Error occurred while specifying the type, Type mismatch error.");
  2619. return jsonRx;
  2620. }
  2621. catch (Exception ex)
  2622. {
  2623. Log.Error("Something Went Wrong, Please Try Again!!", ex);
  2624. jsonRx.SetResponse("1", "Error occurred while loading static data for." + type);
  2625. return jsonRx;
  2626. }
  2627. }
  2628. public JsonRxResponse RegisterKYC_V4()
  2629. {
  2630. throw new NotImplementedException();
  2631. }
  2632. public JsonRxResponse GetFieldsByProduct(Common.Model.Config.MappingType type, string customerId, string receiverId, string payoutPartner)
  2633. {
  2634. JsonRxResponse jsonRx = new JsonRxResponse
  2635. {
  2636. ErrorCode = "1",
  2637. Msg = "Error"
  2638. };
  2639. try
  2640. {
  2641. if (type == Common.Model.Config.MappingType.REWARD_TYPE)
  2642. {
  2643. var response1 = _requestServices.GetRewardDetails(customerId);
  2644. if (response1 != null)
  2645. {
  2646. Log.Debug("GetFieldsByProduct | DB RESPONSE SUCCESS!");
  2647. jsonRx.ErrorCode = "0";
  2648. jsonRx.Msg = "success";
  2649. jsonRx.Data = response1;
  2650. return jsonRx;
  2651. }
  2652. Log.Debug("GetRewardDetails | DB RESPONSE : " + JsonConvert.SerializeObject(response1));
  2653. jsonRx.SetResponse("1", "No Reward Details", null);
  2654. return jsonRx;
  2655. }
  2656. else if (type == Common.Model.Config.MappingType.REWARD_POINT)
  2657. {
  2658. var response1 = _requestServices.GetRewardFee(customerId);
  2659. response1.PaymentOptions = new PaymentOptions() { Options = GetPaymentMethods(receiverId, payoutPartner), HeaderText = "How do you like to pay ?" };
  2660. if (response1 != null)
  2661. {
  2662. Log.Debug("GetFieldsByProduct | DB RESPONSE SUCCESS!");
  2663. jsonRx.ErrorCode = "0";
  2664. jsonRx.Msg = "success";
  2665. jsonRx.Data = response1;
  2666. return jsonRx;
  2667. }
  2668. Log.Debug("GetRewardFee | DB RESPONSE : " + JsonConvert.SerializeObject(response1));
  2669. jsonRx.SetResponse("1", "No Reward Points", null);
  2670. return jsonRx;
  2671. }
  2672. else if (type == Common.Model.Config.MappingType.LOYALTY_POINT)
  2673. {
  2674. var loayaltyResponse = _requestServices.GetLoyaltyPoint(customerId);
  2675. Log.Debug("GetLoyaltyPoint | DB RESPONSE : " + JsonConvert.SerializeObject(loayaltyResponse));
  2676. if (loayaltyResponse != null)
  2677. {
  2678. jsonRx.ErrorCode = "0";
  2679. jsonRx.Msg = "success";
  2680. jsonRx.Data = loayaltyResponse;
  2681. return jsonRx;
  2682. }
  2683. jsonRx.SetResponse("1", "No Loyalty Points", null);
  2684. return jsonRx;
  2685. }
  2686. else
  2687. {
  2688. var response = Utilities.GetReferenceMaps(type);
  2689. if (response != null)
  2690. {
  2691. jsonRx.SetResponse("0", "Success");
  2692. jsonRx.Data = response;
  2693. Log.Debug("GetFieldsByProduct | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
  2694. return jsonRx;
  2695. }
  2696. Log.Debug($"GetFieldsByProduct | Error occurred while specifying the type {Common.Model.Config.MappingType.MODIFICATION_REQUEST}");
  2697. return jsonRx;
  2698. }
  2699. }
  2700. catch (Exception ex)
  2701. {
  2702. Log.Error("Something Went Wrong, Please Try Again!", ex);
  2703. jsonRx.SetResponse("1", "Error occurred while loading GetFieldsByProduct data for." + type);
  2704. return jsonRx;
  2705. }
  2706. }
  2707. public List<Option> GetPaymentMethods(string receiverId, string pcountryid)
  2708. {
  2709. var paymentMethods = _requestServices.GetPaymentMethod(receiverId, pcountryid);
  2710. List<Option> options;
  2711. string mappingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["PaymentConfigFilePath"].ToString());
  2712. using (StreamReader reader = File.OpenText(mappingPath))
  2713. {
  2714. var jsonS = reader.ReadToEnd();
  2715. options = JsonConvert.DeserializeObject<List<Option>>(jsonS);
  2716. }
  2717. List<Option> matchingOptions = new List<Option>();
  2718. foreach (var paymentMethod in paymentMethods)
  2719. {
  2720. var matchingOption = options.FirstOrDefault(option => option.Code == paymentMethod.Key);
  2721. if (matchingOption != null)
  2722. {
  2723. matchingOption.Value = paymentMethod.Value;
  2724. matchingOptions.Add(matchingOption);
  2725. }
  2726. }
  2727. return matchingOptions;
  2728. }
  2729. public JsonRxResponse ValidateReferralCode(string referralCode)
  2730. {
  2731. JsonRxResponse jsonRx = new JsonRxResponse();
  2732. try
  2733. {
  2734. jsonRx = _requestServices.ValidateReferralCode(referralCode);
  2735. return jsonRx;
  2736. }
  2737. catch (Exception ex)
  2738. {
  2739. Log.Error("ValidateReferralCode Error", ex);
  2740. jsonRx.SetResponse("1", "Error occured" + referralCode);
  2741. return jsonRx;
  2742. }
  2743. }
  2744. }
  2745. }