Browse Source

merge with notification n otp

feature/19315_Customer-Registration-new
shakun 11 months ago
parent
commit
c5772b6a84
  1. 2
      CustomerOnlineV2/CustomerOnlineV2.Api/API/TPApi/TPApiService.cs
  2. 222
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs
  3. 3
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs
  4. 22
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/LoggerProperty.cs
  5. 96
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/NotifierV2.cs
  6. 2
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs
  7. 73
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs
  8. 84
      CustomerOnlineV2/CustomerOnlineV2.Business/Business/ThirdPartyAPI.cs
  9. 62
      CustomerOnlineV2/CustomerOnlineV2.Common/Helper/ApplicationConfig.cs
  10. 2
      CustomerOnlineV2/CustomerOnlineV2.Common/Helper/LoginUserInfo.cs
  11. 15
      CustomerOnlineV2/CustomerOnlineV2.Common/Helper/Utilities.cs
  12. 24
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs
  13. 104
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/CommonResponse.cs
  14. 33
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/Notification/RestApiClient.cs
  15. 21
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/Notification/SMSRequestModel.cs
  16. 1
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/RegisterModel/UserRegisterResponse.cs
  17. 3
      CustomerOnlineV2/CustomerOnlineV2.Repository/ConnectionHelper/ConnectionHelper.cs
  18. 49
      CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs
  19. 2
      CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs
  20. 4
      CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs
  21. 59
      CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs
  22. 19
      CustomerOnlineV2/CustomerOnlineV2/Authorization/AuthorizationAttribute.cs
  23. 138
      CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs
  24. 255
      CustomerOnlineV2/CustomerOnlineV2/Views/Account/VerifyOTP.cshtml
  25. 6
      CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerRegistration.cshtml
  26. 17
      CustomerOnlineV2/CustomerOnlineV2/Views/Transaction/Receipt.cshtml

2
CustomerOnlineV2/CustomerOnlineV2.Api/API/TPApi/TPApiService.cs

@ -192,7 +192,7 @@ namespace CustomerOnlineV2.Api.API.TPApi
}
else
{
var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
var errorJson = JsonConvert.DeserializeObject<CommonResponse.ErrorJosn>(resultData);
var jsonResponseData = JsonConvert.DeserializeObject<CommonResponse>(errorJson.Message);
jsonResponse.Id = jsonResponseData.Id;

222
CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs

@ -1,14 +1,11 @@
using CustomerOnlineV2.Common.Helper;
using CustomerOnlineV2.Common.Models;
using CustomerOnlineV2.Common.Models.AccountModel;
using CustomerOnlineV2.Common.Models.HomeModel;
using CustomerOnlineV2.Common.Models.Notification;
using CustomerOnlineV2.Repository.Repository.AccountRepository;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Notify = Azure.Core.HttpHeader;
using Newtonsoft.Json;
using System.Text;
using static CustomerOnlineV2.Common.Models.Notification.PasswordGenerator;
namespace CustomerOnlineV2.Business.Business.AccountBusiness
@ -125,6 +122,221 @@ namespace CustomerOnlineV2.Business.Business.AccountBusiness
return new string(chars.ToArray());
}
public async Task<JsonRxResponse> VerifyOtp(RequestOTPModel requestOTPModel, LoginResponse loginDetails)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
jsonRx = await _accountRepo.VerifyOtp(requestOTPModel, loginDetails);
_logger.LogDebug("SubmitOTP | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (jsonRx.ErrorCode.Equals("0"))
{
//List<Mapping> bodyMappings = new List<Mapping>();
//bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = loginDetails.FullName });
//bodyMappings.Add(new Mapping() { SValue = "CustomerId", SText = loginDetails.MembershipId.ToString() });
//bodyMappings.Add(new Mapping() { SValue = "UserId", SText = loginDetails.MembershipId });
//bodyMappings.Add(new Mapping() { SValue = "FirstName", SText = loginDetails.FullName });
//bodyMappings.Add(new Mapping() { SValue = "MiddleName", SText = loginDetails.FullName });
//bodyMappings.Add(new Mapping() { SValue = "LastName", SText = loginDetails.FullName });
//bodyMappings.Add(new Mapping() { SValue = "MobileNo", SText = loginDetails.MobileNumber });
//bodyMappings.Add(new Mapping() { SValue = "Address", SText = loginDetails.UserName });
//bodyMappings.Add(new Mapping() { SValue = "EMAIL_ID", SText = loginDetails.Email });
//bodyMappings.Add(new Mapping() { SValue = "RegisteredDate", SText = "" });
//SendNotificationRequest request = new SendNotificationRequest()
//{
// IsBulkNotification = false,
// UserName = loginDetails.Email,
// ProviderId = "BasicRegistration",
// NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
// Template = NotifyTemplate.BASIC_REGISTRATION_EMAIL,
// Recipients = new List<RecipientViewModel>()
// {
// new RecipientViewModel()
// {
// NotificationContent = new NotificationDTO() {
// Body = JsonConvert.SerializeObject(bodyMappings),
// //Title will be set by mapping json
// },
// Address= loginDetails.Email
// }
// }
//};
//jsonRx = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
}
//return jsonRx;
return await Task.FromResult(jsonRx);
}
catch (Exception ex)
{
_logger.LogError("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return await Task.FromResult(jsonRx);
}
}
public JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel)
{
JsonRxResponse jsonRx = new JsonRxResponse();
try
{
requestOTPModel.OTP = Utilities.GenerateOTP();
jsonRx = _accountRepo.RequestOTP(requestOTPModel);
_logger.LogDebug("GenerateOTP | RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (jsonRx.ErrorCode == "0")
{
bool emailSent = false;
bool smsSent = false;
if (requestOTPModel.userId.IsValidEmail())
{
if (!string.IsNullOrEmpty(jsonRx.ErrorCode) && jsonRx.ErrorCode.Equals("0"))
{
List<Mapping> bodyMappings = new List<Mapping>();
bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = requestOTPModel.CreatedBy });
//bodyMappings.Add(new Mapping() { SValue = "OTP_CODE", SText = requestOTPModel.OTP });
bodyMappings.Add(new Mapping() { SValue = "OTP_CODE", SText = jsonRx.Id });
bodyMappings.Add(new Mapping() { SValue = "TYPE", SText = requestOTPModel.requestFor });
try
{
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = requestOTPModel.CreatedBy,
ControlNo = requestOTPModel.receiverId,
ProviderId = "REQUESTOTP_EMAIL",
Template = NotifyTemplate.OTP_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= requestOTPModel.CreatedBy,
DeviceType = requestOTPModel.DeviceType,
} }
};
_logger.LogDebug("SendNotification.EMAIL | REQUEST : " + JsonConvert.SerializeObject(request));
var jsonRx1 = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
_logger.LogDebug("SendNotification.EMAIL | RESPONSE : " + JsonConvert.SerializeObject(jsonRx1));
emailSent = true;
}
catch (Exception emailException)
{
_logger.LogError("Error sending email", emailException);
}
try
{
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":sendSms";
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 = "onewaysms",
MobileNumber = mobileNum,
SMSBody = s.ToString(),
ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40),
RequestedBy = requestOTPModel.userId,
UserName = requestOTPModel.userId,
method = "send",
ControlNo = "", // GetControlNo()
};
_logger.LogDebug("SendNotification.SMS | REQUEST : " + JsonConvert.SerializeObject(_req));
APIJsonResponse _resp = _sendAPI.SMSTPApi(_req);
_logger.LogDebug("SendNotification.SMS | RESPONSE : " + JsonConvert.SerializeObject(_resp));
smsSent = true;
}
catch (Exception smsException)
{
_logger.LogError("Error sending SMS", smsException);
}
if (emailSent || smsSent)
{
jsonRx.ErrorCode = "0";
jsonRx.SetResponse("0", "OTP has been Sent.");
return jsonRx;
}
}
}
}
else
{
jsonRx.ErrorCode = "1";
return new JsonRxResponse { ErrorCode = jsonRx.ErrorCode, Msg = jsonRx.Msg };
}
jsonRx.ErrorCode = jsonRx.ErrorCode == "103" ? "0" : jsonRx.ErrorCode;//103 = previous OTP was not expired so same was used
return jsonRx;
}
catch (Exception ex)
{
_logger.LogError("Something Went Wrong, Please Try Again!!", ex);
jsonRx.SetResponse("1", "Error occurred while calling RequestOTP.");
return jsonRx;
}
}
private string getSenderFormattedNumber(string number)
{
string finalNo = number;
if (!number.Contains("+44"))
{
string mobileFirst = number.Substring(0, 1);
if (mobileFirst == "0")
{
if (number.Length == 11)
{
finalNo = "+44" + number.Substring(1, number.Length - 1);
return finalNo;
}
else if (number.Length < 11)
{
finalNo = $"+44{number}";
}
}
else if (number.Substring(0, 1) != "0" && number.Length == 10)
{
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;
}
}
}

