public async Task <ActionResult> Register() { HttpClient httpClient = new HttpClient(); var options = new ContentfulOptions { DeliveryApiKey = "4df4c5c7ed276605d36b9d880f1455aea05fe9b47e2da6acf518c0771d300625", PreviewApiKey = "3aaec008db04a17e144539715f539354ff73cf8d82c2548c3045bbcfc2ee32a2", SpaceId = "bda2gc49gm0w" }; var client = new ContentfulClient(httpClient, options); List <string> Cities = new List <string>(); var AllCategories = await client.GetContentType("users"); foreach (var fields in AllCategories.Fields) { if (fields.Id == "allCity") { Cities = ((Contentful.Core.Models.Management.InValuesValidator)fields.Items.Validations[0]).RequiredValues; } } HttpContext.Cache.Add("City", Cities, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), System.Web.Caching.CacheItemPriority.Normal, null); return(View()); }
public async Task GetContentTypeShouldSerializeCorrectly() { //Arrange _handler.Response = GetResponseFromFile(@"SampleContentType.json"); //Act var res = await _client.GetContentType("someid"); //Assert Assert.Equal("Product", res.Name); Assert.Equal("productName", res.DisplayField); Assert.Equal(12, res.Fields.Count); Assert.True(res.Fields[0].Localized); Assert.Equal("Description", res.Fields[2].Name); Assert.Equal("Link", res.Fields[4].Items.Type); }