public Blogic()
        {
            var app = Application.Current as App;

            articleController = app.articleController;

            InitializeComponent();
            if (ArticlesList != null)
            {
                ArticlesList.ItemsSource = new List <ArticleShow>();
                articlesToShow           = new List <ArticleShow>();
                foreach (Article art in articleController.GetAllArticles())
                {
                    articlesToShow.Add(new ArticleShow()
                    {
                        article = new ModelHCI.ArticleHCI()
                        {
                            article = art, content = art.PostContent.Content, title = art.PostContent.ContentTitle, articlePic = new BitmapImage(new Uri(art.Image, UriKind.Relative))
                        },
                        buttonContent = "Prikaži ceo",
                        info          = new ButtonTagInfo()
                        {
                            article = new ModelHCI.ArticleHCI()
                            {
                                article = art, content = art.PostContent.Content, title = art.PostContent.ContentTitle, articlePic = new BitmapImage(new Uri(art.Image, UriKind.RelativeOrAbsolute))
                            }
                        }
                    });
                    pageCount = articlesToShow.Count;
                    ArticlesList.ItemsSource = articlesToShow;
                }
                //Pagination();
            }
        }
Exemplo n.º 2
0
        public void TestGetAllArticles()
        {
            List <Article> articles = new List <Article>();

            articles.Add(article);
            IEnumerable <Article> _iEnumerableArticle = articles;

            mockArticleService.Setup(x => x.GetAllArticles(It.IsAny <PostFilter>(), It.IsAny <int>())).Returns(_iEnumerableArticle);
            var           _articleController = new ArticleController(mockArticleService.Object, mockPostService.Object);
            IActionResult getAllArticles     = _articleController.GetAllArticles(postFilter, 4);
            var           type = getAllArticles.GetType();

            Assert.AreEqual(type.Name, "OkObjectResult");
        }
Exemplo n.º 3
0
        public async Task Should_Return_All_Articles()
        {
            // Arrange
            _articleServices.Setup(x => x.GetAllArticles())
            .ReturnsAsync(MockArticleResults());

            //Act
            var result = await _sut.GetAllArticles() as OkObjectResult;

            //Assert
            _articleServices.Verify(x => x.GetAllArticles(), Times.Once);
            Assert.IsNotNull(result);
            result.Value.Should().BeOfType <List <Article> >().Which.Count.Should().Be(2);
            result.Should().BeOfType <OkObjectResult>().Which.StatusCode.Should().Be(200);
        }
Exemplo n.º 4
0
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            var listOfUrls = new List <SitemapUrl>();

            foreach (Article ai in ArticleController.GetAllArticles(portalId))
            {
                var pageUrl = new SitemapUrl
                {
                    Url =
                        ArticleController.GetArticleLink(ai.TabID, ai.ArticleId),
                    Priority        = (float)0.5,
                    LastModified    = ai.LastModifiedOnDate,
                    ChangeFrequency = SitemapChangeFrequency.Daily
                };
                listOfUrls.Add(pageUrl);
            }
            return(listOfUrls);
        }
Exemplo n.º 5
0
        //[DnnAuthorize(AllowAnonymous = true)]

        public HttpResponseMessage GetAllArticles(int portalId, bool sortAsc)
        {
            try
            {
                //todo: get the latest X articles?
                var articles = ArticleController.GetAllArticles(portalId, sortAsc);

                //because of the circular reference when cerealizing the taxonomy within content items we have to build out our article view models manually.
                var cleanArticles = new List <ArticleViewModel>();
                foreach (Article a in articles)
                {
                    var newArt = new ArticleViewModel
                    {
                        ArticleId            = a.ArticleId,
                        Body                 = WebUtility.HtmlDecode(a.Body),
                        CreatedByUser        = a.CreatedByUser,
                        CreatedByUserId      = a.CreatedByUserId,
                        CreatedOnDate        = a.CreatedOnDate,
                        Description          = WebUtility.HtmlDecode(a.Description),
                        LastModifiedByUser   = a.LastUpdatedByUser,
                        LastModifiedByUserId = a.LastModifiedByUserId,
                        LastModifiedOnDate   = a.LastModifiedOnDate,
                        ModuleId             = a.ModuleId,
                        Title                = a.Title,
                        url = DotNetNuke.Common.Globals.NavigateURL(a.TabID, "", "&aid=" + a.ArticleId)
                    };
                    cleanArticles.Add(newArt);
                }

                var articleViewModels = new ArticleViewModels
                {
                    Articles = cleanArticles
                };

                return(Request.CreateResponse(HttpStatusCode.OK, articles));
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);                                                             //todo: obsolete
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "error in request")); //todo: probably should localize that?
            }
        }