Exemplo n.º 1
0
        public ActionResult Register(FormCollection collection)
        {
            // TODO: Add insert logic here
            tb_reg ins = new tb_reg();

            ins.name            = collection["name"];
            ins.phone_no        = collection["phone"];
            ins.gmail           = collection["mail"];
            ins.username        = collection["username"];
            ins.password        = collection["password"];
            ins.confirmpassword = collection["confirmpassword"];
            //ins.usertype = collection["usertype"];
            ins.usertype = "User";
            if (db.tb_reg.Any(x => x.username == ins.username))
            {
                ViewBag.f = "Username Already Exist";
            }

            else
            {
                tb_log inse = new tb_log();
                inse.username = collection["username"];
                inse.password = collection["password"];
                inse.usertype = "User";
                db.tb_reg.Add(ins);
                db.tb_log.Add(inse);
                db.SaveChanges();

                MailMessage MyMailMessage = new MailMessage();
                MyMailMessage.From = new MailAddress("*****@*****.**");
                MyMailMessage.To.Add(collection["mail"]);
                MyMailMessage.Subject    = "Membership request";
                MyMailMessage.Body       = "Your request has been approved..Your username is : " + collection["username"] + "Your password is: " + collection["password"];
                MyMailMessage.IsBodyHtml = true;
                SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
                SMTPServer.Port        = 587;
                SMTPServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "!123456789");
                SMTPServer.EnableSsl   = true;
                try
                {
                    SMTPServer.Send(MyMailMessage);
                    //FormView1.DataBind();

                    //Literal1.Text = "Verification Code Sent to the mail ";
                    //Response.Redirect("Thankyou.aspx");
                }

                catch (Exception ex)
                {
                    //Literal1.Text = "Sorry! pls check the entered email ";
                }
                return(RedirectToAction("Login", "reg"));
            }


            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Changeforgotpassword(FormCollection collection)
        {
            string newpassword = collection["newpass"];
            string verify      = collection["verifypass"];
            string user        = Session["username"].ToString();
            string type        = Session["type"].ToString();
            tb_log login       = db.tb_log.Where(i => i.username == user && i.code == verify).FirstOrDefault();

            if (login.usertype == "User")
            {
                tb_reg userd = db.tb_reg.Where(i => i.username == user && i.usertype == type).FirstOrDefault();
                if (login.code == verify && userd.username == user)
                {
                    login.password = collection["newpass"];
                    userd.password = collection["newpass"];
                    int i = db.SaveChanges();
                    if (i > 0)
                    {
                        ViewBag.msg = "Password updated Successfully";
                    }
                    else
                    {
                        ViewBag.msg = "Something went wrong";
                    }
                }
                else
                {
                    ViewBag.msg = "Wrong Current password";
                }
            }
            else if (login.usertype == "Agent")
            {
                tb_agent agentc = db.tb_agent.Where(i => i.username == user).FirstOrDefault();
                if (login.code == verify && agentc.username == user)
                {
                    login.password  = collection["newpass"];
                    agentc.password = collection["newpass"];
                    int i = db.SaveChanges();
                    if (i > 0)
                    {
                        ViewBag.msg = "Password updated Successfully";
                    }
                    else
                    {
                        ViewBag.msg = "Something went wrong";
                    }
                }
                else
                {
                    ViewBag.msg = "Wrong Current password";
                }
            }
            return(View());
        }
Exemplo n.º 3
0
        public ActionResult Editprofile(FormCollection collection)
        {
            String getusername = Session["username"].ToString();
            tb_reg tb          = db.tb_reg.Where(ob => ob.username == getusername).FirstOrDefault();

            tb.name     = collection["name"];
            tb.phone_no = collection["phone"];
            tb.gmail    = collection["mail"];
            //db.tb_reg.Add(tb);
            int i = db.SaveChanges();

            if (i > 0)
            {
                Response.Write("<script>alert('Updated successfully')</script>");
                return(RedirectToAction("profile", "reg"));
            }
            else
            {
                Response.Write("<script>alert('Updation failed')</script>");
            }

            return(View());
        }