Beispiel #1
0
        private void CreateNote()
        {
            CreateNote CN = new CreateNote();

            CN.title   = "Untitled";
            CN.content = "[EMPTY]";

            Messenger.Default.Send <CreateNote>(CN);
            CN = null;
        }
Beispiel #2
0
        private void ADD(CreateNote CN)
        {
            string output = JsonConvert.SerializeObject(CN);

            Console.WriteLine(API_HOST);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(API_HOST);

            request.Method      = WebRequestMethods.Http.Post;
            request.ContentType = "application/json";

            using (System.IO.StreamWriter SW = new System.IO.StreamWriter(request.GetRequestStream()))
            {
                SW.Write(output);
                SW.Flush();
                SW.Close();

                Messenger.Default.Send <NotificationMessage>(new NotificationMessage(output));

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (System.IO.Stream stream = response.GetResponseStream())
                {
                    using (System.IO.StreamReader SR = new System.IO.StreamReader(stream))
                    {
                        string res = SR.ReadToEnd();
                        Messenger.Default.Send <NotificationMessage>(new NotificationMessage(res));
                        ServerAdd result = JsonConvert.DeserializeObject <ServerAdd>(res);

                        DataResponse DR = new DataResponse();
                        DR.id      = result._id;
                        DR.title   = result.title;
                        DR.content = result.content;
                        Messenger.Default.Send <DataResponse>(DR);

                        DM.Insert(result._id, result.title, result.content);
                    }
                }
            }
        }