Ejemplo n.º 1
0
        public int SignUp(string email, string password)
        {
            if (email.Trim().Equals(""))
            {
                return(0);
            }
            if (password.Trim().Equals(""))
            {
                return(1);
            }
            try
            {
                var user = db.Users.Add(new User()
                {
                    Email = email
                });
                db.SaveChanges();

                var acc = db.Accounts.Add(new Account()
                {
                    Email    = email,
                    Password = EncryptorMD5.Hash(password),
                    Status   = true,
                    UserID   = user.UserID
                });
                db.SaveChanges();
                return(2);
            }
            catch
            {
                return(3);
            }
        }
Ejemplo n.º 2
0
 public bool ChangePass(long accID, string newPass)
 {
     newPass = EncryptorMD5.Hash(newPass);
     try
     {
         var _acc = db.Accounts.Find(accID);
         _acc.Password = newPass;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public bool Login(string username, string password)
        {
            if (username == null || password == null)
            {
                return(false);
            }
            if (username.Trim().Equals("") || password.Trim().Equals(""))
            {
                return(false);
            }
            password = EncryptorMD5.Hash(password);
            var quantity = db.Accounts.Count(p => (p.UserName.Equals(username) || p.Email.Equals(username)) &&
                                             p.Password.Equals(password));

            return(quantity > 0);
        }