public static int GetUserIdByUsernameAndHashedSaltedPassword(string userName, string password) { // the default customer ID is 1 //int customerId = 1; PetBoxEntities1 dbForHashCodeCheck = new PetBoxEntities1(); Customer userNameQuery = (from o in dbForHashCodeCheck.Customers where o.CustomerLoginName == userName select o).SingleOrDefault(); if (userNameQuery == null) { return(1); } string toBeTestedPassword = PasswordSecurity.HashSHA1(password + userNameQuery.CustomerGuid); if (toBeTestedPassword == userNameQuery.CustomerPassword) { return(userNameQuery.CustomerID); } return(1); }