public string GenerateUserToken(int userid, int businessid) { string tokenString = ce.GenerateRandomeStrings(20); string returnToken = ""; using (SqlConnection conn = connect.getConnection()) { using (SqlCommand cmd = new SqlCommand("GenerateToken", conn))//call Stored Procedure { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@token", tokenString); cmd.Parameters.AddWithValue("@userId", userid); cmd.Parameters.AddWithValue("@businessId", businessid); cmd.Parameters.Add("@returnvalue", System.Data.SqlDbType.Int); cmd.Parameters["@returnvalue"].Direction = ParameterDirection.Output; try { cmd.ExecuteNonQuery(); if (Convert.ToInt32(cmd.Parameters["@returnvalue"].Value) == 1) { returnToken = tokenString;// ce.Encrypt(tokenString, CommonUtilityClass.apiEncryptKey); } } catch (Exception ex) { CommonUtilityClass.ExceptionLog(ex); } } } return(returnToken); }