Exemplo n.º 1
0
        public ActionResult Addagentslot(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                tb_freeslot addinfreeS = new tb_freeslot();
                tb_agent    addslot    = new tb_agent();
                addinfreeS.agentinfree_name = collection["aname"].ToString();
                addinfreeS.Lat_infree       = collection["lat"];
                addinfreeS.Long_infree      = collection["long"];
                addinfreeS.sllotinfree_name = collection["sname"].ToString();
                //addslot.slot_name = collection["sname"];
                //db.tb_agent.Add(addslot);
                db.tb_freeslot.Add(addinfreeS);
                int j = db.SaveChanges();
                if (j > 0)
                {
                    ViewBag.s = "success";
                    return(View());
                }
                else
                {
                    ViewBag.s = "failed";
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Changepassword(FormCollection collection)
        {
            //tb_login lg = new tb_login();
            string user = Session["username"].ToString();
            string type = Session["type"].ToString();

            ViewBag.type = type;
            string   paswd = Session["password"].ToString();
            string   pass  = collection["oldpass"];
            tb_log   login = db.tb_log.Where(i => i.username == user && i.password == paswd).FirstOrDefault();
            tb_agent agent = db.tb_agent.Where(i => i.username == user && i.password == paswd).FirstOrDefault();

            if (login.password == pass && agent.password == pass)
            {
                login.password = collection["newpass"];
                agent.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 Agentreg(FormCollection collection)
        {
            Random   rand         = new Random();
            var      password     = rand.Next().ToString();
            var      getrandomkey = "AGN" + password.Substring(0, 5);
            tb_agent Addagent     = new tb_agent();

            Addagent.agent_name = collection["name"];
            Addagent.phone_no   = collection["phone"];
            Addagent.gmail      = collection["mail"];
            Addagent.username   = collection["username"];
            Addagent.password   = getrandomkey;
            if (db.tb_reg.Any(x => x.username == Addagent.username))
            {
                ViewBag.f = "Username Already Exist";
            }
            else
            {
                tb_log inse = new tb_log();
                inse.username = collection["username"];
                inse.password = getrandomkey;
                inse.usertype = "Agent";
                db.tb_agent.Add(Addagent);
                db.tb_log.Add(inse);
                db.SaveChanges();
                ViewBag.s = "success";
            }

            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: " + getrandomkey;
            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(View());
        }
Exemplo n.º 4
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.º 5
0
        public ActionResult Editprofile(FormCollection collection)
        {
            String   getusername = Session["username"].ToString();
            tb_agent tb          = db.tb_agent.Where(ob => ob.username == getusername).FirstOrDefault();

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

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

            return(View());
        }