public List <UserOBJ> FindUsersByLocation(string city, string state) { List <UserOBJ> Users = new List <UserOBJ>(); DBConnect objDB = new DBConnect(); SqlCommand FindUsersbyLocation = new SqlCommand(); FindUsersbyLocation.CommandType = CommandType.StoredProcedure; FindUsersbyLocation.CommandText = "TP_FindUsersByLocation"; FindUsersbyLocation.Parameters.AddWithValue("@city", city); FindUsersbyLocation.Parameters.AddWithValue("@state", state); DataSet ds = objDB.GetDataSetUsingCmdObj(FindUsersbyLocation); foreach (DataRow record in ds.Tables[0].Rows) { UserOBJ thisUser = new UserOBJ(); thisUser.First = record["First_Name"].ToString(); thisUser.Last = record["Last_Name"].ToString(); thisUser.Email = record["Email"].ToString(); thisUser.City = record["City"].ToString(); thisUser.State = record["State"].ToString(); thisUser.Organization = record["Organization"].ToString(); thisUser.ProfileURL = record["ProfilePhotoURL"].ToString(); Users.Add(thisUser); } return(Users); }
public List <UserOBJ> GetFriends(String requestingEmail, String requestedEmail, String token) { DBConnect objDB = new DBConnect(); List <UserOBJ> Users = new List <UserOBJ>(); SqlCommand LoginUser = new SqlCommand(); LoginUser.CommandType = CommandType.StoredProcedure; LoginUser.CommandText = "TP_FindUser"; LoginUser.Parameters.AddWithValue("@Email", requestingEmail); LoginUser.Parameters.AddWithValue("@Password", decode(token)); SqlParameter outputPar = new SqlParameter("@Out", SqlDbType.Int, 50); outputPar.Direction = ParameterDirection.Output; LoginUser.Parameters.Add(outputPar); objDB.GetDataSetUsingCmdObj(LoginUser); //check token to see if user is logged in with same Email and pass string a = LoginUser.Parameters["@Out"].Value.ToString(); if (a.Equals("1")) { SqlCommand GetFriends = new SqlCommand(); GetFriends.CommandType = CommandType.StoredProcedure; GetFriends.CommandText = "TP_GetFriends"; GetFriends.Parameters.AddWithValue("@Email", requestedEmail); DataSet ds = objDB.GetDataSetUsingCmdObj(GetFriends); SqlCommand FindUsers = new SqlCommand(); FindUsers.CommandType = CommandType.StoredProcedure; FindUsers.CommandText = "TP_FindUserByEmail"; foreach (DataRow record in ds.Tables[0].Rows) { FindUsers.Parameters.Clear(); FindUsers.Parameters.AddWithValue("@Email", record["Person2"].ToString()); DataSet Friend = objDB.GetDataSetUsingCmdObj(FindUsers); foreach (DataRow UserInfo in Friend.Tables[0].Rows) { UserOBJ thisUser = new UserOBJ(); thisUser.First = UserInfo["First_Name"].ToString(); thisUser.Last = UserInfo["Last_Name"].ToString(); thisUser.Email = UserInfo["Email"].ToString(); thisUser.City = UserInfo["City"].ToString(); thisUser.State = UserInfo["State"].ToString(); thisUser.Organization = UserInfo["Organization"].ToString(); thisUser.ProfileURL = UserInfo["ProfilePhotoURL"].ToString(); Users.Add(thisUser); } } return(Users); } else { return(Users); } }
public List <UserOBJ> FindUsersByName(string name) { List <UserOBJ> Users = new List <UserOBJ>(); DBConnect objDB = new DBConnect(); SqlCommand FindUsersByName = new SqlCommand(); FindUsersByName.CommandType = CommandType.StoredProcedure; FindUsersByName.CommandText = "TP_FindUsersByName"; string[] words = name.Split(' '); if (words.Length == 0) { } if (words.Length == 1) { FindUsersByName.Parameters.AddWithValue("@first", words[0]); FindUsersByName.Parameters.AddWithValue("@last", ""); } if (words.Length == 2) { FindUsersByName.Parameters.AddWithValue("@first", words[0]); FindUsersByName.Parameters.AddWithValue("@last", words[1]); } DataSet ds = objDB.GetDataSetUsingCmdObj(FindUsersByName); foreach (DataRow record in ds.Tables[0].Rows) { UserOBJ thisUser = new UserOBJ(); thisUser.First = record["First_Name"].ToString(); thisUser.Last = record["Last_Name"].ToString(); thisUser.Email = record["Email"].ToString(); thisUser.City = record["City"].ToString(); thisUser.State = record["State"].ToString(); thisUser.Organization = record["Organization"].ToString(); thisUser.ProfileURL = record["ProfilePhotoURL"].ToString(); Users.Add(thisUser); } return(Users); }
public UserOBJ GetProfile(String requestingEmail, String requestedEmail, String token) { DBConnect objDB = new DBConnect(); UserOBJ thisUser = new UserOBJ(); SqlCommand LoginUser = new SqlCommand(); LoginUser.CommandType = CommandType.StoredProcedure; LoginUser.CommandText = "TP_FindUser"; LoginUser.Parameters.AddWithValue("@Email", requestingEmail); LoginUser.Parameters.AddWithValue("@Password", decode(token)); SqlParameter outputPar = new SqlParameter("@Out", SqlDbType.Int, 50); outputPar.Direction = ParameterDirection.Output; LoginUser.Parameters.Add(outputPar); objDB.GetDataSetUsingCmdObj(LoginUser); //check token to see if user is logged in with same Email and pass string a = LoginUser.Parameters["@Out"].Value.ToString(); if (a.Equals("1")) { SqlCommand FindSettings = new SqlCommand(); FindSettings.CommandType = CommandType.StoredProcedure; FindSettings.CommandText = "TP_FindUserSettings"; FindSettings.Parameters.AddWithValue("@Email", requestedEmail); DataSet Settings = objDB.GetDataSetUsingCmdObj(FindSettings); SettingsOBJ mySettings = new SettingsOBJ(); foreach (DataRow UserSetting in Settings.Tables[0].Rows) { mySettings.Login = UserSetting["LoginSetting"].ToString(); mySettings.Personal = UserSetting["PersonalContactSetting"].ToString(); mySettings.Photos = UserSetting["PhotoSetting"].ToString(); mySettings.Profile = UserSetting["ProfileInfoSetting"].ToString(); } SqlCommand FindUsers = new SqlCommand(); FindUsers.CommandType = CommandType.StoredProcedure; FindUsers.CommandText = "TP_FindUserByEmail"; FindUsers.Parameters.Clear(); FindUsers.Parameters.AddWithValue("@Email", requestedEmail); DataSet Friend = objDB.GetDataSetUsingCmdObj(FindUsers); if (requestingEmail != requestedEmail) { SqlCommand CheckFriends = new SqlCommand(); CheckFriends.CommandType = CommandType.StoredProcedure; CheckFriends.CommandText = "TP_ChecksFriendship"; CheckFriends.Parameters.AddWithValue("@Email1", requestingEmail); CheckFriends.Parameters.AddWithValue("@Email2", requestedEmail); SqlParameter outputPar1 = new SqlParameter("@found", SqlDbType.Int, 50); outputPar1.Direction = ParameterDirection.Output; CheckFriends.Parameters.Add(outputPar1); objDB.GetDataSetUsingCmdObj(CheckFriends).ToString(); string Friends = CheckFriends.Parameters["@found"].Value.ToString(); //SqlCommand CheckFriendsofFriends = new SqlCommand(); //CheckFriendsofFriends.CommandType = CommandType.StoredProcedure; //CheckFriendsofFriends.CommandText = "TP_ChecksFriendship"; //CheckFriendsofFriends.Parameters.AddWithValue("@Email1", requestingEmail); //CheckFriendsofFriends.Parameters.AddWithValue("@Email2", requestedEmail); //string FriendsofFriends = objDB.GetDataSetUsingCmdObj(CheckFriendsofFriends).ToString(); switch (mySettings.Profile) { case "Public": foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = UserInfo["First_Name"].ToString(); thisUser.Last = UserInfo["Last_Name"].ToString(); thisUser.Email = UserInfo["Email"].ToString(); if (mySettings.Personal == "Public") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else if (mySettings.Personal == "Only Friends") { if (Friends == "1") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else { thisUser.Phone = "Only Friends can view this info"; } } thisUser.City = UserInfo["City"].ToString(); thisUser.State = UserInfo["State"].ToString(); thisUser.Organization = UserInfo["Organization"].ToString(); thisUser.ProfileURL = UserInfo["ProfilePhotoURL"].ToString(); return(thisUser); } break; case "Only Friends": if (Friends == "1") { foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = UserInfo["First_Name"].ToString(); thisUser.Email = UserInfo["Email"].ToString(); thisUser.Last = UserInfo["Last_Name"].ToString(); if (mySettings.Personal == "Public") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else if (mySettings.Personal == "Only Friends") { if (Friends == "1") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else { thisUser.Phone = "Only Friends can view this info"; } } thisUser.City = UserInfo["City"].ToString(); thisUser.State = UserInfo["State"].ToString(); thisUser.Organization = UserInfo["Organization"].ToString(); thisUser.ProfileURL = UserInfo["ProfilePhotoURL"].ToString(); return(thisUser); } } else { foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = ""; thisUser.Last = ""; thisUser.Email = ""; thisUser.City = ""; thisUser.Phone = ""; thisUser.State = ""; thisUser.Organization = ""; thisUser.ProfileURL = ""; return(thisUser); } } break; case "Friends and Friends of Friends": if (Friends == "1") { foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = UserInfo["First_Name"].ToString(); thisUser.Last = UserInfo["Last_Name"].ToString(); thisUser.Email = UserInfo["Email"].ToString(); thisUser.City = UserInfo["City"].ToString(); if (mySettings.Personal == "Public") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else if (mySettings.Personal == "Only Friends") { if (Friends == "1") { thisUser.Phone = UserInfo["Phone#"].ToString(); } else { thisUser.Phone = "Only Friends can view this info"; } } thisUser.State = UserInfo["State"].ToString(); thisUser.Organization = UserInfo["Organization"].ToString(); thisUser.ProfileURL = UserInfo["ProfilePhotoURL"].ToString(); return(thisUser); } } else { foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = ""; thisUser.Last = ""; thisUser.Email = ""; thisUser.City = ""; thisUser.Phone = ""; thisUser.State = ""; thisUser.Organization = ""; thisUser.ProfileURL = ""; return(thisUser); } } break; } } else { foreach (DataRow UserInfo in Friend.Tables[0].Rows) { thisUser = new UserOBJ(); thisUser.First = UserInfo["First_Name"].ToString(); thisUser.Last = UserInfo["Last_Name"].ToString(); thisUser.Email = UserInfo["Email"].ToString(); thisUser.City = UserInfo["City"].ToString(); thisUser.Phone = UserInfo["Phone#"].ToString(); thisUser.State = UserInfo["State"].ToString(); thisUser.Organization = UserInfo["Organization"].ToString(); thisUser.ProfileURL = UserInfo["ProfilePhotoURL"].ToString(); return(thisUser); } } } return(thisUser); }