3
CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs

@ -8,6 +8,7 @@ namespace CustomerOnlineV2.Business.Business.AccountBusiness
Task<LoginResponse> Login(LoginModel model);
Task<CommonResponse> ChangePassword(ForceChangePasswordModel model, LoginResponse logindetails);
Task<CommonResponse> PasswordReset(PasswordResetModel model, LoginResponse logindetails);
// object PasswordReset(PasswordResetModel model, string processid);
Task<JsonRxResponse> VerifyOtp(RequestOTPModel requestOTPModel, LoginResponse logindetails);
JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel);
}
}

22
CustomerOnlineV2/CustomerOnlineV2.Business/Business/LoggerProperty.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomerOnlineV2.Business.Business
{
public static class LoggerProperty
{
public const string PROCESSID = "processId";
public const string PAYOUTPARTNERID = "payoutPartnerId";
public const string METHODNAME = "methodName";
public const string CONTROLNO = "controlNo";
public const string CREATEDBY = "createdBy";
public const string MESSAGE = "message";
public const string EXCEPTION = "exception";
public const string LOGGER = "logger";
public const string LEVEL = "level";
public const string IPADDRESS = "userIP";
}
}

96
CustomerOnlineV2/CustomerOnlineV2.Business/Business/NotifierV2.cs

@ -0,0 +1,96 @@
using CustomerOnlineV2.Common.Models.Notification;
using CustomerOnlineV2.Common.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CustomerOnlineV2.Common.Models.TransactionModel;
namespace CustomerOnlineV2.Business.Business
{
public static class NotifierV2
{
public static JsonRxResponse SendNotification(SendNotificationRequest request, NOTIFICATION_TYPE nOTIFICATION_TYPE = NOTIFICATION_TYPE.PUSH_NOTIFICATION)
{
ThirdPartyAPI _tpApi = new ThirdPartyAPI();
APIJsonResponse jsonResponse = new APIJsonResponse();
if (string.IsNullOrEmpty(request.ProcessId))
request.ProcessId = Guid.NewGuid().ToString();
//request.ProviderId = Guid.NewGuid().ToString();
request.NotificationTypeId = nOTIFICATION_TYPE.ToString();
APIJsonResponse result = _tpApi.ThirdPartyApiGetDataOnly<SendNotificationRequest, APIJsonResponse>(request, "TP/NotificationAPI", out jsonResponse);
return new JsonRxResponse()
{
ErrorCode = result.ResponseCode,
Id = result.Id,
Msg = result.Msg,
Data = result.Data,
Extra = result.Extra,
Extra2 = result.Extra1
};
}
}
public class SendSMSApiService
{
public APIJsonResponse SMSTPApi(SMSRequestModel model)
{
//Log.Debug("Calculate | Calling third party api to fetch the ex-rate details " + JsonConvert.SerializeObject(model));
using (var client = RestApiClient.GetThirdPartyClient())
{
APIJsonResponse jsonResponse = new APIJsonResponse();
var obj = JsonConvert.SerializeObject(model);
var jbdContent = new StringContent(obj.ToString(), Encoding.UTF8, "application/json");
try
{
var URL = "TP/SMSApi";
HttpResponseMessage resp = client.PostAsync(URL, jbdContent).Result;
string resultData = resp.Content.ReadAsStringAsync().Result;
if (resp.IsSuccessStatusCode)
{
jsonResponse = JsonConvert.DeserializeObject<APIJsonResponse>(resultData);
var a = (jsonResponse.Data != null ? JsonConvert.DeserializeObject<CommonResponse>(jsonResponse.Data.ToString()) : null);
jsonResponse.Data = a;
return jsonResponse;
}
else
{
var errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
var jsonResponseData = JsonConvert.DeserializeObject<APIJsonResponse>(errorJson.Message);
var data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
jsonResponse.Id = jsonResponseData.Id;
jsonResponse.ResponseCode = jsonResponseData.ResponseCode;
jsonResponse.Msg = jsonResponseData.Msg;
jsonResponse.Data = data;
jsonResponse.Extra = jsonResponseData.Extra;
jsonResponse.Extra1 = jsonResponseData.Extra1;
return jsonResponse;
}
}
catch (Exception ex)
{
return new APIJsonResponse()
{
ResponseCode = "1",
Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message)
};
}
}
}
}
}

2
CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/IRegisterBusiness.cs

