Beispiel #1
0
        public async Task RetrieveCategoryAsync_ShouldReturnCategoryWithoutPosts()
        {
            var response = await butterClient.RetrieveCategoryAsync("test-category");

            Assert.IsNotNull(response);
            Assert.IsNull(response.RecentPosts);
        }
Beispiel #2
0
        public async Task <IActionResult> OnGet(string slug, int page = 1)
        {
            var postsPerPage = 10;

            var categoryResponse = (await _client.RetrieveCategoryAsync(slug));
            var postsResponse    = (await _client.ListPostsAsync(page, postsPerPage, true, categorySlug: slug));

            Blogs = new BlogListViewModel
            {
                Posts        = postsResponse.Data,
                Count        = postsResponse.Meta.Count,
                NextPage     = postsResponse.Meta.NextPage,
                CurrentPage  = page,
                PreviousPage = postsResponse.Meta.PreviousPage,
                TotalPages   = Convert.ToInt32(Math.Floor(decimal.Divide(postsResponse.Meta.Count, postsPerPage)))
            };

            Category = new CategoryViewModel
            {
                Category = categoryResponse,
                Blogs    = Blogs
            };

            return(Page());
        }