public Boolean AddUser(User user) { var email = user.Email; user.Passw = HashSalt.Hash_Salt(user.Passw); using (IDbConnection dbConnection = Connection) { string sQuery0 = "SELECT FirstName FROM Customer WHERE Email = @email"; dbConnection.Open(); string result = dbConnection.QueryFirstOrDefault <String>(sQuery0, new { @Email = email }); dbConnection.Close(); if (String.IsNullOrEmpty(result)) { string sQuery = "INSERT INTO Customer(FirstName,LastName,Passw,Email)" + "VALUES(@firstName,@lastName,@passw,@email)"; dbConnection.Open(); dbConnection.Execute(sQuery, user); return(true); } else { return(false); } } }
public Boolean UserLogin(Login login) { login.Password = HashSalt.Hash_Salt(login.Password); var o = login.Email; var i = login.Password; using (IDbConnection dbConnection = Connection) { string sQuery = "SELECT FirstName FROM Customer WHERE Email = @Email AND Passw = @Password"; dbConnection.Open(); detail = dbConnection.QueryFirstOrDefault <String>(sQuery, new{ @Email = o, @Password = i }); } if (String.IsNullOrEmpty(detail)) { return(false); } else { return(true); } }