@ -13,7 +13,7 @@ namespace CustomerOnlineV2.Business.Business.RegisterBusiness
{
public interface IRegisterBusiness
{
Task<CommonResponse> AddCustomers(OnlineCustomerRegisterModel register);
Task<JsonRxResponse> AddCustomers(OnlineCustomerRegisterModel register);
Task<AddressListResponse> GetAddressList(AddressRequest addressRequest);
Task<CustomerList> GetTranCustomerById(LoginResponse loginDetails);
Task<CustomerListModel> UpdateCustomers(CustomerListModel customer, string Id);

73
CustomerOnlineV2/CustomerOnlineV2.Business/Business/RegisterBusiness/RegisterBusiness.cs

@ -2,15 +2,12 @@
using CustomerOnlineV2.Common.Models;
using CustomerOnlineV2.Common.Models.AccountModel;
using CustomerOnlineV2.Common.Models.HomeModel;
using CustomerOnlineV2.Common.Models.Notification;
using CustomerOnlineV2.Common.Models.RegisterModel;
using CustomerOnlineV2.Repository.Repository.RegisterRepository;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Notify = CustomerOnlineV2.Common.Models.Notification;
namespace CustomerOnlineV2.Business.Business.RegisterBusiness
{
@ -20,7 +17,7 @@ namespace CustomerOnlineV2.Business.Business.RegisterBusiness
private readonly ITPApiService _tpApi;
private readonly IRegisterRepository _registerRepository;
@ -30,41 +27,85 @@ namespace CustomerOnlineV2.Business.Business.RegisterBusiness
_registerRepository = registerRepository;
}
public async Task<CommonResponse> AddCustomers(OnlineCustomerRegisterModel register)
public async Task<JsonRxResponse> AddCustomers(OnlineCustomerRegisterModel register)
{
var model1 = await _registerRepository.AddRegisterDetails(register);
return model1;
try
{
if (model1.ErrorCode.Equals("0"))
{
List<Mapping> bodyMappings = new List<Notify.Mapping>();
bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = register.fullName });
bodyMappings.Add(new Mapping() { SValue = "CustomerId", SText = "" });
bodyMappings.Add(new Mapping() { SValue = "UserId", SText = register.membershipId });
bodyMappings.Add(new Mapping() { SValue = "FirstName", SText = register.firstName });
bodyMappings.Add(new Mapping() { SValue = "MiddleName", SText = register.middleName });
bodyMappings.Add(new Mapping() { SValue = "LastName", SText = register.lastName1 });
bodyMappings.Add(new Mapping() { SValue = "MobileNo", SText = register.mobile });
bodyMappings.Add(new Mapping() { SValue = "Address", SText = register.address });
bodyMappings.Add(new Mapping() { SValue = "EMAIL_ID", SText = register.email });
bodyMappings.Add(new Mapping() { SValue = "RegisteredDate", SText = "" });
SendNotificationRequest request = new SendNotificationRequest()
{
IsBulkNotification = false,
UserName = register.email,
ProviderId = "BasicRegistration",
NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
Template = Common.Models.Notification.NotifyTemplate.BASIC_REGISTRATION_EMAIL,
Recipients = new List<RecipientViewModel>()
{
new RecipientViewModel()
{
NotificationContent = new NotificationDTO() {
Body = JsonConvert.SerializeObject(bodyMappings),
//Title will be set by mapping json
},
Address= register.email
}
}
};
var model = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
}
return model1;
}
catch (Exception ex)
{
_logger.LogError("Something Went Wrong, Please Try Again!!", ex);
model1.SetResponse("1", "Error occurred while calling RequestOTP.");
return model1;
}
}
public Task<AddressListResponse> GetAddressList(AddressRequest addressRequest)
{
throw new NotImplementedException();
}
public async Task<CustomerList> GetTranCustomerById(LoginResponse loginDetails)
{
return await _registerRepository.GetTranCustomerById(loginDetails);
}
public async Task<CustomerNotificationModel> GetAllNotificationDetails(LoginResponse loginDetails)
public async Task<CustomerNotificationModel> GetAllNotificationDetails(LoginResponse loginDetails)
{
return (CustomerNotificationModel)await _registerRepository.GetAllNotificationDetails(loginDetails);
}
public async Task<CustomerListModel> UpdateCustomers(CustomerListModel model, string id)
public async Task<CustomerListModel> UpdateCustomers(CustomerListModel model, string id)
{
var model1 = await _registerRepository.UpdateCustomers1(model, id);
return model1;
}
public async Task<CustomerListModel> UpdateDocuments(CustomerListModel model, string Id)
{
var model1 = await _registerRepository.UpdateDocument1(model, Id);
return model1;
}
public async Task<CustomerNotificationModel> GetRewardPoints(LoginResponse loginDetails)
public async Task<CustomerNotificationModel> GetRewardPoints(LoginResponse loginDetails)
{
return (CustomerNotificationModel)await _registerRepository.GetRewardPoints(loginDetails);
}
}
}

84
CustomerOnlineV2/CustomerOnlineV2.Business/Business/ThirdPartyAPI.cs

@ -0,0 +1,84 @@
using CustomerOnlineV2.Common.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http.Headers;
using System.Text;
namespace CustomerOnlineV2.Business.Business
{
public class ThirdPartyAPI
{
private static int timeOut = 100;
private string tp_base_url = "http://77.68.15.91:1083/api/v1/";
private string apiAccessKey = "KPb1ttRs3CJnORpVU8SmAKUs7a42vtvjzQ47gU0b4u0vxAEI0PgZref6puzkVhLTX2PRNMGCbnb2TglupsjV5AGhYvw8a8POTcUcFSrEdHmTkhkIGNvUvxSpKjUOXGFQWaGU1bxoqqUSaFOmNE5zGojVmwPoMy38CNLwnpQKjdsIuxCKGCApa2gWHJl9gebmIpUODv9jAZgmMEaXqyR4CLg4iSksfTyYNjdqxEE88P5THYt5GuNk8Ti6K2RxIKfPWY49hBOpiYnXcApgSDiKFYqQG9WuZ7cvDGJIWg5WgWKjGle8Y3OydhONXVkN5OMPXDA4VZkK4c5nM363Zkg4w4qdzWuwhsEoAwU4rej6sMRZue3L0BowBJja1OK0iPoTX70EexX8rviMLOZPUDwhxzkL3eODS69VEEbjHb8WSjhho5h3KnCE4tcqCWihwSZ8Yuyhw1rzIMNw2C8pN1GEJyXc6goIFkf7dmK9ynJSxu52D9GjOkKqoD7dFNFulOFVfgeCuhPDYG2A2c2RSvGHv24VDXvmGVaAMLiPtsTz5oD8f0na7fX1xGg0Qveh0KgQL5THnrMK6gm5Ky7O8nbecIxY";
public ResponseModel ThirdPartyApiGetDataOnly<RequestModel, ResponseModel>(RequestModel model, string api_url, out APIJsonResponse jsonResponse, string MethodType = "post")
{
ResponseModel _responseModel = default(ResponseModel);
using (HttpClient httpClient = new HttpClient())
{
try
{
httpClient.BaseAddress = new Uri(tp_base_url);
httpClient.DefaultRequestHeaders.Add("apiAccessKey", apiAccessKey);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.Timeout = new TimeSpan(0, 0, timeOut);
HttpResponseMessage resp = new HttpResponseMessage();
if (MethodType.ToLower().Equals("get"))
resp = httpClient.GetAsync(api_url).Result;
if (MethodType.ToLower().Equals("put"))
{
StringContent jbdContent = new StringContent(JsonConvert.SerializeObject(model).ToString(), Encoding.UTF8, "application/json");
resp = httpClient.PutAsync(api_url, jbdContent).Result;
}
if (MethodType.ToLower().Equals("post"))
{
var jsonData = JsonConvert.SerializeObject(model).ToString();
StringContent jbdContent = new StringContent(jsonData, Encoding.UTF8, "application/json");
resp = httpClient.PostAsync(api_url, jbdContent).Result;
}
string resultData = resp.Content.ReadAsStringAsync().Result;
if (resp.IsSuccessStatusCode)
{
var result = resp.Content.ReadAsStringAsync().Result;
JObject a = JObject.Parse(result);
_responseModel = a.ToObject<ResponseModel>();
}
else
{
ErrorJosn errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData);
APIJsonResponse jsonResponseData = JsonConvert.DeserializeObject<APIJsonResponse>(errorJson.Message);
List<Data> data = JsonConvert.DeserializeObject<List<Data>>(jsonResponseData.Data.ToString());
jsonResponse = new APIJsonResponse()
{
Id = jsonResponseData.Id,
Msg = jsonResponseData.Msg,
Data = data,
Extra = jsonResponseData.Extra,
Extra1 = jsonResponseData.Extra1
};
}
}
catch (HttpRequestException ex)
{
jsonResponse = new APIJsonResponse()
{
ResponseCode = "999",
Msg = ex.Message,
Data = ex.Data,
};
_responseModel = default(ResponseModel);
}
};
jsonResponse = new APIJsonResponse()
{
ResponseCode = "0",
Msg = "Api Calling process successfully!"
};
return _responseModel;
}
}
}

62
CustomerOnlineV2/CustomerOnlineV2.Common/Helper/ApplicationConfig.cs

