public ContentResult Entries([FromQuery(Name = "ctid")] string ctid)
        {
            string result = "{" + Environment.NewLine;

            foreach (Entry element in _client.ContentType(ctid).Query().Find <Entry>().Result)
            {
                result += "  { ctid: \"" + ctid + "\" uid:\"" + element.Uid + " \", title: \"" + element.Title + "\" }" + Environment.NewLine;
            }

            return(Content(result + '}'));
        }
        public async Task FetchContenTypeSchema()
        {
            ContentType contenttype = client.ContentType(source);

            var result = await contenttype.Fetch();

            if (result == null)
            {
                Assert.False(true, "contenttype.FetchSchema() is not match with expected result.");
            }
            else
            {
                Assert.True(true);
            }
        }
            public void List(ContentstackClient client)
            {
                foreach (Newtonsoft.Json.Linq.JObject contentType in
                         client.GetContentTypes(new Dictionary <string, object>()).Result)
                {
                    string contentTypeUid = contentType.GetValue("uid").ToString();
                    Message(contentTypeUid);

                    client.ContentType(contentTypeUid).Query().Find <Entry>().ContinueWith((t) =>
                    {
                        foreach (Entry entry in t.Result.Items)
                        {
                            string line = entry.Uid;

                            if (entry.Object.ContainsKey("url") &&
                                entry.Object["url"] != null &&
                                !String.IsNullOrEmpty(entry.Object["url"].ToString()))
                            {
                                line += " (" + entry.Object["url"] + ")";
                            }

                            line += " : " + entry.Title;
                            Message(line);
                        }

                        Line();
                    }).GetAwaiter().GetResult();
                }
            }
 public void Go(
     ContentstackClient stack,
     OutputWriter writer)
 {
     // https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-all-content-types
     foreach (JObject contentTypeJson in stack.GetContentTypes().GetAwaiter().GetResult())
     {
         ContentType contentType = stack.ContentType(contentTypeJson["uid"].ToString());
         new Thread(() => { ProcessContentType(contentType, writer); }).Start();
     }
 }
Exemplo n.º 5
0
        public async Task FetchEntry()
        {
            ContentstackClient contentstackClient = new ContentstackClient("blt520df8d675f11a0a", "bltcc8f202fa758bdf2", "development");
            Entry csEntry = contentstackClient.ContentType("test").Entry("blt9f9e183545e2fe5b");

            csEntry.SetLanguage(Internals.Language.GERMEN_SWITZERLAND);
            Entry entry = await csEntry.Fetch();

            Console.WriteLine(entry.ToString());
            Assert.True(true, "result is greater than 11");
        }
Exemplo n.º 6
0
        public void Go(
            ContentstackClient stack,
            string contentTypeUid,
            string entryUid,
            OutputWriter writer)
        {
            //TODO: does this really invoke REST API?
            // https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-a-single-content-type
            // https://www.contentstack.com/docs/platforms/dot-net/api-reference/api/Contentstack.Core.Models.ContentType.html
            ContentType contentType = stack.ContentType(contentTypeUid);

            // https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-a-single-entry
            // https://www.contentstack.com/docs/platforms/dot-net/api-reference/api/Contentstack.Core.Models.Entry.html
            contentType.Entry(entryUid).Fetch <Entry>().ContinueWith((t) =>
            {
                Entry entry       = t.Result;
                string message    = $"Asynchronous: {entry.Uid} : {entry.Title}";
                JObject entryJson = entry.ToJson();

                if (entryJson.ContainsKey("url"))
                {
                    message += " (" + entryJson["url"] + ")";
                }

                writer.Message(this, message);
            });

            Entry entry = contentType.Entry(entryUid).Fetch <Entry>().GetAwaiter().GetResult();

            if (entry != null)
            {
                string  message   = $"Synchronous: {entry.Uid} : {entry.Title}";
                JObject entryJson = entry.ToJson();

                if (entryJson.ContainsKey("url"))
                {
                    message += " (" + entryJson["url"] + ")";
                }

                writer.Message(this, message);
            }
        }
        public void Go(
            ContentstackClient stack,
            string contentTypeUid,
            string entryUid,
            OutputWriter writer)
        {
            //TODO: does this really invoke REST API?
            // https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-a-single-content-type
            // https://www.contentstack.com/docs/platforms/dot-net/api-reference/api/Contentstack.Core.Models.ContentType.html
            ContentType contentType = stack.ContentType(contentTypeUid);

            // https://www.contentstack.com/docs/developers/apis/content-delivery-api/#get-a-single-entry
            BasicEntry directEntry = contentType.Entry(entryUid).Fetch <BasicEntry>().GetAwaiter().GetResult();

            writer.Message(this, "Direct: " + directEntry.CreatedAt);
            Entry      entry          = contentType.Entry(entryUid).Fetch <Entry>().GetAwaiter().GetResult();
            JObject    entryJson      = entry.ToJson();
            BasicEntry convertedEntry = entryJson.ToObject <BasicEntry>(JsonSerializer.Create(stack.SerializerSettings));

            writer.Message(this, "Converted: " + directEntry.CreatedAt);
        }
Exemplo n.º 8
0
        //EU
        //String source = "source";
        //String singelEntryFetchUID = "bltf4268538a14fc5e1";
        //string htmlSource = "blt7c4197d43c1156ba";
        //String referenceFieldUID = "reference";
        public async Task <string> GetUID(string title)
        {
            Query query  = client.ContentType(source).Query();
            var   result = await query.Find <SourceModel>();

            if (result != null)
            {
                foreach (var data in result.Items)
                {
                    if (data.Title == title)
                    {
                        return(data.Uid);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        public async Task FetchByUid()
        {
            ContentType contenttype = client.ContentType(source);
            Entry       sourceEntry = contenttype.Entry(singelEntryFetchUID);
            var         result      = await sourceEntry.Fetch();

            if (result == null)
            {
                Assert.False(true, "Entry.Fetch is not match with expected result.");
            }
            else
            {
                Assert.True(result.Object.Count > 0 && result.EntryUid == sourceEntry.EntryUid && result.Object.ContainsKey("publish_details") && result.Object["publish_details"] != null);
            }
        }
Exemplo n.º 10
0
 public Task <T> Get <T>(string ContentType, string Entry)
 {
     return(_ContentStackClient.ContentType(ContentType).Entry(Entry).Fetch <T>());
 }