public string CheckForFriend(string username) { var profileService = new ProfileServices(_userId); using (var ctx = new ApplicationDbContext()) { var myProfile = profileService.GetProfile(); var otherProfile = profileService.GetByUsername(username); try { foreach (var friendRequest in myProfile.FriendRequests) { if (friendRequest.Reciever == otherProfile.FullName) { return("pending"); } if (friendRequest.Sender == otherProfile.FullName) { return("theySent"); } } } catch { } foreach (var friend in myProfile.FriendsList) { if (friend.FriendsUsername == username) { return("friends"); } } return("not friends"); } }
public List <ProfileDetail> GetFriendsList() { var profileService = new ProfileServices(_userId); var foundFriends = new List <ProfileDetail>(); using (var ctx = new ApplicationDbContext()) { var userProfile = profileService.GetProfile(); foreach (var friend in userProfile.FriendsList) { var friendsProfile = profileService.GetByUsername(friend.FriendsUsername); var friendInList = new ProfileDetail { FullName = friendsProfile.FullName, Username = friendsProfile.Username, FirstName = friendsProfile.FirstName, LastName = friendsProfile.LastName, City = friendsProfile.City, State = friendsProfile.State, ZipCode = friendsProfile.ZipCode, }; foundFriends.Add(friendInList); } } return(foundFriends); }
public bool CheckForFollow(int id) { var profileService = new ProfileServices(_userId); using (var ctx = new ApplicationDbContext()) { var myProfile = profileService.GetProfile(); foreach (var friend in myProfile.FriendsList) { if (friend.BusinessID == id) { return(true); } } return(false); } }