示例#1
0
 public async Task <IActionResult> Get(Guid id)
 {
     return(await Execute(async() =>
     {
         var result = await _draftRepository.Get(id);
         return _mapper.Map <NewsDto>(result);
     }));
 }
示例#2
0
        public async Task <IActionResult> Advanced(
            [FromQuery] string website,
            [FromQuery] string query,
            [FromQuery] IEnumerable <string> tags,
            [FromQuery] uint page,
            [FromQuery] uint count)
        {
            if (count > 0)
            {
                return(await Execute(async() =>
                {
                    var labels = (tags ?? Enumerable.Empty <string>()).ToArray();
                    var news = await _draftRepository.Get(website, query, labels, (int)page, (int)count);
                    var newsDtos = _mapper.Map <IEnumerable <NewsDto> >(news);

                    return new NewsResponseListDto
                    {
                        News = newsDtos,
                        Count = await _draftRepository.Count(website, query, labels)
                    };
                }));
            }

            return(BadRequest());
        }
示例#3
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);
            }
        }
示例#4
0
        public void Accept(string draftIdString)
        {
            var draftId = DraftId.From(draftIdString);
            var draft   = _draftRepository.Get(draftId);

            var agreement = draft.Accept();

            _agreementRepository.Save(agreement);
        }
示例#5
0
        public async Task Save(Comment comment)
        {
            comment.Content.CheckIfNull(nameof(comment.Content));

            _ = await _draftRepository.Get(comment.DraftId);

            if (comment.ReplyingTo.HasValue)
            {
                var parent = await _commentRepository.Get(comment.ReplyingTo.Value);

                _ = await _commentRepository.AddReply(parent.Id);
            }

            await _commentRepository.Save(comment);
        }