Hi,
you will need to inherit from the following WebParts and classes:
- inherit your repository from NoteRepository
- override the
GetNotes(Guid? languageId, Guid userId, Guid groupId, Guid wallOwnerId, int pageNumber, int pageSize, out int recordCount) method - you need to put your filter for friends here
- put code similar to this in your overridden
GetNotes method (
Note: this is only a sample code, this is not a fully functional code and you shouldn't expect this code to work as is!)
01.
EntityCollection<SnNoteEntity> notes =
new
EntityCollection<SnNoteEntity>();
02.
RelationPredicateBucket filter =
new
RelationPredicateBucket();
03.
filter.PredicateExpression.Add(SnNoteFields.NoteContent !=
string
.Empty);
04.
filter.PredicateExpression.Add(SnNoteFields.ApplicationId == MembershipRepository.GetInstance().GetApplicationId();
05.
if
(languageId.HasValue)
06.
filter.PredicateExpression.Add(SnNoteFields.LanguageId == languageId);
07.
08.
filter.PredicateExpression.Add(SnNoteFields.GroupId == DBNull.Value);
09.
10.
filter.Relations.Add(SnNoteEntity.Relations.AspnetUsersEntityUsingUserId);
11.
filter.PredicateExpression.Add(SnNoteFields.PostToUserId == wallOwnerId);
12.
//if this is the owner
13.
if
(wallOwnerId == SecurityUtility.GetUserId())
14.
{
15.
PredicateExpression peFriend = GetFriendPrivacyFilter();
16.
filter.PredicateExpression.Add(peFriend);
17.
}
18.
//if this is owner's friend, show everything except private notes
19.
else
if
(FriendRepository.GetInstance().RelationshipExists(userId, wallOwnerId))
20.
{
21.
PredicateExpression pe =
new
PredicateExpression();
22.
PredicateExpression pePrivate =
new
PredicateExpression();
23.
pePrivate.Add(SnNoteFields.PostToUserId == wallOwnerId);
24.
pePrivate.Add(SnNoteFields.UserId == userId);
25.
PredicateExpression peFriend = GetFriendPrivacyFilter();
26.
pe.Add(pePrivate);
27.
pe.AddWithOr(peFriend);
28.
filter.PredicateExpression.Add(pe);
29.
}
- inherit mark-up and the code from "
~\MonoX\ModuleGallery\SocialNetworking\WallNotes.ascx"
- in the code behind of your inherited class, you need to override
BindData()
- in the
BindData you need to put this code:
01.
int
recordCount = 0;
02.
03.
Guid userId = SecurityUtility.GetUserId();
04.
EntityCollection<SnNoteEntity> posts = YourRepositoryInstance.
05.
GetNotes(userId,
this
.GroupId,
this
.UserId, pager.CurrentPageIndex + 1, pager.PageSize,
out
recordCount);
06.
PagerUtility.BindPager(pager, BindData, lvItems, posts, recordCount);
07.
if
(recordCount == 0)
08.
lblNoData.Visible =
true
;
09.
else
10.
lblNoData.Visible =
false
;
- from now on you need to use your inherited WebPart in order to show the WallNotes with notes only from your friends
Regards