public async Task <EntryContent> CreateArticleEntry(Guid articleId, ArticleEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            var article = await _context.Find <Article>(articleId);

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

            return(await CreateNewEntryFor(article, entry));
        }
        public async Task <EntryMedia> CreateArticleEntryMedia(ArticleEntryMediaRequest entryMediaRequest)
        {
            if (entryMediaRequest == null)
            {
                throw new ArgumentNullException(nameof(entryMediaRequest));
            }

            var entryContent = await _context.Find <EntryContent>(entryMediaRequest.EntryId);

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

            return(await CreateNewEntryMediaFor(entryContent, entryMediaRequest));
        }
Пример #3
0
        public async Task <bool> TryUpdateArticle(Guid articleId, ArticleRequest updatedArticle)
        {
            if (updatedArticle == null)
            {
                throw new ArgumentNullException(nameof(updatedArticle));
            }

            var existingArticle = await _context.Find <Article>(articleId);

            if (existingArticle == null)
            {
                return(false);
            }

            UpdateValues(existingArticle, updatedArticle);

            await _context.SaveChanges();

            return(true);
        }
Пример #4
0
        public async Task <bool> TryDeleteArticle(Guid articleId)
        {
            var articleToDelete = await _context.Find <Article>(articleId);

            if (articleToDelete == null)
            {
                return(false);
            }

            if (articleToDelete.IsDeleted)
            {
                return(true);
            }

            articleToDelete.IsDeleted = true;
            articleToDelete.Deleted   = _clock.Now;

            await _context.SaveChanges();

            return(true);
        }
Пример #5
0
 private async Task <Blog> GetBlogForEntry(Guid newEntryBlogId) => await _context.Find <Blog>(newEntryBlogId);
Пример #6
0
 public async Task <Article> Find(Guid articleId)
 {
     return(await _context.Find <Article>(articleId));
 }