@ -0,0 +1,62 @@
using CustomerOnlineV2.Common.Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomerOnlineV2.Common.Helper
{
public static class ApplicationConfig
{
public static string GetDocumentUploadPath()
{
return ReadWebConfig("docUploadPath");
}
public static string GetDocumentUploadUrl()
{
return ReadWebConfig("docUploadURL");
}
public static string GetTelecomsIconRelativePath()
{
return ReadWebConfig("telecomsIconRelativePath");
}
public static string GetCountryFlagRelativePath()
{
return ReadWebConfig("countryFlagRelativePath");
}
public static string GetKycImageRelativePath()
{
return ReadWebConfig("kycImageRelativePath");
}
public static string GetRewardImageRelativePath()
{
return ReadWebConfig("rewardImageRelativePath");
}
public static string GetRootURL()
{
return ReadWebConfig("rootUrl");
}
public static string GetMaximumFileSize()
{
return ReadWebConfig("maxFileSize");
}
public static string ReadWebConfig(string key)
{
return ReadWebConfig(key, "");
}
public static string ReadWebConfig(string key, string defValue)
{
return ConfigurationManager.AppSettings[key] ?? defValue;
}
}
}

2
CustomerOnlineV2/CustomerOnlineV2.Common/Helper/LoginUserInfo.cs

@ -22,7 +22,7 @@ namespace CustomerOnlineV2.Common.Helper
model.RememberMe = Convert.ToBoolean(claimIdentity.FindFirst(x => x.Type == "RememberMe").Value);
model.SessionId = claimIdentity.FindFirst(x => x.Type == "SessionId").Value;
model.UserId = claimIdentity.FindFirst(x => x.Type == "UserId").Value;
model.IsEmailVerified = Convert.ToBoolean(claimIdentity.FindFirst(x => x.Type == "IsEmailVerified").Value);
}
return model;
}

15
CustomerOnlineV2/CustomerOnlineV2.Common/Helper/Utilities.cs

@ -1,5 +1,6 @@
using CustomerOnlineV2.Common.Configs;
using Microsoft.AspNetCore.Http;
using System.Text.RegularExpressions;
namespace CustomerOnlineV2.Common.Helper
{
@ -66,6 +67,18 @@ namespace CustomerOnlineV2.Common.Helper
else
return strVal;
}
public static string GenerateOTP()
{
string[] strChar = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
Random random = new Random();
string otpChar = strChar[random.Next(0, 10)] + strChar[random.Next(0, 10)] +
strChar[random.Next(0, 10)] + strChar[random.Next(0, 10)] +
strChar[random.Next(0, 10)] + strChar[random.Next(0, 10)];
return otpChar;
}
public static bool IsValidEmail(this string email)
{
return Regex.IsMatch(email ?? "", ApplicationConfig.ReadWebConfig("regex"), RegexOptions.IgnoreCase);
}
}
}

24
CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs

@ -46,4 +46,28 @@ namespace CustomerOnlineV2.Common.Models.AccountModel
public string? MembershipId { get; set; }
public bool IsEmailVerified { get; set; }
}
public class VerifyOtpModel
{
public string? Email { get; set; }
public string otp { get; set; }
}
public class RequestOTPModel
{
public string? userId { get; set; }
public string? OTP { get; set; }
public string? requestFor { get; set; }
public string? receiverId { get; set; }
public string? mobileNo { get; set; }
public string? customerName { get; set; }
public string? IpAddress { get; set; }
public string? sessionId { get; set; }
public string? FcmId { get; set; }
public string? ProcessId { get; set; }
public string? MethodName { get; set; }
public string? CreatedBy { get; set; }
[JsonIgnore]
public string? DeviceType { get; set; }
[JsonIgnore]
public string? Lang { get; set; }
}
}

104
CustomerOnlineV2/CustomerOnlineV2.Common/Models/CommonResponse.cs

@ -17,7 +17,15 @@
ResponseMessage = ResponseMessageHelper.FAILED;
}
public CommonResponse(int responseCode, string? responseMessage, string? id = null, string? extra = null)
public CommonResponse(int responseCode, string? responseMessage, string? id = null, string? extra = null, string? extra2 = null)
{
ResponseCode = responseCode;
ResponseMessage = responseMessage;
Id = id;
Extra = extra;
Extra2 = extra2;
}
public void SetResponse(int responseCode, string? responseMessage, string? id = null, string? extra = null)
{
ResponseCode = responseCode;
ResponseMessage = responseMessage;
@ -29,4 +37,98 @@
public string Message { get; set; }
}
}
public class JsonRxResponse
{
private string? _errorCode = "";
private string? _msg = "";
private string? _id = "";
private string? _extra = "";
private string? _extra2 = "";
private string? _extra3 = "";
private object _data = null;
private string? _footNoteMessage = "";
public string ErrorCode
{
set { _errorCode = value; }
get { return _errorCode; }
}
public string Msg
{
set { _msg = value; }
get { return _msg; }
}
public string Id
{
set { _id = value; }
get { return _id; }
}
public string Extra
{
set { _extra = value; }
get { return _extra; }
}
public string Extra2
{
set { _extra2 = value; }
get { return _extra2; }
}
public string Extra3
{
set { _extra3 = value; }
get { return _extra3; }
}
public object Data
{
set { _data = value; }
get { return _data; }
}
public JsonRxResponse()
{
}
public string FootNoteMessage
{
set { _footNoteMessage = value; }
get { return _footNoteMessage; }
}
public void SetResponse(string? errorCode, string? message, string? id = null, string? extra = null)
{
ErrorCode = errorCode;
Msg = message;
Id = id;
Extra = extra;
}
}
public class APIJsonResponse
{
public string? ResponseCode { get; set; }
public string? Msg { get; set; }
public string? Id { get; set; }
public object? Data { get; set; }
public string? Extra { get; set; }
public string? Extra1 { get; set; }
public string? Extra2 { get; set; }
public string? Extra3 { get; set; }
public string? FootNoteMessage { get; set; }
public void SetResponse(string responseCode, string msg, string id = null, string extra = null, string extra1 = null, string extra3 = null, string footNoteMessage = "")
{
ResponseCode = responseCode;
Msg = msg;
Id = id;
Extra = extra;
Extra1 = extra1;
Extra3 = extra3;
FootNoteMessage = footNoteMessage;
}
}
public class ErrorJosn
{
public string Message { get; set; }
}
public class Data
{
public string Name { get; set; }
public string Message { get; set; }
}
}

33
CustomerOnlineV2/CustomerOnlineV2.Common/Models/Notification/RestApiClient.cs

