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.

3056 lines
128 KiB

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