Browse Source

#17825 updated

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

78
Business/Mobile/MobileServices.cs

@ -144,49 +144,61 @@ namespace Business.Mobile
{
var lang = Convert.ToString(CallContext.GetData(Constants.Language));
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
requestOTPModel.OTP = Utilities.GenerateOTP(); //implement the logic to send OTP SMS in customers mobile.
requestOTPModel.OTP = Utilities.GenerateOTP();
jsonRx = _requestServices.RequestOTP(requestOTPModel);
Log.Debug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
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 (!string.IsNullOrEmpty(jsonRx.Extra2) && jsonRx.Extra2.Equals("100"))
{
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 = "TYPE", SText = requestOTPModel.requestFor.Equals("REGISTER") ? "customer" : "receiver" });
SendNotificationRequest request = new SendNotificationRequest()
try
{
IsBulkNotification = false,
UserName = requestOTPModel.userId,
ControlNo = requestOTPModel.receiverId,
ProviderId = "RequestOTP",
Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = requestOTPModel.userId,
ControlNo = requestOTPModel.receiverId,
ProviderId = "RequestOTP",
Template = Common.Model.Enum.NotifyTemplate.OTP_EMAIL,
Recipients = new List<RecipientViewModel>()
{
NotificationContent = new NotificationDTO()
{
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= requestOTPModel.userId,
DeviceType = requestOTPModel.DeviceType,
new RecipientViewModel()
{
NotificationContent = new NotificationDTO()
{
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= requestOTPModel.userId,
DeviceType = requestOTPModel.DeviceType,
}
}
};
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";
SendSMSApiService _sendAPI = new SendSMSApiService();
//GetSMSTextForTxn
SMSRequestModel _req = new SMSRequestModel
{
ProviderId = "onewaysms",
@ -199,23 +211,28 @@ namespace Business.Mobile
ControlNo = "", // GetControlNo()
};
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
{
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 };
;
}
}
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;
}
catch (Exception ex)
@ -224,6 +241,7 @@ namespace Business.Mobile
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx;
}
}

2
Common/Common.csproj

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

Loading…
Cancel
Save