Пример #1
0
        public async Task <Article> GetBySlug(SlugQuery query)
        {
            var from = new DateTime(query.Year, query.Month, query.Day);
            var to   = from.AddDays(1);

            return(await db.Articles
                   .Find(item => item.CreatedAt >= from && item.CreatedAt < to && item.Slug == query.Slug)
                   .SortByDescending(a => a.CreatedAt)
                   .FirstOrDefaultAsync());
        }
Пример #2
0
        public async Task <ClientArticle> GetBySlug(SlugQuery query)
        {
            var article = await articleRepository.GetBySlug(query);

            if (article is null)
            {
                throw new ArgumentException("No article was found with these parameters.");
            }

            return(ConvertArticle(article));
        }