@ -0,0 +1,33 @@
using CustomerOnlineV2.Common.Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace CustomerOnlineV2.Common.Models.Notification
{
public class RestApiClient
{
private static int timeOut = 100;//Convert.ToInt16(ConfigurationManager.AppSettings["ApiTimeOutSeconds"]);
public static HttpClient GetThirdPartyClient()
{
//string authHeader = ConfigurationManager.AppSettings["ApiUser"].ToString() + ":" +ConfigurationManager.AppSettings["ApiPwd"].ToString();
//var plainTextBytes = Encoding.UTF8.GetBytes(authHeader);
//string encodedAuthHeader = Convert.ToBase64String(plainTextBytes);
string thirdPartyUrl = "http://77.68.15.91:1083/api/v1/"; //ConfigurationManager.AppSettings["ThirdParty_Base_Url"].ToString();
string apiAccessKey = "KPb1ttRs3CJnORpVU8SmAKUs7a42vtvjzQ47gU0b4u0vxAEI0PgZref6puzkVhLTX2PRNMGCbnb2TglupsjV5AGhYvw8a8POTcUcFSrEdHmTkhkIGNvUvxSpKjUOXGFQWaGU1bxoqqUSaFOmNE5zGojVmwPoMy38CNLwnpQKjdsIuxCKGCApa2gWHJl9gebmIpUODv9jAZgmMEaXqyR4CLg4iSksfTyYNjdqxEE88P5THYt5GuNk8Ti6K2RxIKfPWY49hBOpiYnXcApgSDiKFYqQG9WuZ7cvDGJIWg5WgWKjGle8Y3OydhONXVkN5OMPXDA4VZkK4c5nM363Zkg4w4qdzWuwhsEoAwU4rej6sMRZue3L0BowBJja1OK0iPoTX70EexX8rviMLOZPUDwhxzkL3eODS69VEEbjHb8WSjhho5h3KnCE4tcqCWihwSZ8Yuyhw1rzIMNw2C8pN1GEJyXc6goIFkf7dmK9ynJSxu52D9GjOkKqoD7dFNFulOFVfgeCuhPDYG2A2c2RSvGHv24VDXvmGVaAMLiPtsTz5oD8f0na7fX1xGg0Qveh0KgQL5THnrMK6gm5Ky7O8nbecIxY";
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(thirdPartyUrl);
httpClient.DefaultRequestHeaders.Add("apiAccessKey", apiAccessKey.ToString());
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.Timeout = new TimeSpan(0, 0, timeOut);
return httpClient;
}
}
}

21
CustomerOnlineV2/CustomerOnlineV2.Common/Models/Notification/SMSRequestModel.cs

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomerOnlineV2.Common.Models.Notification
{
public class SMSRequestModel
{
public string? ProcessId { get; set; }
public string? UserName { get; set; }
public string? RequestedBy { get; set; }
public string? MobileNumber { get; set; }
public string? SMSBody { get; set; }
public string? method { get; set; }
public string? ProviderId { get; set; }
public string? ControlNo { get; set; }
public string? MTID { get; set; }
}
}

1
CustomerOnlineV2/CustomerOnlineV2.Common/Models/RegisterModel/UserRegisterResponse.cs

@ -181,5 +181,6 @@ namespace CustomerOnlineV2.Common.Models.RegisterModel
public string? islocked { get; set; }
public string? sessionId { get; set; }
public string? AboutUs { get; set; }
public string? otp { get; set; }
}
}

3
CustomerOnlineV2/CustomerOnlineV2.Repository/ConnectionHelper/ConnectionHelper.cs

@ -179,7 +179,8 @@ namespace CustomerOnlineV2.Repository.ConnectionHelper
response.Id = Convert.ToString(dt.Rows[0][2]);
if (dt.Columns.Count > 3)
response.Extra = Convert.ToString(dt.Rows[0][3]);
if (dt.Columns.Count > 4)
response.Extra2 = Convert.ToString(dt.Rows[0][4]);
return response;
}
}

49
CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs

@ -96,6 +96,8 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository
}
return await Task.FromResult(_response);
}
public async Task<CommonResponse> PasswordReset(PasswordResetModel model, LoginResponse logindetails)
{
CommonResponse _response = new CommonResponse();
@ -104,7 +106,9 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository
var sql = "EXEC JsonRx_Proc_UserRegistration @flag='pwd-reset' ";
sql += " ,@username = " + _connHelper.FilterString(model.Username);
sql += ", @dob = " + _connHelper.FilterString(model.Dob);
sql += ", @randomPassword = " + _connHelper.FilterString(model.RandomPassword);
_logger.LogDebug("ACCOUNTREPOSITORY | RESETPASSWORD | SQL | " + sql);
return _connHelper.ParseDbResult(sql);
}
@ -117,5 +121,50 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository
}
return await Task.FromResult(_response);
}
public JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel)
{
var sql = "EXEC mobile_proc_OTPRequest @flag='REQUEST' ";
sql += ", @USER_ID = " + _connHelper.FilterString(requestOTPModel.CreatedBy);
sql += ", @OTP_CODE = " + _connHelper.FilterString(requestOTPModel.OTP);
sql += ", @REQUEST_FOR = " + _connHelper.FilterString(requestOTPModel.requestFor);
sql += ", @RECEIVER_ID = " + _connHelper.FilterString(requestOTPModel.receiverId);
_logger.LogDebug("RequestOTP | SQL : {0}", sql);
var _dbRes = _connHelper.ParseDbResult(sql);
_logger.LogDebug("RequestOTP | DB RESPONSE : " + JsonConvert.SerializeObject(_dbRes));
List<string> successCode = new List<string> { "0", "100", "103" };
return new JsonRxResponse
{
ErrorCode = successCode.Contains(_dbRes.ResponseCode.ToString()) ? "0" : "1",
Msg = _dbRes.ResponseMessage,
Id = _dbRes.Id,
Extra = _dbRes.Extra,
Extra2 = _dbRes.Extra2
};
}
public async Task<JsonRxResponse> VerifyOtp(RequestOTPModel requestOTPModel, LoginResponse logindetails)
{
JsonRxResponse _response;
try
{
var sql = "EXEC mobile_proc_OTPRequest @flag='SUBMIT' ";
sql += " ,@USER_ID = " + _connHelper.FilterString(requestOTPModel.CreatedBy);
sql += ", @OTP_CODE = " + _connHelper.FilterString(requestOTPModel.OTP.Trim());
sql += ", @REQUEST_FOR = " + _connHelper.FilterString(requestOTPModel.requestFor);
sql += ", @RECEIVER_ID = " + _connHelper.FilterString(requestOTPModel.receiverId);
_logger.LogDebug("SubmitOTP | Lang {0} | SQL : {1}", sql);
var _dbRes = _connHelper.ParseDbResult(sql);
_response = new JsonRxResponse
{
ErrorCode = _dbRes.ResponseCode.ToString(),
Msg = _dbRes.ResponseMessage
};
}
catch (Exception ex)
{
_logger.LogError("Error in VerifyOtp: {0}", ex.Message);
_response = new JsonRxResponse { ErrorCode = "1", Msg = "An error occurred while verifying OTP." };
}
return await Task.FromResult(_response);
}
}
}

2
CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs

@ -8,5 +8,7 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository
Task<CommonResponse> ChangePassword(ForceChangePasswordModel model, LoginResponse logindetails);
Task<LoginResponse> Login(LoginModel model);
Task<CommonResponse> PasswordReset(PasswordResetModel model, LoginResponse logindetails);
Task<JsonRxResponse> VerifyOtp(RequestOTPModel requestOTPModel, LoginResponse logindetails);
JsonRxResponse RequestOTP(RequestOTPModel requestOTPModel);
}
}

4
CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/IRegisterRepository.cs

