Beispiel #1
0
        static async Task TestComments(SpeckleApiClient myClient)
        {
            string commentId = "lol", secondCommentId = "lol";

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating a comment on a stream.");
                var Response = await myClient.CommentCreateAsync(ResourceType.Stream, "SJY4LnGqz", new Comment()
                {
                    Text = "Hello World!", Labels = new List <string>()
                    {
                        "hai", "urgent"
                    }
                });

                Console.WriteLine("OK: " + Response.Resource.ToJson());

                commentId = Response.Resource._id;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating a comment on a comment.");
                var Response = await myClient.CommentCreateAsync(ResourceType.Comment, commentId, new Comment()
                {
                    Text = "Nested Hello World!", Labels = new List <string>()
                    {
                        "urgent"
                    }
                });

                Console.WriteLine("OK: " + Response.Resource.ToJson());

                secondCommentId = Response.Resource._id;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting a comment.");
                var Response = await myClient.CommentGetAsync(secondCommentId);

                Console.WriteLine("OK: " + Response.Resource.ToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Deleting a comment.");
                var Response = await myClient.CommentDeleteAsync(secondCommentId);

                Console.WriteLine("OK: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }