public ActionResult Login(String email, String password) { using (var context = new DLMSDb()) { if (email == "*****@*****.**" && password == "dlms@123") { Session["adminemail"] = email; Session["adminname"] = "ADMIN"; Session["usertype"] = "admin"; return(RedirectToAction("Index", "Home")); } return(View()); } }
public ActionResult forgot(Dealer model) { using (var context = new DLMSDb()) { var a = context.Dealer.FirstOrDefault(x => x.email == model.email); if (a != null) { Random random = new Random(); int value = random.Next(10000); Session["otp"] = value; Session["forgotmail"] = model.email; // ViewBag["forgot"]= model.email; var senderEmail = new MailAddress("*****@*****.**", "DLMS"); var receiverEmail = new MailAddress(model.email, "Receiver"); var password = "******"; var sub = "Forgot Password"; var body = "Your OTP Is!! " + value; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(senderEmail.Address, password) }; using (var mess = new MailMessage(senderEmail, receiverEmail) { Subject = sub, Body = body }) { smtp.Send(mess); } return(RedirectToAction("forgotone", "Dealers")); // Response.Write("<script>alert('Main Sef')</script>"); } else { Response.Write("<script>alert('Email Not Found')</script>"); } } return(View()); }
public ActionResult Login(Lender model) { using (var context = new DLMSDb()) { bool isValid = context.Lender.Any(x => x.b_email == model.b_email && x.password == model.password); if (isValid) { Session["lenderemail"] = model.b_email; var e = Session["lenderemail"].ToString(); var firstname = context.Lender.FirstOrDefault(d => d.b_email == e); ViewBag.name = firstname.bankname; Session["lendername"] = firstname.bankname.ToString(); Session["lender_id"] = firstname.lender_id.ToString(); Session["usertype"] = "lender"; FormsAuthentication.SetAuthCookie(model.b_email, false); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Invalid username and password"); return(View()); } }