示例#1
0
        ///
        /// Main methods
        ///

        public async Task <List <Webpage> > GetContentfulWebpages()
        {
            return(await _cacheService.GetAsync("GetContentfulWebpages", async() =>
            {
                var builder = new QueryBuilder <ContentfulWebpage>().Include(10);

                var response = await _client.GetEntriesByType("webpage", builder);

                return response.Select(x => new Webpage(x)).ToList();
            }, 1440).Unwrap());
        }
示例#2
0
        public async Task GetEntriesByTypeShouldAddCorrectFilter()
        {
            //Arrange
            _handler.Response = GetResponseFromFile(@"EntriesCollection.json");
            var builder = QueryBuilder <TestEntryModel> .New;
            //Act
            var res = await _client.GetEntriesByType("666", builder);

            //Assert
            Assert.Equal(9, res.Count());
            Assert.Equal("Home & Kitchen", res.First().Title);
            Assert.Equal("?content_type=666", builder.Build());
        }
示例#3
0
        ///
        /// Preview Methods
        /// No caching for preview client results - don't want to reset cache when previewing changes
        ///

        public async Task <List <Webpage> > PreviewContentfulWebpages()
        {
            var builder = new QueryBuilder <ContentfulWebpage>().Include(10);

            var response = await _previewClient.GetEntriesByType("webpage", builder);

            return(response.Select(x => new Webpage(x)).ToList());
        }
        // When you go to /Lessons, return a list of all lessons
        public async Task <ActionResult> Index()
        {
            var httpClient = new System.Net.Http.HttpClient();
            var client     = new ContentfulClient(httpClient, "TJUTn86tuAZZ0L4Aw1LmA2HUBWNoU2TBHeCghBWJTac", "XsWxHVfA6Mu5yO2rlMf_IlrmIxfy5nAnFPraPg5LGc0", "dgv1c069l5im");

            var entries = await client.GetEntriesByType <Lesson>("lesson");

            // foreach (var row in entries) Console.WriteLine(row.Slug);

            return(View(entries));
        }