private IntranetActivityPreviewModelBase GetBaseModel(IFeedItem feedItem, bool isGroupFeed) { if (feedItem is IntranetActivity activity) { var baseModel = new IntranetActivityPreviewModelBase { Id = feedItem.Id, Links = _linkService.GetLinks(feedItem.Id), Type = _localizationService.Translate(activity.Type.ToString()), CommentsCount = _commentsService.GetCount(feedItem.Id), Likes = _likesService.GetLikeModels(activity.Id), GroupInfo = isGroupFeed ? null : _feedActivityHelper.GetGroupInfo(feedItem.Id), ActivityType = feedItem.Type, }; if (feedItem is Social social) { baseModel.LinkPreviewId = social.LinkPreviewId; baseModel.LinkPreview = social.LinkPreview; } _lightboxHelper.FillGalleryPreview(baseModel, activity.MediaIds); return(baseModel); } _logger.Warn <FeedPresentationService>("Feed item is not IntranetActivity (id={0};type={1})", feedItem.Id, feedItem.Type.ToInt()); return(null); }
public virtual CommentViewModel GetCommentView(CommentModel comment, Guid currentMemberId, IIntranetMember creator) { var likes = _likesService.GetLikeModels(comment.Id).ToArray(); var memberId = _intranetMemberService.GetCurrentMemberId(); var model = comment.Map <CommentViewModel>(); model.ModifyDate = _commentsService.WasChanged(comment) ? comment.ModifyDate.ToDateTimeFormat() : null; model.CanEdit = _commentsService.CanEdit(comment, currentMemberId); model.CanDelete = _commentsService.CanDelete(comment, currentMemberId); model.Creator = creator.ToViewModel(); model.ElementOverviewId = GetOverviewElementId(comment.ActivityId); model.CommentViewId = _commentsService.GetCommentViewId(comment.Id); model.CreatorProfileUrl = creator == null ? null : _profileLinkProvider.GetProfileLink(creator); model.LinkPreview = comment.LinkPreview.Map <LinkPreviewModel>(); model.LikedByCurrentUser = likes.Any(el => el.UserId == memberId); model.Likes = likes; model.LikeModel = GetLikesViewModel(comment.Id, memberId, likes); return(model); }
public override ConverterResponseModel MapViewModel(LikesPanelModel node, LikesPanelViewModel viewModel) { var activityId = _context.ParseQueryString("id").TryParseGuid(); var activityType = activityId.HasValue ? _activityTypeHelper.GetActivityType(activityId.Value) : IntranetActivityTypeEnum.ContentPage; var id = activityType.Equals(IntranetActivityTypeEnum.ContentPage) ? _requestContext.Node?.Key : activityId; if (!id.HasValue) { return(NotFoundResult()); } var groupId = _groupActivityService.GetGroupId(id.Value); var currentMember = _intranetMemberService.GetCurrentMember(); viewModel.IsGroupMember = !groupId.HasValue || currentMember.GroupIds.Contains(groupId.Value); if (!viewModel.IsGroupMember) { return(ForbiddenResult()); } var likes = _likesService.GetLikeModels(id.Value).ToArray(); viewModel.Likes = likes; viewModel.EntityId = id.Value; viewModel.LikedByCurrentUser = likes.Any(el => el.UserId == currentMember.Id); viewModel.ActivityType = activityType; return(OkResult()); }
public virtual PartialViewResult ContentLikes() { var guid = CurrentPage.GetKey(); return(Likes(_likesService.GetLikeModels(guid), guid, showTitle: true)); }