public string GetViewHtml(IContent content, Target target)
        {
            if (content == null || content.ContentId == Guid.Empty)
            {
                return(null);
            }

            var library = PublicApi.Libraries.Get(new LibraryGetOptions(content.ContentId));

            if (library == null || library.Id == Guid.Empty)
            {
                return(null);
            }

            var options = new RenderedSearchResultOptions
            {
                Target          = target,
                Title           = library.Name,
                Body            = library.Description,
                Url             = PublicApi.SharePointUrls.BrowseDocuments(library.Id),
                Date            = library.Created,
                ContainerName   = library.Container.HtmlName(target.ToString()),
                ContainerUrl    = library.Container.Url,
                ApplicationName = library.Name,
                ApplicationUrl  = PublicApi.SharePointUrls.BrowseDocuments(library.Id),
                TypeCssClass    = "sharepoint-library",
                User            = content.CreatedByUserId.HasValue ? TEApi.Users.Get(new UsersGetOptions {
                    Id = content.CreatedByUserId.Value
                }) : null,
            };

            return(content.ToRenderedSearchResult(options));
        }
        public string GetViewHtml(IContent content, Target target)
        {
            if (content == null || content.ContentId == Guid.Empty)
            {
                return(null);
            }

            var itemBase = listItemDataService.Get(content.ContentId);

            if (itemBase == null)
            {
                return(null);
            }

            var document = PublicApi.Documents.Get(itemBase.ApplicationId, new DocumentGetOptions(content.ContentId));

            if (document == null || document.HasErrors() || document.ContentId == Guid.Empty)
            {
                return(null);
            }

            var options = new RenderedSearchResultOptions
            {
                Target        = target,
                Title         = document.Title,
                Url           = PublicApi.SharePointUrls.Document(document.ContentId),
                Date          = document.CreatedDate,
                ContainerName = document.Library.Container != null?content.Application.Container.HtmlName(target.ToString()) : null,
                                    ContainerUrl    = document.Library.Container != null ? content.Application.Container.Url : null,
                                    ApplicationName = document.Library.Name,
                                    ApplicationUrl  = PublicApi.SharePointUrls.BrowseDocuments(document.Library.Id),
                                    TypeCssClass    = "sharepoint-document",
                                    User            = content.CreatedByUserId.HasValue ? TEApi.Users.Get(new UsersGetOptions
                {
                    Id = content.CreatedByUserId.Value
                }) : null,
                                    RemoteAttachments = new List <RenderedSearchResultAttachment>
                {
                    new RenderedSearchResultAttachment
                    {
                        FileName = document.Name,
                        Url      = document.DownloadUrl
                    }
                }
            };

            return(content.ToRenderedSearchResult(options));
        }
        public string GetViewHtml(IContent content, Target target)
        {
            if (content == null || content.ContentId == Guid.Empty)
            {
                return(null);
            }

            var contentId = content.ContentId;
            var listId    = EnsureListId(contentId);

            if (listId != Guid.Empty)
            {
                var listItem = PublicApi.ListItems.Get(listId, new SPListItemGetOptions(contentId));
                if (listItem != null)
                {
                    var options = new RenderedSearchResultOptions
                    {
                        Target        = target,
                        Title         = listItem.DisplayName,
                        Url           = PublicApi.SharePointUrls.ListItem(listItem.ContentId),
                        Date          = listItem.CreatedDate,
                        ContainerName = content.Application.Container != null?content.Application.Container.HtmlName(target.ToString()) : null,
                                            ContainerUrl    = content.Application.Container != null ? content.Application.Container.Url : null,
                                            ApplicationName = content.Application.HtmlName(target.ToString()),
                                            ApplicationUrl  = PublicApi.SharePointUrls.BrowseDocuments(listItem.ListId),
                                            TypeCssClass    = "sharepoint-listItem",
                                            User            = content.CreatedByUserId.HasValue ? TEApi.Users.Get(new UsersGetOptions {
                            Id = content.CreatedByUserId.Value
                        }) : null,
                                            RemoteAttachments = new List <RenderedSearchResultAttachment>(
                                                PublicApi.Attachments.List(listItem.ListId, new AttachmentsGetOptions(listItem.ContentId, "Attachments"))
                                                .Select(_ =>
                                                        new RenderedSearchResultAttachment
                        {
                            FileName = _.Name,
                            Url      = _.Uri.ToString()
                        }))
                    };

                    return(content.ToRenderedSearchResult(options));
                }
            }
            return(null);
        }