Ejemplo n.º 1
0
        protected override void Then(Article model, ArticleViewModel viewModel)
        {
            base.Then(model, viewModel);
            var articles = _articlesService.GetAllArticles();

            viewModel.ArticleImageUrl = model.PublishedContent.HasValue("articleImage")?
                                        model.PublishedContent.GetCropUrl("articleImage", "smallImage") : "http://lorempixel.com/370/240/";
            viewModel.ArticleImageWide = model.PublishedContent.HasValue("articleImage")?
                                         model.PublishedContent.GetCropUrl("articleImage", "wideImage"):"http://lorempixel.com/770/240/";
            var articlesContent = articles as IList <IPublishedContent> ?? articles.ToList();

            if (articlesContent.Any())
            {
                articlesContent.OrderBy(x => Guid.NewGuid()).Take(15).ForEach(
                    x =>
                    viewModel.SideNav.Add(new SideNav
                {
                    Id        = x.Id,
                    Name      = x.Name,
                    Url       = x.Url,
                    Level     = x.Level,
                    SortOrder = x.SortOrder
                }));
            }
        }
        protected override void Then(ArticlesCategory model, ArticlesCategoryViewModel viewModel)
        {
            base.Then(model, viewModel);
            var articles = _articlesService.GetAllArticles();

            var publishedContents = articles as IList <IPublishedContent> ?? articles.ToList();

            if (publishedContents.Any())
            {
                publishedContents.ForEach(
                    x =>
                    viewModel.Articles.Add(
                        _mapperProvider.GetViewModelMapper <Article, ArticleViewModel>().Map(_contentMapper.Map(x))));
            }
        }