Ejemplo n.º 1
0
        public async Task <ActionResult <int> > PostPostItem(Post post)
        {
            var serializer = new DataContractJsonSerializer(typeof(List <Post>));

            // send new post to backend
            MemoryStream s = new MemoryStream();

            serializer.WriteObject(s, post);
            string stringData  = System.Text.Encoding.UTF8.GetString(s.ToArray());
            var    contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
            var    response    = await client.PostAsync("http://backend/v1/post", contentData);

            // update top words
            var postStream = await client.GetStreamAsync("http://backend/v1/post");

            var posts = serializer.ReadObject(postStream) as List <Post>;

            TextAnalyzer.AnalyseTextAndUpdateCache(posts, _cache);

            return(0);
        }