public async Task <ContentSearchResult> SearchContent(ContentSearchRequest contentsSearch) { if (contentsSearch.GetDepth() != ContentsSearchDepth.Item) { throw new UnsupportedFeatureException($"{contentsSearch.GetDepth()} not supported by Contentful provider"); } var entry = await _query.GetContentItem(new ContentItemReference { Id = contentsSearch.Id, Locale = contentsSearch.Language, }, contentsSearch.PublishingTarget); var contentType = _query.GetContentType(entry); return(ConvertToContentSearchResult(entry, contentType, ParsePublishingTarget(contentsSearch.PublishingTarget))); }
public ContentItemResult SearchItems(ContentSearchRequest search) { var item = _query.GetItem(search.Id, search.Language, search.PublishingTarget); if (item == null) { return(null); } switch (search.GetDepth()) { case ContentsSearchDepth.Item: return(_adapter.AdaptItem(item)); case ContentsSearchDepth.Children: return(_adapter.AdaptItemWithChildren(item, _query.GetItemChildren(item))); case ContentsSearchDepth.Descendants: return(_adapter.AdaptItemWithChildren(item, _query.GetItemDescendants(item))); default: throw new NotImplementedException($"{nameof(ContentsSearchDepth)} value {search.Depth} not implemented"); } }