public async Task <IActionResult> Get(Guid id) { return(await Execute(async() => { var result = await _draftRepository.Get(id); return _mapper.Map <NewsDto>(result); })); }
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()); }
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); } }
public void Accept(string draftIdString) { var draftId = DraftId.From(draftIdString); var draft = _draftRepository.Get(draftId); var agreement = draft.Accept(); _agreementRepository.Save(agreement); }
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); }