Esempio n. 1
0
        protected void Unnamed9_Click(object sender, EventArgs e)
        {
            if (txtEmailNew.Text != txtEmailNewRepeat.Text)
            {
                //LOS EMAILS NO COINCIDEN
                return;
            }

            if (!ValidEmail(txtEmailNew.Text))
            {
                //NO ES UN MAIL VALIDO
            }

            var user = (LOGIN)Session["USER"];

            if (user != null)
            {
                using (var db = new MonzonEntities())
                {
                    var dbUser = db.LOGIN.FirstOrDefault(l => l.UNIQUE_ID == user.UNIQUE_ID);
                    dbUser.EMAIL = txtEmailNew.Text;
                    db.LOGIN.Attach(dbUser);
                    db.Entry(dbUser).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
Esempio n. 2
0
        protected void Unnamed13_Click(object sender, EventArgs e)
        {
            var user = (LOGIN)Session["USER"];

            if (user != null)
            {
                using (var db = new MonzonEntities())
                {
                    var dbUser = db.LOGIN.FirstOrDefault(l => l.UNIQUE_ID == user.UNIQUE_ID);

                    if (txtPasswordNew.Text == dbUser.PASSWORD)
                    {
                        if (txtPasswordNew.Text != txtPasswordNewRepeat.Text)
                        {
                            //LAS PASSWORD NUEVAS NO COINCIDEN
                        }
                        else
                        {
                            dbUser.PASSWORD = txtPasswordNew.Text;
                            db.LOGIN.Attach(dbUser);
                            db.Entry(dbUser).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        //LA PASSWORD ANTIGUA NO ES CORRECTA
                    }
                }
            }
        }
Esempio n. 3
0
        protected void Unnamed5_Click(object sender, EventArgs e)
        {
            var user = (LOGIN)Session["USER"];

            if (user != null)
            {
                using (var db = new MonzonEntities())
                {
                    var dbUser = db.LOGIN.FirstOrDefault(l => l.UNIQUE_ID == user.UNIQUE_ID);
                    dbUser.FIRST_NAME = txtName.Text;
                    dbUser.LAST_NAME  = txtSurname.Text;
                    dbUser.PHONE      = txtPhone.Text;

                    db.LOGIN.Attach(dbUser);
                    db.Entry(dbUser).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
Esempio n. 4
0
        public bool PasswordRecovery(LOGIN login, string random)
        {
            using (var ts = new TransactionScope())
            {
                using (var db = new MonzonEntities())
                {
                    login.PASSWORD = random;
                    db.LOGIN.Attach(login);
                    db.SaveChanges();
                }

                MailMessage mail   = new MailMessage("*****@*****.**", login.EMAIL);
                SmtpClient  client = new SmtpClient {
                    Port = 25, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Host = "smtp.google.com"
                };
                mail.Subject = "this is a test email.";
                mail.Body    = "this is my test email body";
                client.Send(mail);

                ts.Complete();

                return(true);
            }
        }