Browse Source

#17825 updated

Mobile-pdf
Leeza Baidar 1 year ago
parent
commit
4f858396bd
  1. 44
      Business/Mobile/MobileServices.cs
  2. 2
      Common/Common.csproj

44
Business/Mobile/MobileServices.cs

@ -144,25 +144,27 @@ namespace Business.Mobile
{ {
var lang = Convert.ToString(CallContext.GetData(Constants.Language)); var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse(); JsonRxResponse jsonRx = new JsonRxResponse();
try try
{ {
requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile.
requestOTPModel.OTP = Utilities.GenerateOTP();
jsonRx = _requestServices.RequestOTP(requestOTPModel); jsonRx = _requestServices.RequestOTP(requestOTPModel);
Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx)); Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (jsonRx.ErrorCode == "0") if (jsonRx.ErrorCode == "0")
{ {
// string msgBody = "Dear Customer, your OTP code is: " + requestOTPModel.OTP + " (Valid for " + jsonRx.Extra + " mins).";
bool emailSent = false;
bool smsSent = false;
if (requestOTPModel.userId.IsValidEmail()) if (requestOTPModel.userId.IsValidEmail())
{ {
if (!string.IsNullOrEmpty(jsonRx.Extra2) && jsonRx.Extra2.Equals("100")) if (!string.IsNullOrEmpty(jsonRx.Extra2) && jsonRx.Extra2.Equals("100"))
{ {
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>(); List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
//bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = requestOTPModel.customerName });
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = requestOTPModel.customerName });
bodyMappings.Add(new Notify.Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP }); bodyMappings.Add(new Notify.Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP });
bodyMappings.Add(new Notify.Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" }); bodyMappings.Add(new Notify.Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" });
try
{
SendNotificationRequest request = new SendNotificationRequest() SendNotificationRequest request = new SendNotificationRequest()
{ {
IsBulkNotification = false, IsBulkNotification = false,
@ -184,9 +186,19 @@ namespace Business.Mobile
} }
} }
}; };
jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
emailSent = true;
}
catch (Exception emailException)
{
Log.Error("Error sending email", emailException);
}
}
try
{
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms";
SendSMSApiService _sendAPI = new SendSMSApiService(); SendSMSApiService _sendAPI = new SendSMSApiService();
//GetSMSTextForTxn
SMSRequestModel _req = new SMSRequestModel SMSRequestModel _req = new SMSRequestModel
{ {
ProviderId = "onewaysms", ProviderId = "onewaysms",
@ -199,23 +211,28 @@ namespace Business.Mobile
ControlNo = "", // GetControlNo() ControlNo = "", // GetControlNo()
}; };
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
smsSent = true;
}
catch (Exception smsException)
{
Log.Error("Error sending SMS", smsException);
}
if (emailSent || smsSent)
{
jsonRx.ErrorCode = "0";
jsonRx.SetResponse("0", "OTP has been verified.");
return jsonRx;
} }
else
Log.Debug("RequestOTP | 103 : " + JsonConvert.SerializeObject(jsonRx));
} }
else else
{ {
jsonRx.ErrorCode = "1"; jsonRx.ErrorCode = "1";
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang); var map = Utilities.GetLanguageMapping(RESPONSE_MSG.OLD_USER_REGISTER_FAIL_11.ToString(), lang);
return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = map.Message }; return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = map.Message };
;
} }
} }
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode; // 103 = previous OTP was not expired, so the same was used
return jsonRx; return jsonRx;
} }
catch (Exception ex) catch (Exception ex)
@ -224,6 +241,7 @@ namespace Business.Mobile
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP."); jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx; return jsonRx;
} }
} }

2
Common/Common.csproj

@ -105,6 +105,7 @@
<Compile Include="Model\EmailParameters.cs" /> <Compile Include="Model\EmailParameters.cs" />
<Compile Include="Model\Enum\ErrorCode.cs" /> <Compile Include="Model\Enum\ErrorCode.cs" />
<Compile Include="Model\Enum\Notifications.cs" /> <Compile Include="Model\Enum\Notifications.cs" />
<Compile Include="Model\ExRateResponse.cs" />
<Compile Include="Model\External\CallbackParam.cs" /> <Compile Include="Model\External\CallbackParam.cs" />
<Compile Include="Model\External\CallbackTpResponse.cs" /> <Compile Include="Model\External\CallbackTpResponse.cs" />
<Compile Include="Model\GetDetailForDllTxn.cs" /> <Compile Include="Model\GetDetailForDllTxn.cs" />
@ -140,6 +141,7 @@
<Compile Include="Model\Notification\BodyMapping.cs" /> <Compile Include="Model\Notification\BodyMapping.cs" />
<Compile Include="Model\Notification\NotificationDTO.cs" /> <Compile Include="Model\Notification\NotificationDTO.cs" />
<Compile Include="Model\Notification\RecipientViewModel.cs" /> <Compile Include="Model\Notification\RecipientViewModel.cs" />
<Compile Include="Model\Notification\SMSRequestModel.cs" />
<Compile Include="Model\PasswordReset.cs" /> <Compile Include="Model\PasswordReset.cs" />
<Compile Include="Model\PennyTest\PennyCertVerifyRequestModel.cs" /> <Compile Include="Model\PennyTest\PennyCertVerifyRequestModel.cs" />
<Compile Include="Model\PennyTest\PennyTestCustomerCert.cs" /> <Compile Include="Model\PennyTest\PennyTestCustomerCert.cs" />

Loading…
Cancel
Save