@ -12,10 +12,10 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
{
public interface IRegisterRepository
{
Task<CommonResponse> AddRegisterDetails(OnlineCustomerRegisterModel register);
Task<JsonRxResponse> AddRegisterDetails(OnlineCustomerRegisterModel register);
Task<CustomerList> GetTranCustomerById(LoginResponse loginDetails);
Task<CustomerNotificationModel> GetAllNotificationDetails(LoginResponse loginDetails);
Task<CustomerListModel> UpdateCustomers1(CustomerListModel model, string id);
Task<CustomerListModel> UpdateCustomers1(CustomerListModel model, string id);
Task<CustomerNotificationModel> GetRewardPoints(LoginResponse loginDetails);
Task<CustomerListModel> UpdateDocument1(CustomerListModel model, string id);
}

59
CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs

@ -26,8 +26,9 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
_connHelper = connHelper;
}
public async Task<CommonResponse> AddRegisterDetails(OnlineCustomerRegisterModel model)
public async Task<JsonRxResponse> AddRegisterDetails(OnlineCustomerRegisterModel model)
{
var response = new JsonRxResponse();
try
{
var sql = "EXEC proc_online_core_customerSetup";
@ -60,40 +61,36 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
sql += ",@serviceUsedFor =" + _connHelper.FilterString("on");
var dt = _connHelper.ExecuteDataTable(sql);
if (dt == null || dt.Rows.Count <= 0)
{
model.ResponseCode = ResponseHelper.FAILED;
model.ResponseMessage = "DB Null Error!";
response.ErrorCode = ResponseHelper.FAILED.ToString();
response.Msg = "DB Null Error!";
}
else if (dt.Rows[0]["ErrorCode"].Equals("0"))
{
model.ResponseCode = ResponseHelper.SUCCESS;
model.ResponseMessage = "Customer is registered. Proceed to login.";
response.ErrorCode = ResponseHelper.SUCCESS.ToString();
response.Msg = "Customer is registered. Proceed to login.";
}
else
{
model.ResponseCode = ResponseHelper.FAILED;
model.ResponseMessage = dt.Rows[0]["Msg"].ToString();
response.ErrorCode = ResponseHelper.FAILED.ToString();
response.Msg = dt.Rows[0]["Msg"].ToString();
}
}
catch (Exception ex)
{
model.ResponseCode = ResponseHelper.EXCEPTION;
model.ResponseMessage = "Exception occured: " + ex.Message;
response.ErrorCode = ResponseHelper.EXCEPTION.ToString();
response.Msg = "Exception occured: " + ex.Message;
}
return await Task.FromResult(model);
return await Task.FromResult(response);
}
public async Task<CustomerList> GetTranCustomerById(LoginResponse loginDetails)
@ -119,7 +116,6 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
_response.ResponseCode = Convert.ToInt16(dt.Rows[0]["errorCode"]);
_response.ResponseMessage = Convert.ToString(dt.Rows[0]["msg"]);
List<CustomerListModel> obj = new List<CustomerListModel>();
foreach (DataRow item in dt.Rows)
{
@ -135,7 +131,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
address = Convert.ToString(item["address1"]),
address2 = Convert.ToString(item["address2"]),
idType = Convert.ToString(item["idType"]),
idNumber = Convert.ToString(item["idNumber"]),
idNumber = Convert.ToString(item["idNumber"]),
idIssueDate = Convert.ToString(item["idIssueDate"]),
idExpiryDate = Convert.ToString(item["idExpiryDate"]),
nativeCountry = Convert.ToString(item["ICountryName"])
@ -153,7 +149,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
}
return await Task.FromResult(_response);
}
public async Task<CustomerNotificationModel> GetAllNotificationDetails(LoginResponse loginDetails)
public async Task<CustomerNotificationModel> GetAllNotificationDetails(LoginResponse loginDetails)
{
CustomerNotificationModel _response = new CustomerNotificationModel();
try
@ -192,7 +188,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
Category = Convert.ToString(item["category"]),
//url = Convert.ToString(item["url"]),
//IsClickable = Convert.ToString(item["isClickable"])
// notificationCount = Convert.ToString(item["notificationCount"])
// notificationCount = Convert.ToString(item["notificationCount"])
});
}
_response.NotificationModel = obj;
@ -207,12 +203,8 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
}
return await Task.FromResult(_response);
}
public async Task<CustomerListModel> UpdateCustomers1(CustomerListModel model, string id)
{
try
{
var sql = "EXEC mobile_proc_online_customerMaster_V1";
@ -229,7 +221,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
//_logger.LogDebug("RECEIVERREPOSITORY | GETRECEIVEDRDETAILS | SQL | " + sql);
var dt = _connHelper.ExecuteDataTable(sql);
@ -238,14 +230,19 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
model.ResponseCode = ResponseHelper.FAILED;
model.ResponseMessage = "DB Null Error!";
// _logger.LogError("RECEIVERREPOSITORY | GETRECEIVEDRDETAILS | DB RESPONSE | " + JsonConvert.SerializeObject(_response));
}
else
{
model.ResponseCode = ResponseHelper.SUCCESS;
model.ResponseMessage = ResponseMessageHelper.SUCCESS;
// _response.firstName = Convert.ToString(dt.Rows[0]["firstName"]);
// _response.middleName = Convert.ToString(dt.Rows[0]["middleName"]);
// _response.lastName1 = Convert.ToString(dt.Rows[0]["lastName1"]);
// _response.Country = Convert.ToString(dt.Rows[0]["Country"]);
// _response.Address = Convert.ToString(dt.Rows[0]["Address"]);
// _response.State = Convert.ToString(dt.Rows[0]["State"]);
}
}
catch (Exception ex)
@ -253,7 +250,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
model.ResponseCode = ResponseHelper.EXCEPTION;
model.ResponseMessage = "Exception occured: " + ex.Message;
//_logger.LogError("RECEIVERREPOSITORY | GETRECEIVEDRDETAILS | EXCEPTION | " + JsonConvert.SerializeObject(_response));
}
return await Task.FromResult(model);
@ -309,8 +306,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
}
public async Task<CustomerNotificationModel> GetRewardPoints(LoginResponse loginDetails)
public async Task<CustomerNotificationModel> GetRewardPoints(LoginResponse loginDetails)
{
CustomerNotificationModel _response = new CustomerNotificationModel();
try
@ -361,7 +357,8 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
CustomerName = Convert.ToString(item["CUSTOMER_NAME"]),
Date = Convert.ToString(item["CREATED_DATE"]),
RewardPoints = Convert.ToString(item["REWARD_POINTS"]),
ReferralCode = Convert.ToString(item["REFERRAL_CODE"]),
ReferralCode = loginDetails.MembershipId,
//ReferralCode = Convert.ToString(item["REFERRAL_CODE"]),
//IsRead = Convert.ToString(item["isRead"]),
//Type = Convert.ToString(item["type"]),
//SentId = Convert.ToString(item["sentId"]),

19
CustomerOnlineV2/CustomerOnlineV2/Authorization/AuthorizationAttribute.cs

@ -1,8 +1,11 @@
using CustomerOnlineV2.Common.Models.AccountModel;
using CustomerOnlineV2.Common.Helper;
using CustomerOnlineV2.Common.Models.AccountModel;
using CustomerOnlineV2.Common.Models.Notification;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Net;
using System.Security.Claims;
using System.Text;
namespace CustomerOnlineV2.Authorization
{
@ -34,7 +37,7 @@ namespace CustomerOnlineV2.Authorization
_loginData.UserName = claimsIndentity.FindFirst(c => c.Type == "UserName").Value;
_loginData.SessionId = claimsIndentity.FindFirst(c => c.Type == "SessionId").Value;
_loginData.ForceChangePassword = Convert.ToBoolean(claimsIndentity.FindFirst(c => c.Type == "ForceChangePassword").Value);
_loginData.IsEmailVerified = Convert.ToBoolean(claimsIndentity.FindFirst(c => c.Type == "IsEmailVerified").Value);
//_loginData.IsEmailVerified = Convert.ToBoolean(claimsIndentity.FindFirst(c => c.Type == "IsEmailVerified").Value);
if (string.IsNullOrEmpty(_loginData.UserName))
{
@ -48,12 +51,12 @@ namespace CustomerOnlineV2.Authorization
return;
}
if (!_loginData.IsEmailVerified)
{
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
context.HttpContext.Response.Redirect("/Account/VerifyOTP");
return;
}
//is Email Verified
//{
// context.HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
// context.HttpContext.Response.Redirect("/Account/VerifyOTP");
// return;
//}
//force change password
if (_loginData.ForceChangePassword)

138
CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs

@ -1,17 +1,16 @@
using CustomerOnlineV2.Business.Business.AccountBusiness;
using CustomerOnlineV2.Common.Helper;
using CustomerOnlineV2.Common.Models.AccountModel;
using CustomerOnlineV2.Common.Models;
using Microsoft.AspNetCore.Authentication.Cookies;
using CustomerOnlineV2.Common.Models.AccountModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Serilog.Context;
using Serilog;
using Serilog.Context;
using System.Security.Claims;
using System.Web;
using System.Security.Permissions;
namespace CustomerOnlineV2.Controllers
{
@ -41,6 +40,7 @@ namespace CustomerOnlineV2.Controllers
return View();
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
@ -75,13 +75,18 @@ namespace CustomerOnlineV2.Controllers
new Claim("SessionId", result.SessionId),
new Claim("UserId", result.UserId),
new Claim("MembershipId", result.MembershipId),
new Claim("IsEmailVerified", Convert.ToString(result.IsEmailVerified))
//new Claim("IsEmailVerified", Convert.ToString(result.IsEmailVerified)),
};
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentity));
if (!result.IsEmailVerified)
{
Log.Information("ACCOUNTCONTROLLER | LOGIN | VERIFY OTP");
return RedirectToAction("VerifyOTP", "Account");
}
if (result.ForceChangePassword)
{
Log.Information("ACCOUNTCONTROLLER | LOGIN | FORCE CHANGE PASSWORD");
@ -186,5 +191,128 @@ namespace CustomerOnlineV2.Controllers
}
}
}
public async Task<IActionResult> VerifyOTP(RequestOTPModel requestOTPModel)
{
requestOTPModel.sessionId = Guid.NewGuid().ToString().Replace("-", "");
var loginDetails = HttpContext.GetLoginDetails();
string userEmail = loginDetails.UserName;
try
{
if (!loginDetails.IsEmailVerified)
{
requestOTPModel.ProcessId = Guid.NewGuid().ToString();
requestOTPModel.MethodName = "RequestOTP";
requestOTPModel.CreatedBy = userEmail;
requestOTPModel.IpAddress = "";
requestOTPModel.requestFor = "REGISTER";
Log.Debug("RequestOTP | REQUEST : " + JsonConvert.SerializeObject(requestOTPModel));
var staticDataResponse = _accountBusiness.RequestOTP(requestOTPModel);
if (staticDataResponse.ErrorCode == "0")
{
var viewModel = new VerifyOtpModel
{
Email = userEmail,
otp = "",
};
ViewBag.ResponseCode = "0";
ViewBag.ResponseMessage = "OTP has been sent.";
return View(viewModel);
}
else
{
ViewBag.ResponseCode = staticDataResponse.ErrorCode;
ViewBag.ResponseMessage = staticDataResponse.Msg;
_logger.LogError("ACCOUNTCONTROLLER | REQUESTOTP | ERROR OCCURED | " + JsonConvert.SerializeObject(staticDataResponse));
return View();
}
}
return View("ErrorViewName");
}
catch (Exception ex)
{
_logger.LogError("An error occurred in VerifyOtp action.", ex);
return View("ErrorViewName");
}
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> VerifyOtp(RequestOTPModel requestOTPModel)
{
try
{
var loginDetails = HttpContext.GetLoginDetails();
if (string.IsNullOrEmpty(loginDetails.UserName))
{
_logger.LogError("ACCOUNTCONTROLLER | VERIFYOTP | INVALID logindetails.UserName");
return RedirectToAction("Index", "Account");
}
requestOTPModel.ProcessId = Guid.NewGuid().ToString();
requestOTPModel.MethodName = "SubmitOTP";
requestOTPModel.CreatedBy = loginDetails.Email;
requestOTPModel.IpAddress = "";
requestOTPModel.requestFor = "REGISTER";
using (LogContext.PushProperty("DebugId", loginDetails.UserName))
{
_logger.LogDebug("ACCOUNTCONTROLLER | VERIFYOTP | REQUEST | " + JsonConvert.SerializeObject(requestOTPModel));
var response = await _accountBusiness.VerifyOtp(requestOTPModel, loginDetails);
Log.Debug("verify OTP response: " + JsonConvert.SerializeObject(response));
if (response.ErrorCode == ResponseHelper.SUCCESS.ToString())
{
var currentUser = HttpContext.User as ClaimsPrincipal;
var identity = currentUser?.Identity as ClaimsIdentity;
if (identity != null)
{
var isEmailVerifiedClaim = identity.FindFirst("IsEmailVerified");
if (isEmailVerifiedClaim != null)
{
identity.RemoveClaim(isEmailVerifiedClaim);
}
identity.AddClaim(new Claim("IsEmailVerified", "true"));
}
Log.Debug("ACCOUNTCONTROLLER | VERIFYOTP | REQUEST ARRIVED | " + loginDetails.Email);
return RedirectToAction("Index", "Home");
}
else
{
ViewBag.ResponseCode = response.ErrorCode;
ViewBag.ResponseMessage = response.Msg;
_logger.LogError("ACCOUNTCONTROLLER | LOGIN | ERROR OCCURRED | " + JsonConvert.SerializeObject(response));
return View();
}
}
}
catch (Exception ex)
{
_logger.LogError("An error occurred in VerifyOtp action.", ex);
return RedirectToAction("Index", "Account");
}
}
private async Task ResetIsEmailVerifiedClaimAsync(string email, bool newIsEmailVerifiedValue)
{
var existingClaims = (ClaimsIdentity)User.Identity;
var existingIsEmailVerifiedClaim = existingClaims.FindFirst("IsEmailVerified");
if (existingIsEmailVerifiedClaim != null)
{
existingClaims.RemoveClaim(existingIsEmailVerifiedClaim);
}
// Add a new "IsEmailVerified" claim with the updated value
var newIsEmailVerifiedClaim = new Claim("IsEmailVerified", newIsEmailVerifiedValue.ToString());
existingClaims.AddClaim(newIsEmailVerifiedClaim);
// Sign in again with the updated claims
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(existingClaims));
}
}
}

