Browse Source

#ResetPassword sms

Mobile-pdf
Leeza Baidar 10 months ago
parent
commit
fae3172ef6
  1. 36
      Business/Mobile/MobileServices.cs
  2. 41
      JsonRx/Helper/Util.cs

36
Business/Mobile/MobileServices.cs

@ -2030,9 +2030,10 @@ namespace Business.Mobile
if (res.ErrorCode == "0") if (res.ErrorCode == "0")
{ {
bool emailSent = false;
bool smsSent = false;
try try
{ {
List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>(); List<Notify.Mapping> bodyMappings = new List<Notify.Mapping>();
bodyMappings.Add(new Notify.Mapping() { SValue = "CustomerName", SText = res.Extra2 }); 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 = "EMAIL_ID", SText = pwdReset.Username });
@ -2059,28 +2060,53 @@ namespace Business.Mobile
} }
}; };
Log.Debug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
Log.Debug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(res));
emailSent = true;
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms"; string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms";
var mobileNo = getSenderFormattedNumber(res.Extra3);
SendSMSApiService _sendAPI = new SendSMSApiService(); SendSMSApiService _sendAPI = new SendSMSApiService();
StringBuilder s = new StringBuilder();
s.AppendLine($"Dear { pwdReset.Username}");
s.AppendLine($"We received your password reset request and your new credentials are");
s.AppendLine($"Login ID: { pwdReset.Username}");
s.AppendLine($"Password: { pwdReset.RandomPassword}");
s.AppendLine("Regards, IME London");
SMSRequestModel _req = new SMSRequestModel SMSRequestModel _req = new SMSRequestModel
{ {
ProviderId = "onewaysms", ProviderId = "onewaysms",
MobileNumber = pwdReset.mobileNo, MobileNumber = pwdReset.mobileNo,
SMSBody = Common.Model.Enum.NotifyTemplate.RESET_PASSWORD_EMAIL.ToString(),
SMSBody = s.ToString(),
ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40), ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
RequestedBy = pwdReset.Username, RequestedBy = pwdReset.Username,
UserName = pwdReset.Username, UserName = pwdReset.Username,
method = "send", method = "send",
ControlNo = "", // GetControlNo() ControlNo = "", // GetControlNo()
}; };
Log.Debug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req); APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
Log.Debug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
smsSent = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("ResetPassword.SendNotification", ex); Log.Error("ResetPassword.SendNotification", ex);
} }
if (emailSent || smsSent)
{
res.ErrorCode = "0";
res.SetResponse("0", "Reset password email/sms has been sent.");
return res;
}
var map = Utilities.GetLanguageMapping(RESPONSE_MSG.SEND_EMAIL_FOR_RESETPASSWORD_SUCCESS.ToString(), lang); var map = Utilities.GetLanguageMapping(RESPONSE_MSG.SEND_EMAIL_FOR_RESETPASSWORD_SUCCESS.ToString(), lang);
return new JsonRxResponse { ErrorCode = "0", Msg = map.Message }; return new JsonRxResponse { ErrorCode = "0", Msg = map.Message };
// return res; // return res;

41
JsonRx/Helper/Util.cs

@ -295,45 +295,4 @@ namespace JsonRx.Helper
First, First,
All All
} }
public static class StringHelper
{
private static CultureInfo ci = new CultureInfo("en-US");
public static string ToTitleCase(this string str)
{
str = str.ToLower();
var strArray = str.Split(' ');
if (strArray.Length > 1)
{
strArray[0] = ci.TextInfo.ToTitleCase(strArray[0]);
return string.Join(" ", strArray);
}
return ci.TextInfo.ToTitleCase(str);
}
public static string ToTitleCase(this string str, TitleCase tcase)
{
str = str.ToLower();
switch (tcase)
{
case TitleCase.First:
var strArray = str.Split(' ');
if (strArray.Length > 1)
{
strArray[0] = ci.TextInfo.ToTitleCase(strArray[0]);
return string.Join(" ", strArray);
}
break;
case TitleCase.All:
return ci.TextInfo.ToTitleCase(str);
default:
break;
}
return ci.TextInfo.ToTitleCase(str);
}
}
public enum TitleCase
{
First,
All
}
} }
Loading…
Cancel
Save