@@ -93,16 +93,20 @@ private static void MatchOrLikeNotification(object matchOrLike)
9393 List < Profile > profileList ;
9494
9595 // Prepares data depending on the match or like handling
96- if ( ( MatchOrLike ) matchOrLike == MatchOrLike . Matched )
96+ if ( ( MatchOrLike ) matchOrLike == MatchOrLike . Matched && Account . UserID != null )
9797 {
9898 current = new HashSet < int > ( MatchDataAccess . GetAllMatchesFromUser ( Account . UserID . Value , MatchOrLike . Matched ) ) ;
9999 profileList = ViewModelMediators . Matches ;
100100 }
101- else
101+ else if ( ( MatchOrLike ) matchOrLike == MatchOrLike . Liked && Account . UserID != null )
102102 {
103103 current = new HashSet < int > ( MatchDataAccess . GetReceivedLikesFromUser ( Account . UserID . Value ) ) ;
104104 profileList = ViewModelMediators . Likes ;
105105 }
106+ else
107+ {
108+ throw new Exception ( "Match or like notification MatchOrLike enum not set correctly" ) ;
109+ }
106110
107111 // Add the user ID's to the HashSet
108112 foreach ( Profile p in profileList )
@@ -120,15 +124,21 @@ private static void MatchOrLikeNotification(object matchOrLike)
120124 // ...reload the profiles
121125 if ( ( MatchOrLike ) matchOrLike == MatchOrLike . Matched )
122126 {
123- ViewModelMediators . Matches = MatchHelper . LoadProfilesOfMatches ( Account . UserID . Value ) ;
127+ if ( Account . UserID != null )
128+ {
129+ ViewModelMediators . Matches = MatchHelper . LoadProfilesOfMatches ( Account . UserID . Value ) ;
130+ }
124131 if ( Account . NotificationSettings != null )
125132 {
126133 notificationsOn = Account . NotificationSettings . Matches ;
127134 }
128135 }
129136 else
130137 {
131- ViewModelMediators . Likes = MatchHelper . LoadProfilesOfLikes ( Account . UserID . Value ) ;
138+ if ( Account . UserID != null )
139+ {
140+ ViewModelMediators . Likes = MatchHelper . LoadProfilesOfLikes ( Account . UserID . Value ) ;
141+ }
132142 if ( Account . NotificationSettings != null )
133143 {
134144 notificationsOn = Account . NotificationSettings . Likes ;
0 commit comments