Ejemplo n.º 1
0
        /// <summary>
        /// This method takes the Question title that is targetted into param qTitle this allows us to create a new array called Question.Title (eg HowToCode?)
        /// Which will allow us to easily identify the array to target and append new replies to it
        /// </summary>
        /// <param name="qTitle"></param>
        /// <param name="Reply"></param>
        public void Reply(Question qTitle, ReplyQuestion Reply)
        {
            string replyJson    = WebUtility.UrlEncode(Reply.ToJsonString());
            string spaceRemoved = qTitle.Title.Replace(" ", string.Empty);

            string newReplyUrl = url + "&action=append&objectid=" + spaceRemoved + "&data=" + replyJson;
            Uri    uri         = new Uri(newReplyUrl);

            SendToServer(uri);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new Questions inside the JSON questionData array + create a new array for replies
        /// </summary>
        /// <param name="NewQuestion"></param>
        public void NewQuestion(Question NewQuestion)
        {
            string        replyQuestion = "Comments below are replies";
            ReplyQuestion NewReply      = ReplyQuestion.CreateReplyFromJson("{\"Reply\":\"" + replyQuestion + "\"}");

            string spaceRemoved = NewQuestion.Title.Replace(" ", string.Empty);

            string Qjson = WebUtility.UrlEncode(NewQuestion.ToJsonString());
            string Rjson = WebUtility.UrlEncode(NewReply.ToJsonString());

            string newQuestionUrl = url + "&action=append&objectid=" + questionData + "&data=" + Qjson;
            string newReplyUrl    = url + "&action=append&objectid=" + spaceRemoved + "&data=[" + Rjson + "]";

            Uri uri         = new Uri(newQuestionUrl);
            Uri newReplyUri = new Uri(newReplyUrl);

            SendToServer(uri);
            SendToServer(newReplyUri);
        }
Ejemplo n.º 3
0
        public static ReplyQuestion CreateReplyFromJson(string json)
        {
            ReplyQuestion reply = JsonConvert.DeserializeObject <ReplyQuestion>(json);

            return(reply);
        }