Ejemplo n.º 1
0
        public List <ArticleInfoDto> GetLatestArticlesInfo(int?take)
        {
            var articlesDto = new List <ArticleInfoDto>();
            var query       = _context.Articles.Where(a => a.IsDeleted == false);

            if (take != null)
            {
                query = query.Take(take.Value);
            }

            var articles = query.ToList();

            foreach (var item in articles)
            {
                var articleInfo = new ArticleInfoDto();
                articleInfo.Id    = item.Id;
                articleInfo.Image = item.Image;
                if (_currentLang != (int)Language.Farsi)
                {
                    articleInfo.Title = item.EnglishTitle;
                    articleInfo.Date  = item.AddedDate.Value.ToString("d MMMM yyyy");
                }
                else
                {
                    articleInfo.Title = item.Title;
                    articleInfo.Date  = new PersianDateTime(item.AddedDate.Value).ToString("d MMMM yyyy");
                }
                articlesDto.Add(articleInfo);
            }

            return(articlesDto);
        }
Ejemplo n.º 2
0
        public async Task <ArticleInfoDto> GetArticleInfo(int userId)
        {
            var            userArticlesList = this._userArticleAccessor.GetUserArticles(userId);
            ArticleInfoDto articleInfoDto   = new ArticleInfoDto();

            articleInfoDto.noOfArticlesLiked  = userArticlesList.Count(a => a.IsLiked == true);
            articleInfoDto.noOfArticlesRead   = userArticlesList.Count(a => a.IsMarkedRead == true);
            articleInfoDto.noOfArticlesSaved  = userArticlesList.Count(a => a.IsSaved == true);
            articleInfoDto.noOfSubscribedTags = userArticlesList.Select(a => a.TagId).Distinct().Count();
            articleInfoDto.PolarChartTags     = this._mapper.Map <List <TagArticle>, List <PolarChartTags> >(this._userArticleAccessor.GetTopTags(userId));
            articleInfoDto.TrendingArticle    = this._mapper.Map <Article, ArticleDto> (this._userArticleAccessor.GetTrendingArticle(userId));
            return(articleInfoDto);
        }