Exemplo n.º 1
0
 //6. gives Rating for common friends with a stranger
 public static List<Ratedmember> checkCommonFriendsWithStranger(List<Ratedmember> ratedMembers, Int64 mitgliedID, List<Nullable<long>> myFriends)
 {
     int ratingUP = 3;
     using (DBEntities dbConnection = new DBEntities())
     {
         Mitglied currentMitglied = dbConnection.Mitglied.Find(mitgliedID);
         foreach (Ratedmember currentRated in ratedMembers)
         {
             //List<Mitglied> stangersFriends = Friendsuggestor.getMyFriends(currentRated.mitgliedData.mitgliedID);
             ObjectResult<Nullable<long>> strangersFriends = dbConnection.getMyFriendsSP(currentRated.mitgliedData.mitgliedID);
             foreach (Int64 currentStrangersFriend in strangersFriends)
             {
                 bool foundCommonFriend = false;
                 foreach (long currentUsersFriend in myFriends)
                 {
                     if (currentUsersFriend.Equals(currentStrangersFriend))
                     {
                         foundCommonFriend = true;
                     }
                     else
                     {
                     }
                 }
                 if (foundCommonFriend == true)
                 {
                     ratedMembers.Find(x => x.Equals(currentRated)).incrementRating(ratingUP);
                 }
                 else { }
             }
         }
     }
     return ratedMembers;
 }
Exemplo n.º 2
0
 //1. returns a Mitglieder List with all Friends of a member
 //public static List<Mitglied> getMyFriends(Int64 mitgliedID)
 //{
 //    using (DBEntities dbConnection = new DBEntities())
 //    {
 //        List<Mitglied> allMitglieder = dbConnection.Mitglied.ToList();
 //        List<Freundschaft> myFriendships = Datareader.getMyFriends(mitgliedID);
 //        List<Mitglied> myFriends = new List<Mitglied>();
 //        foreach (Freundschaft currentFriendship in myFriendships)
 //        {
 //            if(currentFriendship.mitgliedIDA.Equals(mitgliedID))
 //            {
 //                myFriends.Add(dbConnection.Mitglied.Find(currentFriendship.mitgliedIDB));
 //            }
 //            else if (currentFriendship.mitgliedIDB.Equals(mitgliedID))
 //            {
 //                myFriends.Add(dbConnection.Mitglied.Find(currentFriendship.mitgliedIDA));
 //            }
 //        }
 //        return myFriends;
 //    }
 //}
 //returns the friends of a specific user
 public static List<Nullable<long>> getMyFriends(Int64 mitgliedID)
 {
     using (DBEntities dbConnection = new DBEntities())
     {
         //getMyFriendsSP is a StoredProcedure mapped by the entity framework
         ObjectResult<Nullable<long>> x = dbConnection.getMyFriendsSP(mitgliedID);
         List<Nullable<Int64>> y = (from a in x select a).ToList();
         y.Add(mitgliedID);
         return y;
     }
 }