From e5c836a812995b143e4aa7efbfd5ea61d6cdbdfc Mon Sep 17 00:00:00 2001 From: shakun Date: Fri, 10 Nov 2023 09:59:37 +0545 Subject: [PATCH] lastes code --- Business/Business.csproj | 7 +- Business/Mobile/MobileServices.cs | 373 +- Business/MobileV2/IMobileV2Business.cs | 11 +- Business/MobileV2/MobileV2Business.cs | 49 +- Business/SendMoney/SendMoneyBusiness.cs | 68 +- Business/TPApi/ThirdPartyAPI.cs | 6 +- Business/Utility/AesOperation.cs | 64 + Common/APIJsonResponse.cs | 3 + Common/Common.csproj | 12 +- Common/Helper/Utilities.cs | 47 +- .../CustomerRegister/NewUserRegisterModel.cs | 5 +- Common/Model/JsonRxResponse.cs | 9 + Common/Model/MobileV2/CustomerProfileV2.cs | 30 + Common/Model/Notification/SMSRequestModel.cs | 5 +- Common/Model/RequestOTP/RequestOTPModel.cs | 4 + Common/Model/RewardFee.cs | 8 + Common/Model/TPSendMoney/TpSendMoney.cs | 3 + Common/Model/TranHistoryResponse.cs | 5 + Common/Model/TransactionResponse.cs | 2 +- Common/Model/WalletStatementResponse.cs | 23 +- JsonRx/Api/AuthController.cs | 2 +- JsonRx/Api/MobileController.cs | 6 +- JsonRx/Api/SendMoneyController.cs | 59 +- JsonRx/ApiV3/MobileV3Controller.cs | 95 +- .../TokenAuthenticationAttribute.cs | 17 +- JsonRx/Config/ResponseMsg.json | 4006 ++++++++--------- JsonRx/Helper/Util.cs | 14 +- JsonRx/JsonRx.csproj | 2 +- JsonRx/Web.config | 17 +- Repository/Mobile/MobileServicesRepo.cs | 140 +- Repository/MobileV2/IMobileV2Repo.cs | 3 + Repository/MobileV2/MobileV2Repo.cs | 154 +- 32 files changed, 2931 insertions(+), 2318 deletions(-) create mode 100644 Business/Utility/AesOperation.cs diff --git a/Business/Business.csproj b/Business/Business.csproj index c3485c0..2fdd819 100644 --- a/Business/Business.csproj +++ b/Business/Business.csproj @@ -45,8 +45,7 @@ ..\packages\Microsoft.IdentityModel.Tokens.6.25.1\lib\net45\Microsoft.IdentityModel.Tokens.dll - - False + ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll @@ -71,6 +70,9 @@ + + ..\..\TransactionProcessor\TransactionProcessor\bin\Debug\TransactionProcessor.dll + @@ -123,6 +125,7 @@ + diff --git a/Business/Mobile/MobileServices.cs b/Business/Mobile/MobileServices.cs index 811277f..022251e 100644 --- a/Business/Mobile/MobileServices.cs +++ b/Business/Mobile/MobileServices.cs @@ -32,6 +32,7 @@ using Repository; using System.Configuration; using Business.TrustDoc; using Business.Addressy; +using System.Text; namespace Business.Mobile { @@ -144,10 +145,9 @@ namespace Business.Mobile { var lang = Convert.ToString(CallContext.GetData(Constants.Language)); JsonRxResponse jsonRx = new JsonRxResponse(); - try { - requestOTPModel.OTP = Utilities.GenerateOTP(); + requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile. jsonRx = _requestServices.RequestOTP(requestOTPModel); Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx)); @@ -155,8 +155,9 @@ namespace Business.Mobile { bool emailSent = false; bool smsSent = false; - if (requestOTPModel.userId.IsValidEmail()) + if (requestOTPModel.userId.IsValidEmail() & (jsonRx.Extra3.Equals("0") | jsonRx.Extra3.Equals("100"))) { + if (!string.IsNullOrEmpty(jsonRx.ErrorCode) && jsonRx.ErrorCode.Equals("0")) { List bodyMappings = new List(); @@ -173,71 +174,93 @@ namespace Business.Mobile ProviderId = "REQUESTOTP_EMAIL", Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL, Recipients = new List() - { - new RecipientViewModel() { + new RecipientViewModel() + { NotificationContent = new NotificationDTO() { - Body = JsonConvert.SerializeObject(bodyMappings), - //Title will be set by mapping json - }, - Address= requestOTPModel.userId, - DeviceType = requestOTPModel.DeviceType, + Body = JsonConvert.SerializeObject(bodyMappings), + //Title will be set by mapping json + }, + Address= requestOTPModel.userId, + DeviceType = requestOTPModel.DeviceType, } } }; + + Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request)); + var jsonRx1 = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(jsonRx1)); emailSent = true; } catch (Exception emailException) { Log.Error("Error sending email", emailException); - } + } - try - { - string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; - SendSMSApiService _sendAPI = new SendSMSApiService(); - string mobileNum = jsonRx.Extra2; - var mobNum = getSenderFormattedNumber(mobileNum); - - SMSRequestModel _req = new SMSRequestModel + try { - ProviderId = "onewaysms", - MobileNumber = mobNum, //jsonRx.Extra2, - SMSBody = Common.Model.Enum.NotifyTemplate.OTP_EMAIL, - ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), - RequestedBy = requestOTPModel.userId, - UserName = requestOTPModel.userId, - method = "send", - ControlNo = "", // GetControlNo() - }; + + string mobileNum = jsonRx.Extra2; + var mobNum = getSenderFormattedNumber(mobileNum); + SendSMSApiService _sendAPI = new SendSMSApiService(); + + StringBuilder s = new StringBuilder(); + s.AppendLine($"Dear { jsonRx.Extra}"); + s.AppendLine($"Your OTP code for Customer Registration is {requestOTPModel.OTP }."); + s.AppendLine("Regards, IME London"); + + SMSRequestModel _req = new SMSRequestModel + { + ProviderId = "ProcessId", + MobileNumber = mobileNum, + SMSBody = s.ToString(), + ProcessId = requestOTPModel.ProcessId, + RequestedBy = requestOTPModel.userId, + UserName = requestOTPModel.userId, + method = "send", + ControlNo = "", // GetControlNo() + }; + Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req)); - APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); + + APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); + Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp)); - smsSent = true; - } - catch (Exception smsException) - { - Log.Error("Error sending SMS", smsException); - } - if (emailSent || smsSent) - { - jsonRx.ErrorCode = "0"; + + smsSent = true; + } + catch (Exception smsException) + { + Log.Error("Error sending SMS", smsException); + } + if (emailSent || smsSent) + { + jsonRx.ErrorCode = "0"; jsonRx.SetResponse("0", "OTP has been Sent."); - return jsonRx; + return jsonRx; } } + + } else { + + if (jsonRx.Extra3 != null & jsonRx.Extra3.Equals("103")) + { + return new JsonRxResponse { ErrorCode = "0", Msg = "OTP Already Sent" }; + } + jsonRx.ErrorCode = "1"; - var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang); - return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = map.Message }; + // var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang); + return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = jsonRx.Msg }; + } } - jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode; // 103 = previous OTP was not expired, so the same was used + jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used return jsonRx; } catch (Exception ex) @@ -246,13 +269,10 @@ namespace Business.Mobile jsonRx.SetResponse("1", "Error occurred while calling RequestOTP."); return jsonRx; } - } - - private string getSenderFormattedNumber(string number) + public string getSenderFormattedNumber(string number) { string finalNo = number; - if (!number.Contains("+44")) { string mobileFirst = number.Substring(0, 1); @@ -272,19 +292,20 @@ namespace Business.Mobile { finalNo = $"+44{number}"; } - } else if (number.Contains("+44")) { string MobN = number.Substring(4, 1); - if (MobN == "0" && number.Length > 14) { finalNo = number.Remove(4, 1); } } if (!finalNo.Substring(0, 1).Contains("+")) + { + finalNo = $"+{finalNo}"; + } return finalNo; } @@ -668,8 +689,6 @@ namespace Business.Mobile } - - if (!string.IsNullOrEmpty(custKyc.RegistrationType) && custKyc.RegistrationType.Equals("EKYC")) { isKyc = true; @@ -684,6 +703,8 @@ namespace Business.Mobile // isBackRequired = id["isBackRequired"].ToString(); // } //} + + //Log.Debug($"RegisterKYC | httpRequest : {httpRequest.Params}"); Log.Debug($"RegisterKYC | REQUEST : { JsonConvert.SerializeObject(custKyc)} | Files: { httpRequest.Files.Count}"); @@ -1001,34 +1022,59 @@ namespace Business.Mobile // kyc.mobile = jsonRxMobile.Extra; //} + if (kyc.type.Equals("0")) + { + if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation)) + { + enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString(); + var map = Utilities.GetLanguageMapping(enumString, lang); + jsonRx.SetResponse("1", map.Message); - //if (string.IsNullOrEmpty(kyc.otherOccupation) && string.IsNullOrEmpty(kyc.occupation)) - //{ - // enumString = RESPONSE_MSG.VALIDATE_FORM_2.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); + return jsonRx; + } + else if (string.IsNullOrEmpty(kyc.occupation)) + { + if (string.IsNullOrEmpty(kyc.otherOccupation)) + { + enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString(); + var map = Utilities.GetLanguageMapping(enumString, lang); + jsonRx.SetResponse("1", map.Message); - // return jsonRx; - //} - //else if (string.IsNullOrEmpty(kyc.occupation)) - //{ - // if (string.IsNullOrEmpty(kyc.otherOccupation)) - // { - // enumString = RESPONSE_MSG.VALIDATE_FORM_9.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); - - // return jsonRx; - // } - //} + return jsonRx; + } + } + + if (string.IsNullOrEmpty(kyc.idExpiryDate)) + { - //if (string.IsNullOrEmpty(kyc.monthlyIncome)) + jsonRx.SetResponse("1", "IdExpiryDate is required"); + return jsonRx; + } + if (string.IsNullOrEmpty(kyc.idStartDate)) + { + + jsonRx.SetResponse("1", "Idissue Date is required"); + return jsonRx; + } + if (string.IsNullOrEmpty(kyc.idIssuingCountry)) + { + + jsonRx.SetResponse("1", "idIssuingCountry is required"); + return jsonRx; + } + } + + + //if (string.IsNullOrEmpty(kyc.idNumber)) //{ - // enumString = RESPONSE_MSG.VALIDATE_FORM_3.ToString(); - // var map = Utilities.GetLanguageMapping(enumString, lang); - // jsonRx.SetResponse("1", map.Message); + + // jsonRx.SetResponse("1", "Id number is required"); // return jsonRx; //} + + + + //if (string.IsNullOrEmpty(kyc.additionalAddress)) //{ // enumString = RESPONSE_MSG.VALIDATE_FORM_4.ToString(); @@ -1666,28 +1712,28 @@ namespace Business.Mobile _resp.SetResponse("1", "Password can not be empty!"); return _resp; } - if (confirmpwd.Length < 8) + if (confirmpwd.Length < 6) { - _resp.SetResponse("1", "Password must be of atleast 8 digits!"); + _resp.SetResponse("1", "Password must be of atleast 6 digits!"); return _resp; } - if (!Regex.Match(confirmpwd, @"\d+").Success) - { - _resp.SetResponse("1", "Password must contain 1 number!"); - return _resp; - } + //if (!Regex.Match(confirmpwd, @"\d+").Success) + //{ + // _resp.SetResponse("1", "Password must contain 1 number!"); + // return _resp; + //} - if (!Regex.Match(confirmpwd, @"[A-Z]").Success) - { - _resp.SetResponse("1", "Password must contain atleaset one capital letter!"); - return _resp; - } - if (!Regex.Match(confirmpwd, @"[!@#$%&*_+\-]").Success) - { - _resp.SetResponse("1", "Password must contain atleaset one special character!"); - return _resp; - } + //if (!Regex.Match(confirmpwd, @"[A-Z]").Success) + //{ + // _resp.SetResponse("1", "Password must contain atleaset one capital letter!"); + // return _resp; + //} + //if (!Regex.Match(confirmpwd, @"[!@#$%&*_+\-]").Success) + //{ + // _resp.SetResponse("1", "Password must contain atleaset one special character!"); + // return _resp; + //} return _resp; } @@ -1739,6 +1785,8 @@ namespace Business.Mobile return verifyPwdResp; } + newUserRegister.MobileNumber = newUserRegister.MobileNumber.getUKFormattedNumber(); + res = _requestServices.NewUserRegister(newUserRegister); Log.Debug("NewUserRegister | completed with db response. " + "ErrorCode: " + res.ErrorCode + " Msg: " + res.Msg); @@ -1907,29 +1955,9 @@ namespace Business.Mobile res = _requestServices.CustomerInfoAgree(username, "agree"); - //if (res.ErrorCode.Equals("0")) - //{ - - // _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id); - - // SendNotificationRequest request = new SendNotificationRequest() - // { - // IsBulkNotification = false, - // UserName = username, - // ProcessId = Guid.NewGuid().ToString(), - // ProviderId = "CustomerInfoAgree", - // NotificationTypeId = NOTIFICATION_TYPE.PUSH_NOTIFICATION.ToString(), - // //Template = Common.Model.Enum.NotifyTemplate.NEW_REGISTER_WELCOME, - // Recipients = new List() - // { - // new RecipientViewModel() { Address= res.Extra , NotificationContent = new NotificationDTO() } - // }, - // Language = Convert.ToString(CallContext.GetData(Constants.Language)) - // }; - // Task.Run(() => NotifierV2.SendNotification(request, NOTIFICATION_TYPE.PUSH_NOTIFICATION)); - //} if (res.ErrorCode.Equals("0")) { + // _trustDocBusiness.CompareData(new TrustDocRequest() { birth = res.Extra2, name = res.Msg }, res.Extra3, username, res.Id); res.Msg = "Thank you for completing your profile. You can now start sending transactions"; @@ -1961,10 +1989,8 @@ namespace Business.Mobile // }, // Language = Convert.ToString(CallContext.GetData(Constants.Language)) //}; - //Task.Run(() => NotifierV2.SendNotification(emailNotificationRequest, NOTIFICATION_TYPE.EMAIL)); } - Log.Debug("CustomerInfoAgree.Agree | DB RESPONSE : " + JsonConvert.SerializeObject(res)); } //else if (agreeYn.Equals("N")) @@ -2001,6 +2027,15 @@ namespace Business.Mobile return res; } + + DateTime dateTime; + if (DateTime.TryParseExact(pwdReset.Dob, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) + { + pwdReset.Dob = dateTime.ToString("yyyy-MM-dd"); + } + + + if (!pwdReset.Username.IsValidEmail()) { var map = Utilities.GetLanguageMapping(RESPONSE_MSG.INVALID_EMAIL_FOR_RESETPASSWORD.ToString(), lang); @@ -2008,7 +2043,9 @@ namespace Business.Mobile return res; }; - var randomPassword = PasswordGenerator.GenerateRandomPassword(); + // var randomPassword = PasswordGenerator.GenerateRandomPassword(); + + var randomPassword = Utilities.GenerateRandomPin(); pwdReset.RandomPassword = randomPassword; res = _requestServices.ResetPassword(pwdReset); @@ -2018,20 +2055,21 @@ namespace Business.Mobile { try { - List bodyMappings = new List(); + + List bodyMappings = new List(); bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = res.Extra2 }); bodyMappings.Add(new Notify.Mapping() { SValue = "EMAIL_ID", SText = pwdReset.Username }); - bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword }); + bodyMappings.Add(new Notify.Mapping() { SValue = "PASS_WORD", SText = randomPassword }); - SendNotificationRequest request = new SendNotificationRequest() - { - IsBulkNotification = false, - UserName = pwdReset.Username, - ProcessId = processId, - ProviderId = "ResetPassword", - NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), - Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL, - Recipients = new List() + SendNotificationRequest request = new SendNotificationRequest() + { + IsBulkNotification = false, + UserName = pwdReset.Username, + ProcessId = processId, + ProviderId = "ResetPassword", + NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), + Template = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL, + Recipients = new List() { new RecipientViewModel() { @@ -2042,25 +2080,26 @@ namespace Business.Mobile Address= pwdReset.Username } } - }; + }; - string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; - SendSMSApiService _sendAPI = new SendSMSApiService(); + res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.); - //GetSMSTextForTxn - SMSRequestModel _req = new SMSRequestModel - { - ProviderId = "onewaysms", - MobileNumber = pwdReset.mobileNo, - SMSBody = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL, - ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), - RequestedBy = pwdReset.Username, - UserName = pwdReset.Username, - method = "send", - ControlNo = "", // GetControlNo() - }; - APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); - res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); + + string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; + SendSMSApiService _sendAPI = new SendSMSApiService(); + SMSRequestModel _req = new SMSRequestModel + { + ProviderId = "onewaysms", + MobileNumber = pwdReset.mobileNo, + SMSBody = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL.ToString(), + ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), + RequestedBy = pwdReset.Username, + UserName = pwdReset.Username, + method = "send", + ControlNo = "", // GetControlNo() + }; + APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); + } catch (Exception ex) { @@ -2114,56 +2153,16 @@ namespace Business.Mobile if (liWalletStmtResponse == null) { - jsonRx.ErrorCode = "0"; + jsonRx.ErrorCode = "1"; jsonRx.Msg = "No wallet statement found."; jsonRx.Data = new System.Collections.ArrayList(); Log.Debug("GetWalletStatement | Returning null while fetching the list of wallet statements."); return jsonRx; } - double OpenBalnce = 0.0; - foreach (var item in liWalletStmtResponse) - { - if (item.Particular.ToString().ToUpper() == "BALANCE BROUGHT FORWARD") - { - OpenBalnce = GetStatic.ParseDouble(item.ClosingAmount.ToString()); - } - else - { - item.ClosingAmount = (OpenBalnce + GetStatic.ParseDouble(item.WalletIn) - GetStatic.ParseDouble(item.WalletOut)).ToString(); - OpenBalnce = GetStatic.ParseDouble(item.ClosingAmount); - } - - //item.ClosingAmount = GetStatic.ShowCommaAmt(item.ClosingAmount); - item.WalletIn = GetStatic.ShowCommaAmt(item.WalletIn); - item.WalletOut = GetStatic.ShowCommaAmt(item.WalletOut); - } - if (liWalletStmtResponse[0].Particular.ToString().ToUpper() == "BALANCE BROUGHT FORWARD") - { - liWalletStmtResponse.RemoveAt(0); - } - liWalletStmtResponse.Add(new WalletStatementResponse() - { - Particular = "BALANCE BROUGHT FORWARD", - ClosingAmount = OpenBalnce.ToString() - }); - jsonRx.SetResponse("0", liWalletStmtResponse.Count.ToString() + " wallet txn"); + jsonRx.ErrorCode = "0"; + jsonRx.Data = liWalletStmtResponse; - List list = new List(); - - for (int i = liWalletStmtResponse.Count - 1; i >= 0; i--) - { - list.Add(new WalletStatementResponse() - { - Particular = liWalletStmtResponse[i].Particular, - TransactionDate = liWalletStmtResponse[i].TransactionDate, - WalletIn = liWalletStmtResponse[i].WalletIn, - WalletOut = liWalletStmtResponse[i].WalletOut, - ClosingAmount = GetStatic.ShowCommaAmt(liWalletStmtResponse[i].ClosingAmount) - }); - } - jsonRx.Data = list; - Log.Debug("GetWalletStatement | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx)); return jsonRx; } @@ -2932,7 +2931,6 @@ namespace Business.Mobile return jsonRx; } - else if (type == Common.Model.Config.MappingType.REWARD_POINT) { var response1 = _requestServices.GetRewardFee(customerId); @@ -2999,7 +2997,6 @@ namespace Business.Mobile public List - + False ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll diff --git a/JsonRx/Web.config b/JsonRx/Web.config index f687903..1ee681a 100644 --- a/JsonRx/Web.config +++ b/JsonRx/Web.config @@ -11,15 +11,19 @@ - - + + + - + + + @@ -94,6 +98,13 @@ + + + + + + +