255
CustomerOnlineV2/CustomerOnlineV2/Views/Account/VerifyOTP.cshtml

@ -0,0 +1,255 @@
@model CustomerOnlineV2.Common.Models.AccountModel.VerifyOtpModel
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<script src="~/vendor/jquery/jquery.min.js"></script>
<link href="~/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/vendor/font-awesome/css/all.min.css" rel="stylesheet" />
<link href="~/vendor/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" />
<link href="~/vendor/currency-flags/css/currency-flags.min.css" rel="stylesheet" />
<link href="~/vendor/owl.carousel/owl.carousel.min.css" rel="stylesheet" />
<link href="~/css/styles-login.css" rel="stylesheet" />
<link href="~/vendor/toast-alert/izitoast.min.css" rel="stylesheet" />
<script src="~/vendor/toast-alert/izitoast.min.js"></script>
<link rel="icon" type="image/png" href="favicon.png" />
</head>
<body>
<div id="main-wrapper">
<!-- Header -->
<header id="header">
<div class="container">
<div class="header-row">
<div class="header-column justify-content-between">
<!-- Logo
============================= -->
<div class="logo me-3">
<a class="d-flex" href="/#" title="Money - HTML Template">
<img src="images/imelondon.svg" height="35" alt="IME London - Logo" />
</a>
</div>
<!-- Logo end -->
<!-- Collapse Button
============================== -->
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#header-nav"><span></span> <span></span> <span></span></button>
<!-- Collapse Button end -->
<!-- Primary Navigation
============================== -->
<nav class="primary-menu navbar navbar-expand-lg">
<div id="header-nav" class="collapse navbar-collapse">
<ul class="navbar-nav me-auto">
<li><a href="https://imelondon.co.uk/faqs">Help</a></li>
<li><a href="https://imelondon.co.uk/how-it-works">How It Works</a></li>
<li><a href="/Customer/CustomerRegistration">Register Now</a></li>
</ul>
</div>
</nav>
<!-- Primary Navigation end -->
</div>
<div class="header-column justify-content-end">
<!-- Login & Signup Link
============================== -->
<!-- Login & Signup Link end -->
</div>
</div>
</div>
</header>
<!-- Header End -->
<!-- Page Header
<div id="content">
<!-- Who we are -->
<section class="section section-form-bg">
<div class="container">
<div class="row align-items-center">
<div class="col-md-7 pe-0">
<div class="contact-from-wrap">
<div class="sec-heading mb-5">
<h2 class="sec-title">Verify OTP</h2>
<div class="text-3">Please enter the 6-digit code sent to your email address</div>
<p class="sec-subtitle"></p>
</div>
@* <form action="dashboard-new.html" id="reset-form" class=""> *@
<form asp-controller="Account" id="reset-form" asp-action="verifyOtp" method="post" novalidate>
<div class="form-floating mb-3">
<input type="email" class="form-control" asp-for="Email" readonly>
<label for="floatingInput">Email address</label>
</div>
<div class="form-floating mb-1">
<input type="text" class="form-control" asp-for="otp">
<label for="floatingInput">OTP</label>
</div>
@* <div class="col-lg-3 mt-4">
<div class="d-grid mb-5">
<button type="submit" id="btnSubmit" onclick="VerifyOtp()" class="btn btn-primary btn-sumbit-blue" style="width: 250px;">
<span class="resetText">Submit</span>&nbsp;<div class="spinner-border text-success loading" role="status" style="display:none;"></div> <i class="fa fa-window-maximize px-2 loginText" aria-hidden="true"></i>
</button>
</div>
<div class="d-grid mb-5">
<button type="button" class="btn btn-secondary" onclick="CancelVerification()" style="width: 250px;">
Cancel
</button>
</div>
</div> *@
<div class="col-lg-8 mt-4">
<div class="row">
<div class="col-md-4 mb-3">
<button type="submit" id="btnSubmit" onclick="VerifyOtp()" class="btn btn-primary btn-sumbit-blue" style="width: 100%;">
<span class="resetText">Submit</span>&nbsp;<div class="spinner-border text-success loading" role="status" style="display:none;"></div> <i class="fa fa-window-maximize px-2 loginText" aria-hidden="true"></i>
</button>
</div>
<div class="col-md-4 mb-3">
<button type="button" class="btn btn-secondary" onclick="CancelVerification()" style="width: 100%;">
Cancel
</button>
</div>
</div>
</div>
</form>
<div class="mt-3"> Dont have username ? Registration won't take more than 5 min, <a class="" href="/Customer/CustomerRegistration">Register Now</a></div>
<div class="mt-3"> Already registered, <a class="" href="/Account/Index">Login Now</a></div>
</div>
</div>
<div class="col-md-5 ps-0">
<div class="contact-info-wrap">
<address>
<i class="fas fa-envelope"></i>
<span>Email Address</span>
<a href="mailto:info@imelondon.co.uk">info@imelondon.co.uk</a>
</address>
<address>
<i class="fas fa-phone-alt"></i>
<span>Contact Numbers</span>
<a href="tel:+44 02088660307">+44 02088660307</a>
<a href="tel:+44 07984713677">+44 07984713677</a>
</address>
<address>
<i class="fas fa-map-marker-alt"></i>
<span>Our Head Office</span>
Pentax House, South Hill Avenue, South Harrow, London, HA2 0DU
</address>
</div>
</div>
</div>
</div>
</section>
<!-- Who we are end -->
</div>
<footer id="footer" class="footer-web">
<div class="container">
<div class="text-center">
<div class="row">
<div class="mx-auto">
<div class="text-center text-white">
<p class="text-center mb-3 text-1">
IME London is a product of Subhida UK Limited, Pentax House,South Hill Avenue, South Harrow, London, H2A 0D
Company Registration No. 06432399 Subhida UK Ltd is authorized and regulated by the Financial Conduct
Authority (FCA) <br> under the Payment Service Regulations 2017. FCA Registration No. 576127 HMRC Registration No. XYML000000119350
</p>
</div>
</div>
</div>
<div class="row"><div class="col-lg-6 mx-auto"><div class="text-center text-white"><p>© IME London, 2023</p></div></div></div>
</div>
</div>
</footer>
<script type="text/javascript">
$(document).ready(function () {
if ('@ViewBag.ResponseCode' != '0') {
iziToast.error({
title: 'Error',
message: '@ViewBag.ResponseMessage'
});
}
else {
iziToast.success({
title: 'OK',
message: '@ViewBag.ResponseMessage'
});
}
});
function VerifyOtp() {
let email = $('#Email').val();
let otp = $('#otp').val();
let Data = {
Email: email,
otp: otp,
};
$.ajax(
{
type: 'POST',
url: '/Account/VerifyOtp',
data: Data,
processData: true,
headers: {
"RequestVerificationToken":
$('input[name="__RequestVerificationToken"]').val()
},
async: true,
success: function (response) {
if (response.errorCode == 0) {
ShowAlertMessage(response.errorCode, response.msg);
window.location.replace("/home");
}
else {
debugger
ShowAlertMessage(response.errorCode, response.msg);
}
},
error: function () {
ShowAlertMessage(response.errorCode, response.msg);
}
});
}
function CancelVerification() {
let confirmAction = confirm("Are you sure logout?");
if (confirmAction) {
window.location.replace("/Home/Logout");
} else {
// alert("Action canceled");
}
}
</script>
</body>
</html>

