示例#1
0
        public async Task SetSuggestions()
        {
            var allTags = await _draftRepository.GetTags();

            var highlightsByContent = await _contentRepository.GetHighlights(allTags);

            foreach (var highlights in highlightsByContent)
            {
                var contentId = Guid.Parse(highlights.Key);
                var tags      = await _draftRepository.GetTags(contentId);

                var draftSuggestions = GetTagSuggestion(contentId, highlights.Value, tags);

                if (draftSuggestions.Tags.Any())
                {
                    var entrySuggestions = await _draftRepository.Get(draftSuggestions.Tags);

                    try
                    {
                        var entryRelationship = await _draftRelationshipRepository.Get(contentId);

                        draftSuggestions.SetDraftSuggestions(entrySuggestions, entryRelationship);
                    }
                    catch (NotFoundException)
                    {
                        draftSuggestions.SetDraftSuggestions(entrySuggestions, null);
                    }
                }

                await _draftSuggestionsRepository.Save(draftSuggestions);
            }
        }
示例#2
0
 public async Task <IActionResult> Get()
 {
     return(await Execute(async() => await _draftRepository.GetTags()));
 }