protected void newReply_Click(object sender, EventArgs e)
    {
        //If you loaded multiple hosts, like say for each website, replace the string with a retrieval method of your choice.
        //Example, if you loaded by site name you could get the current site name.
        host = Host.Get("default");

        int threadId;

        if (Request["t"] == null || !Int32.TryParse(Request["t"], out threadId))
        {
            throw new ArgumentException("Thread Id was missing or invalid");
        }

        var options = new NameValueCollection();

        options.Add("Body", tbNewReplyBody.Text);

        var pathParms = new NameValueCollection();

        pathParms.Add("threadid", threadId.ToString());
        // REST call: create the reply
        var endpoint = "forums/threads/{threadid}/replies.json";

        dynamic response = host.PostToDynamic(2, endpoint, true, new RestPostOptions()
        {
            PathParameters = pathParms, PostParameters = options
        });

        Response.Redirect(string.Format("/community/forums/thread?t={0}", threadId));
    }
Ejemplo n.º 2
0
    protected void newThread_Click(object sender, EventArgs e)
    {
        host = Host.Get("default");

        int forumId;

        if (Request["f"] == null || !Int32.TryParse(Request["f"], out forumId))
        {
            throw new ArgumentException("Forum Id was missing or invalid");
        }

        var options = new NameValueCollection();

        options.Add("Subject", tbNewThreadSubject.Text);
        options.Add("Body", tbNewThreadBody.Text);

        var pathParms = new NameValueCollection();

        pathParms.Add("forumid", forumId.ToString());

        var endpoint = "forums/{forumid}/threads.json";

        dynamic response = host.PostToDynamic(2, endpoint, true, new RestPostOptions()
        {
            PathParameters = pathParms, PostParameters = options
        });

        Response.Redirect(string.Format("/community/forums/thread?t={0}", response.Thread.Id));
    }