6
CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerRegistration.cshtml

@ -547,15 +547,15 @@
async: true,
success: function (response) {
EnableRegisterButton();
if (response.responseCode != 0) {
ShowAlertMessageErrorOnly(response.responseCode, response.responseMessage);
if (response.errorCode != 0) {
ShowAlertMessageErrorOnly(response.errorCode, response.msg);
//ShowAlertMessage("Receiver Successfully created")
return false;
}
// window.location.replace("/account/index");
ShowAlertMessage(response.responseCode, response.responseMessage, "/account/index");
ShowAlertMessage(response.errorCode, response.msg, "/account/index");
},

17
CustomerOnlineV2/CustomerOnlineV2/Views/Transaction/Receipt.cshtml

@ -110,6 +110,12 @@
<strong><span>@Utilities.ShowDecimal(Model.TransferFee) @Model.CollectionCurrency</span></strong>
</td>
</tr>
<tr>
<td>Reward Amount Used :</td>
<td>
<strong><span>@Model.PromotionDiscount</span></strong>
</td>
</tr>
<tr>
<td>Total Sent Amount :</td>
<td>
@ -159,22 +165,17 @@
<strong><span>@Model.PurposeOfRemit</span></strong>
</td>
</tr>
<tr>
@* <tr>
<td>
<i>Promotion Premium Rate* :</i>
</td>
<td>
<strong><span>@Model.PromotionPremiumRate</span></strong>
</td>
</tr>
</tr> *@
<tr>
<td>Promotion Discount* :</td>
<td>
<strong><span>@Model.PromotionDiscount</span></strong>
</td>
</tr>
<tr>
<td>Paid by :</td>

Loading…
Cancel
Save