send otp and mail
protected void Page_Load(object sender, EventArgs e)
{
var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
client.BaseAddress = new Uri(appsurl);
if (!IsPostBack)
{
lblshowmessage.Visible = false;
GetHeaderlogo();
GetMenuList();
#region Indexpage Username and Menu Show Page
if (Session["UserName"] != null)
{
afterlogin.InnerText = Session["UserName"].ToString();
fooItem.Visible = true;
LnkSignIn.Visible = false;
lnkRegister.Visible = false;
orshow.Visible = false;
BtnRegister.Enabled = false;
}
else
{
LnkSignIn.Visible = true;
lnkRegister.Visible = true;
fooItem.Visible = false;
}
#endregion
btnVerifay.Visible = true;
imgverify.Visible = false;
BtnRegister.Enabled = false;
}
}
#region Header and footerLogo
private List<Informal> Getinformal()
{
HttpResponseMessage hrm = client.GetAsync("api/AdminBrandingLogo").Result;
if (hrm.IsSuccessStatusCode)
{
informallist = hrm.Content.ReadAsAsync<List<Informal>>().Result;
return informallist.ToList();
}
else
{
return null;
}
}
private void GetHeaderlogo()
{
try
{
var lstfotlogo = (from m in Getinformal()
// where m.Informal_Title == "HeaderLogo"
select m).ToList();
if (lstfotlogo.ToList().Count > 0)
{
imgheader.Src = lstfotlogo.ToList()[0].Informal_Logo_Path.ToString();
footerimage.Src = lstfotlogo.ToList()[0].Informal_Logo_Path.ToString();
}
}
catch (Exception Ex)
{
}
}
#endregion
#region GetMenu & SubMenu Section
private void GetMenuList()
{
MenuText += "<ul class='megamenu skyblue'>";
if (GetTopMenu() != null)
{
topMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == null)).ToList();
if (topMenuList.Count > 0)
{
//Loop Top topMenuList
for (int i = 0; i < topMenuList.Count; i++)
{
MenuText += @"<li class='grid'><a class='color1' href='#'>" + topMenuList.ToList()[i].TopMenu_Text.ToString() + "</a>";
//Loop topChildMenuList Starts
if (GetTopMenu().ToList().OrderBy(a => a.TopMenu_Id).Where(a => (a.Parent_TopMenu_ID == topMenuList.ToList()[i].TopMenu_Id)).Count() > 0)
{
MenuText += "<div class='megapanel'><div class='row'>";
topChildMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == topMenuList.ToList()[i].TopMenu_Id)).ToList();
for (int j = 0; j < topChildMenuList.Count; j++)
{
if (i == 0)
{
if (j != 1) { MenuText += "<div class='col1'>"; }
}
else
{
MenuText += "<div class='col1'>";
}
MenuText += @"<div class='h_nav'>
<h4>" + topChildMenuList.ToList()[j].TopMenu_Text.ToString() + @"</h4>";
if (GetTopMenu().ToList().OrderBy(a => a.TopMenu_Id).Where(a => (a.Parent_TopMenu_ID == topChildMenuList.ToList()[j].TopMenu_Id)).Count() > 0)
{
topSubChildMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == topChildMenuList.ToList()[j].TopMenu_Id)).ToList();
MenuText += "<ul>";
for (int k = 0; k < topSubChildMenuList.Count; k++)
{
if (topSubChildMenuList.ToList()[k].Link_Page == null) { LinkPage = "#"; } else { LinkPage = topSubChildMenuList.ToList()[k].Link_Page.ToString().Trim(); }
if (topSubChildMenuList.ToList()[k].QueryString == null) { QueryString = ""; } else { QueryString = topSubChildMenuList.ToList()[k].QueryString.ToString().Trim(); }
MenuText += @"<li><a href='../" + LinkPage + "" + QueryString + "'>" + topSubChildMenuList.ToList()[k].TopMenu_Text.ToString() + "</a></li>";
}
MenuText += @"</ul> ";
}
MenuText += "</div>";
if (i == 0)
{
if (j != 0) { MenuText += "</div>"; }
}
else
{
MenuText += "</div>";
}
}
MenuText += @"</div>
</div>";
}
MenuText += "</li>";
}
}
MenuText += @"</ul>";
}
headerMenu.Text = MenuText;
}
private List<TopMenu> GetTopMenu()
{
HttpResponseMessage topMenu = client.GetAsync("api/TopMenu").Result;
if (topMenu.IsSuccessStatusCode)
{
MenuList = topMenu.Content.ReadAsAsync<List<TopMenu>>().Result;
return MenuList.ToList();
}
else
{
return null;
}
}
#endregion
#region Login and Register
protected void BtnRegister_Click(object sender, EventArgs e)
{
SendMail();
var email = TxtEmail.Text;
HttpResponseMessage Login_UserR = client.GetAsync("api/User").Result;
if (Login_UserR.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_UserR.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var data = (from a in GetMasterLoginUser
where a.Login_EmailId == email
select new
{
a.Login_User_ID,
}).ToList();
if (data.ToList().Count() > 0)
{
}
else
{
if (RadUserType.SelectedValue == "Customer")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Customer";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Response.Redirect("~/PublicWebsites/Default.aspx", false);
}
}
}
}
if (RadUserType.SelectedValue == "Artist")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Artist";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
// Response.Redirect("~/PublicWebsites/Default.aspx", false);
Response.Redirect("~/Supplier/Default.aspx");
}
}
}
}
if (RadUserType.SelectedValue == "Gallerist")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Gallerist";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
// Response.Redirect("~/PublicWebsites/Default.aspx", false);
Response.Redirect("~/Supplier/Default.aspx");
}
}
}
}
}
}
}
#endregion
protected void btnSignin_Click(object sender, EventArgs e)
{
switch (GetUser())
{
case "Admin":
Response.Redirect("~/Admin/AdminPage.aspx");
break;
case "Supplier":
case "Gallerist":
case "Artist":
case "Seller":
#region....checking all details....
CheckDetails();
#endregion
Response.Redirect("~/Supplier/Default.aspx");
break;
case "Customer":
if (Convert.ToString(Request.QueryString["AucUser"]) == "1")
{
Response.Redirect("~/PublicWebsites/AuctionUserPage.aspx");
}
else if (Session["ADD TO CART"] == "ADD TO CART")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else if (Session["Add to Wishlist"] == "Add to Wishlist")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else if (Session["BUY NOW"] == "BUY NOW")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else
{
Response.Redirect("~/PublicWebsites/Default.aspx");
}
//Response.Redirect("~/DolnaWebsite/Default.aspx");
break;
default:
// Response.Redirect("~/Login.aspx");
break;
}
}
private void CheckDetails()
{
#region...User Personal Information...
HttpResponseMessage Login_User = client.GetAsync("api/UserPersonalInformation").Result;
if (Login_User.IsSuccessStatusCode)
{
UserPersonalInformationList = Login_User.Content.ReadAsAsync<List<User_Personal_Information>>().Result;
var result = (from a in UserPersonalInformationList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Personal_Information_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Personal Information"] = "ok";
}
else
{
Session["Personal Information"] = "Not ok";
}
}
#endregion
#region...Bank Information...
HttpResponseMessage Login_Users = client.GetAsync("api/UserBankingInformation").Result;
if (Login_Users.IsSuccessStatusCode)
{
UserBankingInformationList = Login_Users.Content.ReadAsAsync<List<User_Banking_Information>>().Result;
var res = (from a in UserBankingInformationList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Banking_Information_ID
}).ToList();
if (res.ToList().Count() > 0)
{
Session["Bank Details"] = "Ok";
}
else
{
Session["Bank Details"] = "Not Ok";
}
}
else
{
Session["Bank Details"] = "Not Ok";
}
#endregion
#region...Additional Information...
HttpResponseMessage Login_User1 = client.GetAsync("api/UserAdditionalInformation").Result;
if (Login_User1.IsSuccessStatusCode)
{
UserAdditionalInformationlist = Login_User1.Content.ReadAsAsync<List<User_Additional_Information>>().Result;
var data = (from a in UserAdditionalInformationlist
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Additional_Information_ID
}).ToList();
if (data.ToList().Count() > 0)
{
Session["Additional Information"] = "OK";
}
else
{
Session["Additional Information"] = "Not OK";
}
}
else
{
Session["Additional Information"] = "Not OK";
}
#endregion
}
protected void btnVerifay_Click(object sender, EventArgs e)
{
string OTP = GeneratePassword(5);
string message = "One Time Password is " + OTP;
// TextBox txtmobile = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtmobile");
// Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
SendSMS.Mobile(TxtMobileNo.Text, message);
Session["OTP"] = OTP;
btnVerifay.Visible = false;
if (Session["OTP"] != "")
{
//imgverify.Visible = false;
pnlotp.Visible = true;
}
}
protected void btnimg_Click(object sender, EventArgs e)
{
string sessonOtp = Session["OTP"].ToString();
if (txtotp.Text == sessonOtp)
{
btnVerifay.Visible = false;
imgverify.Visible = true;
pnlotp.Visible = false;
BtnRegister.Enabled = true;
}
else
{
lblmsg.Text = "Enter a valid OTP";
}
}
#region Check User
private string GetUser()
{
if (TxtLogUsername.Text == "Saurendra" && TxtLogPassword.Text == "Admin@12345")
{
Session["Loginuserid"] = 0;
Session["UserName"] = "Super Admin";
Session["UserType"] = "Admin";
return "Admin";
}
HttpResponseMessage hrm = client.GetAsync("api/User").Result;
if (hrm.IsSuccessStatusCode)
{
userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == TxtLogUsername.Text && a.Login_Password == TxtLogPassword.Text && a.IsActive == true && a.IsDelete == false).ToList();
if (userList.Count > 0)
{
Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
Session["UserName"] = userList.ToList()[0].Login_Username.ToString();
Session["UserType"] = userList.ToList()[0].Login_User_Type.ToString();
Session["UserMailId"] = userList.ToList()[0].Login_EmailId.ToString();
//Session["Loged"] = "true";
return userList.ToList()[0].Login_User_Type.ToString();
}
else
{
userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == TxtLogUsername.Text && a.Login_Password == TxtLogPassword.Text && a.IsActive == false && a.IsDelete == false).ToList();
if (userList.Count > 0)
{
Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
Session["txtUsername"] = TxtLogUsername.Text;
Session["txtPassword"] = TxtLogPassword.Text;
// Response.Redirect("~/RegistationPage.aspx");
return string.Empty;
}
else
{
lblshowmessage.Visible = true;
// Response.Redirect("~/Login.aspx");
return string.Empty;
}
}
}
else
{
lblshowmessage.Visible = true;
return string.Empty;
}
}
private List<Master_Login_User> GetLogin_User()
{
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
userList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
return userList.ToList();
}
else
{
return null;
}
}
#endregion
#region Otp Method
public class SendSMS
{
#region -- Class For Sending SMS --
public static bool Mobile(string MobileNo, string Message)
{
//where the SMS Gateway is running
string ozSURL = "http://bhashsms.com/api/sendmsg.php";
//username for successful login
string ozUser = HttpUtility.UrlEncode("swash");
//user's password
string ozPassw = "Swash@2015";
//type of message
string ozSender = "swashc";
//who will get the message
string ozRecipients = HttpUtility.UrlEncode(MobileNo);
//body of message
string ozMessageData = HttpUtility.UrlEncode("One Time Password For Dolna Site Registration is : " + Message); //body of message
//priority of message
string ozPriority = "ndnd";
//type of message
string ozStype = "normal";
string createdURL = ozSURL +
"?user=" + ozUser +
"&pass=" + ozPassw +
"&sender=" + ozSender +
"&phone=" + ozRecipients +
"&text=" + ozMessageData +
"&priority=" + ozPriority +
"&stype=" + ozStype;
try
{
//Create the request and send data to the SMS Gateway Server by HTTP connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
//Get response from the SMS Gateway Server and read the answer
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
return true;
}
catch (Exception)
{
//if sending request or getting response is not successful the SMS Gateway Server may do not run
return false;
}
}
#endregion
}
private string GeneratePassword(int PasswordLength)
{
#region -- Generating The OTP Password --
string OTP = null;
try
{
// This OTP Code Created By Mr. Satyabrata Behera
string _allowedChars = "0123456789";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
catch (Exception Exc)
{
// lblErrorMsg.Text = "Application Error : " + Exc.Message;
return OTP;
}
#endregion
}
#endregion
#region MailIntegration
private void SendMail()
{
string Froms = "satyabrata@kencloud.co.in";
string Tos = TxtEmail.Text.Trim();
string UserName = string.Empty;
string url = string.Empty;
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Tos, TxtEmail.Text.Trim()));
msg.From = new MailAddress(Froms, "Satya");
msg.Subject = "Dolna Testing Mail Azure Web App Email using smtp.office365.com";
#region BodySetup
url = "http://kencommerce.azurewebsites.net/DolnaWebsite/Default.aspx";
//string body = "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
string body = "";
body += "Hi, " + TxtEmail.Text.Trim();
body += "<br /><br />Thank you, for Dolna Registration.";
// body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";
body += "<br /><br />To Complete Your Registration and verify your email please use the following link";
// body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
// body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";
body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
body += "<br /><br /> Best Wishes,";
body += "<br />SBackend Team";
body += "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
body += "<br />---------------------------------------------------------------------------";
body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
#endregion
msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "ss");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
// statusLabel.Text = "Message Sent Succesfully";
}
catch (Exception ex)
{
// statusLabel.Text = ex.ToString();
}
}
#endregion
{
var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
client.BaseAddress = new Uri(appsurl);
if (!IsPostBack)
{
lblshowmessage.Visible = false;
GetHeaderlogo();
GetMenuList();
#region Indexpage Username and Menu Show Page
if (Session["UserName"] != null)
{
afterlogin.InnerText = Session["UserName"].ToString();
fooItem.Visible = true;
LnkSignIn.Visible = false;
lnkRegister.Visible = false;
orshow.Visible = false;
BtnRegister.Enabled = false;
}
else
{
LnkSignIn.Visible = true;
lnkRegister.Visible = true;
fooItem.Visible = false;
}
#endregion
btnVerifay.Visible = true;
imgverify.Visible = false;
BtnRegister.Enabled = false;
}
}
#region Header and footerLogo
private List<Informal> Getinformal()
{
HttpResponseMessage hrm = client.GetAsync("api/AdminBrandingLogo").Result;
if (hrm.IsSuccessStatusCode)
{
informallist = hrm.Content.ReadAsAsync<List<Informal>>().Result;
return informallist.ToList();
}
else
{
return null;
}
}
private void GetHeaderlogo()
{
try
{
var lstfotlogo = (from m in Getinformal()
// where m.Informal_Title == "HeaderLogo"
select m).ToList();
if (lstfotlogo.ToList().Count > 0)
{
imgheader.Src = lstfotlogo.ToList()[0].Informal_Logo_Path.ToString();
footerimage.Src = lstfotlogo.ToList()[0].Informal_Logo_Path.ToString();
}
}
catch (Exception Ex)
{
}
}
#endregion
#region GetMenu & SubMenu Section
private void GetMenuList()
{
MenuText += "<ul class='megamenu skyblue'>";
if (GetTopMenu() != null)
{
topMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == null)).ToList();
if (topMenuList.Count > 0)
{
//Loop Top topMenuList
for (int i = 0; i < topMenuList.Count; i++)
{
MenuText += @"<li class='grid'><a class='color1' href='#'>" + topMenuList.ToList()[i].TopMenu_Text.ToString() + "</a>";
//Loop topChildMenuList Starts
if (GetTopMenu().ToList().OrderBy(a => a.TopMenu_Id).Where(a => (a.Parent_TopMenu_ID == topMenuList.ToList()[i].TopMenu_Id)).Count() > 0)
{
MenuText += "<div class='megapanel'><div class='row'>";
topChildMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == topMenuList.ToList()[i].TopMenu_Id)).ToList();
for (int j = 0; j < topChildMenuList.Count; j++)
{
if (i == 0)
{
if (j != 1) { MenuText += "<div class='col1'>"; }
}
else
{
MenuText += "<div class='col1'>";
}
MenuText += @"<div class='h_nav'>
<h4>" + topChildMenuList.ToList()[j].TopMenu_Text.ToString() + @"</h4>";
if (GetTopMenu().ToList().OrderBy(a => a.TopMenu_Id).Where(a => (a.Parent_TopMenu_ID == topChildMenuList.ToList()[j].TopMenu_Id)).Count() > 0)
{
topSubChildMenuList = GetTopMenu().ToList().OrderBy(a => a.TopMenu_DisplayOrder).Where(a => (a.IsActive == true) && (a.Parent_TopMenu_ID == topChildMenuList.ToList()[j].TopMenu_Id)).ToList();
MenuText += "<ul>";
for (int k = 0; k < topSubChildMenuList.Count; k++)
{
if (topSubChildMenuList.ToList()[k].Link_Page == null) { LinkPage = "#"; } else { LinkPage = topSubChildMenuList.ToList()[k].Link_Page.ToString().Trim(); }
if (topSubChildMenuList.ToList()[k].QueryString == null) { QueryString = ""; } else { QueryString = topSubChildMenuList.ToList()[k].QueryString.ToString().Trim(); }
MenuText += @"<li><a href='../" + LinkPage + "" + QueryString + "'>" + topSubChildMenuList.ToList()[k].TopMenu_Text.ToString() + "</a></li>";
}
MenuText += @"</ul> ";
}
MenuText += "</div>";
if (i == 0)
{
if (j != 0) { MenuText += "</div>"; }
}
else
{
MenuText += "</div>";
}
}
MenuText += @"</div>
</div>";
}
MenuText += "</li>";
}
}
MenuText += @"</ul>";
}
headerMenu.Text = MenuText;
}
private List<TopMenu> GetTopMenu()
{
HttpResponseMessage topMenu = client.GetAsync("api/TopMenu").Result;
if (topMenu.IsSuccessStatusCode)
{
MenuList = topMenu.Content.ReadAsAsync<List<TopMenu>>().Result;
return MenuList.ToList();
}
else
{
return null;
}
}
#endregion
#region Login and Register
protected void BtnRegister_Click(object sender, EventArgs e)
{
SendMail();
var email = TxtEmail.Text;
HttpResponseMessage Login_UserR = client.GetAsync("api/User").Result;
if (Login_UserR.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_UserR.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var data = (from a in GetMasterLoginUser
where a.Login_EmailId == email
select new
{
a.Login_User_ID,
}).ToList();
if (data.ToList().Count() > 0)
{
}
else
{
if (RadUserType.SelectedValue == "Customer")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Customer";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Response.Redirect("~/PublicWebsites/Default.aspx", false);
}
}
}
}
if (RadUserType.SelectedValue == "Artist")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Artist";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
// Response.Redirect("~/PublicWebsites/Default.aspx", false);
Response.Redirect("~/Supplier/Default.aspx");
}
}
}
}
if (RadUserType.SelectedValue == "Gallerist")
{
Master_Login_User lgn = new Master_Login_User();
lgn.Login_Username = TxtFullName.Text;
lgn.Login_User_Type = "Gallerist";
lgn.Login_EmailId = TxtEmail.Text;
lgn.Login_MobileNo = TxtMobileNo.Text;
lgn.Login_Password = TxtPassword.Text;
lgn.IsActive = true;
lgn.IsDelete = false;
lgn.InsertedOn = DateTime.Now;
HttpResponseMessage content = client.PostAsJsonAsync("api/User", lgn).Result;
if (content.IsSuccessStatusCode)
{
string LoginUID = content.Content.ReadAsStringAsync().Result;
Session["Loginuserid"] = LoginUID;
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
GetMasterLoginUser = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
var result = (from a in GetMasterLoginUser
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.Login_EmailId,
a.Login_Password,
a.Login_User_Type,
a.Login_Username,
a.Login_User_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Loginuserid"] = result.ToList()[0].Login_User_ID;
Session["UserName"] = result.ToList()[0].Login_Username;
Session["UserType"] = result.ToList()[0].Login_User_Type;
Session["UserMailId"] = result.ToList()[0].Login_EmailId;
Session["Status"] = "FirstTime";
// Response.Redirect("~/PublicWebsites/Default.aspx", false);
Response.Redirect("~/Supplier/Default.aspx");
}
}
}
}
}
}
}
#endregion
protected void btnSignin_Click(object sender, EventArgs e)
{
switch (GetUser())
{
case "Admin":
Response.Redirect("~/Admin/AdminPage.aspx");
break;
case "Supplier":
case "Gallerist":
case "Artist":
case "Seller":
#region....checking all details....
CheckDetails();
#endregion
Response.Redirect("~/Supplier/Default.aspx");
break;
case "Customer":
if (Convert.ToString(Request.QueryString["AucUser"]) == "1")
{
Response.Redirect("~/PublicWebsites/AuctionUserPage.aspx");
}
else if (Session["ADD TO CART"] == "ADD TO CART")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else if (Session["Add to Wishlist"] == "Add to Wishlist")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else if (Session["BUY NOW"] == "BUY NOW")
{
itemdetid = Convert.ToInt32(Session["itemDetID"]);
price = Convert.ToDecimal(Session["lblRuppess"]);
qty = Convert.ToInt32(Session["lblQty"]);
Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
}
else
{
Response.Redirect("~/PublicWebsites/Default.aspx");
}
//Response.Redirect("~/DolnaWebsite/Default.aspx");
break;
default:
// Response.Redirect("~/Login.aspx");
break;
}
}
private void CheckDetails()
{
#region...User Personal Information...
HttpResponseMessage Login_User = client.GetAsync("api/UserPersonalInformation").Result;
if (Login_User.IsSuccessStatusCode)
{
UserPersonalInformationList = Login_User.Content.ReadAsAsync<List<User_Personal_Information>>().Result;
var result = (from a in UserPersonalInformationList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Personal_Information_ID
}).ToList();
if (result.ToList().Count() > 0)
{
Session["Personal Information"] = "ok";
}
else
{
Session["Personal Information"] = "Not ok";
}
}
#endregion
#region...Bank Information...
HttpResponseMessage Login_Users = client.GetAsync("api/UserBankingInformation").Result;
if (Login_Users.IsSuccessStatusCode)
{
UserBankingInformationList = Login_Users.Content.ReadAsAsync<List<User_Banking_Information>>().Result;
var res = (from a in UserBankingInformationList
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Banking_Information_ID
}).ToList();
if (res.ToList().Count() > 0)
{
Session["Bank Details"] = "Ok";
}
else
{
Session["Bank Details"] = "Not Ok";
}
}
else
{
Session["Bank Details"] = "Not Ok";
}
#endregion
#region...Additional Information...
HttpResponseMessage Login_User1 = client.GetAsync("api/UserAdditionalInformation").Result;
if (Login_User1.IsSuccessStatusCode)
{
UserAdditionalInformationlist = Login_User1.Content.ReadAsAsync<List<User_Additional_Information>>().Result;
var data = (from a in UserAdditionalInformationlist
where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
select new
{
a.User_Additional_Information_ID
}).ToList();
if (data.ToList().Count() > 0)
{
Session["Additional Information"] = "OK";
}
else
{
Session["Additional Information"] = "Not OK";
}
}
else
{
Session["Additional Information"] = "Not OK";
}
#endregion
}
protected void btnVerifay_Click(object sender, EventArgs e)
{
string OTP = GeneratePassword(5);
string message = "One Time Password is " + OTP;
// TextBox txtmobile = (TextBox)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("txtmobile");
// Panel pnlotp = (Panel)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("pnlotp");
SendSMS.Mobile(TxtMobileNo.Text, message);
Session["OTP"] = OTP;
btnVerifay.Visible = false;
if (Session["OTP"] != "")
{
//imgverify.Visible = false;
pnlotp.Visible = true;
}
}
protected void btnimg_Click(object sender, EventArgs e)
{
string sessonOtp = Session["OTP"].ToString();
if (txtotp.Text == sessonOtp)
{
btnVerifay.Visible = false;
imgverify.Visible = true;
pnlotp.Visible = false;
BtnRegister.Enabled = true;
}
else
{
lblmsg.Text = "Enter a valid OTP";
}
}
#region Check User
private string GetUser()
{
if (TxtLogUsername.Text == "Saurendra" && TxtLogPassword.Text == "Admin@12345")
{
Session["Loginuserid"] = 0;
Session["UserName"] = "Super Admin";
Session["UserType"] = "Admin";
return "Admin";
}
HttpResponseMessage hrm = client.GetAsync("api/User").Result;
if (hrm.IsSuccessStatusCode)
{
userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == TxtLogUsername.Text && a.Login_Password == TxtLogPassword.Text && a.IsActive == true && a.IsDelete == false).ToList();
if (userList.Count > 0)
{
Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
Session["UserName"] = userList.ToList()[0].Login_Username.ToString();
Session["UserType"] = userList.ToList()[0].Login_User_Type.ToString();
Session["UserMailId"] = userList.ToList()[0].Login_EmailId.ToString();
//Session["Loged"] = "true";
return userList.ToList()[0].Login_User_Type.ToString();
}
else
{
userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == TxtLogUsername.Text && a.Login_Password == TxtLogPassword.Text && a.IsActive == false && a.IsDelete == false).ToList();
if (userList.Count > 0)
{
Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
Session["txtUsername"] = TxtLogUsername.Text;
Session["txtPassword"] = TxtLogPassword.Text;
// Response.Redirect("~/RegistationPage.aspx");
return string.Empty;
}
else
{
lblshowmessage.Visible = true;
// Response.Redirect("~/Login.aspx");
return string.Empty;
}
}
}
else
{
lblshowmessage.Visible = true;
return string.Empty;
}
}
private List<Master_Login_User> GetLogin_User()
{
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
userList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
return userList.ToList();
}
else
{
return null;
}
}
#endregion
#region Otp Method
public class SendSMS
{
#region -- Class For Sending SMS --
public static bool Mobile(string MobileNo, string Message)
{
//where the SMS Gateway is running
string ozSURL = "http://bhashsms.com/api/sendmsg.php";
//username for successful login
string ozUser = HttpUtility.UrlEncode("swash");
//user's password
string ozPassw = "Swash@2015";
//type of message
string ozSender = "swashc";
//who will get the message
string ozRecipients = HttpUtility.UrlEncode(MobileNo);
//body of message
string ozMessageData = HttpUtility.UrlEncode("One Time Password For Dolna Site Registration is : " + Message); //body of message
//priority of message
string ozPriority = "ndnd";
//type of message
string ozStype = "normal";
string createdURL = ozSURL +
"?user=" + ozUser +
"&pass=" + ozPassw +
"&sender=" + ozSender +
"&phone=" + ozRecipients +
"&text=" + ozMessageData +
"&priority=" + ozPriority +
"&stype=" + ozStype;
try
{
//Create the request and send data to the SMS Gateway Server by HTTP connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
//Get response from the SMS Gateway Server and read the answer
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
return true;
}
catch (Exception)
{
//if sending request or getting response is not successful the SMS Gateway Server may do not run
return false;
}
}
#endregion
}
private string GeneratePassword(int PasswordLength)
{
#region -- Generating The OTP Password --
string OTP = null;
try
{
// This OTP Code Created By Mr. Satyabrata Behera
string _allowedChars = "0123456789";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
catch (Exception Exc)
{
// lblErrorMsg.Text = "Application Error : " + Exc.Message;
return OTP;
}
#endregion
}
#endregion
#region MailIntegration
private void SendMail()
{
string Froms = "satyabrata@kencloud.co.in";
string Tos = TxtEmail.Text.Trim();
string UserName = string.Empty;
string url = string.Empty;
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Tos, TxtEmail.Text.Trim()));
msg.From = new MailAddress(Froms, "Satya");
msg.Subject = "Dolna Testing Mail Azure Web App Email using smtp.office365.com";
#region BodySetup
url = "http://kencommerce.azurewebsites.net/DolnaWebsite/Default.aspx";
//string body = "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
string body = "";
body += "Hi, " + TxtEmail.Text.Trim();
body += "<br /><br />Thank you, for Dolna Registration.";
// body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";
body += "<br /><br />To Complete Your Registration and verify your email please use the following link";
// body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
// body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";
body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
body += "<br /><br /> Best Wishes,";
body += "<br />SBackend Team";
body += "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
body += "<br />---------------------------------------------------------------------------";
body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
#endregion
msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "ss");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
// statusLabel.Text = "Message Sent Succesfully";
}
catch (Exception ex)
{
// statusLabel.Text = ex.ToString();
}
}
#endregion
Comments
Post a Comment