AddComment() public method

public AddComment ( ExampleComment comment ) : void
comment ExampleComment
return void
        private void AddComment(HttpContext context, ExampleConfig config)
        {
            lock (lockObj)
            {
                try
                {
                    string title = context.Request["CommentName"];
                    title = this.Shrink(title.IsEmpty() ? "[no title]" : title, 128);
                    string name = context.Request["UserName"];
                    name = this.Shrink(name.IsEmpty() ? "[anonymous]" : name, 128);
                    string message = this.Shrink(context.Request["CommentMessage"], 1024);

                    config.AddComment(new ExampleComment {
                        Name = name, Title = title, Message = message
                    });
                    context.Response.Write(JSON.Serialize(new { success = true }));
                }
                catch (Exception e)
                {
                    context.Response.Write(JSON.Serialize(new { success = false, msg = e.Message }));
                }

                context.Response.End();
            }
        }
Exemplo n.º 2
0
        private void AddComment(HttpContext context, ExampleConfig config)
        {
            lock (lockObj)
            {
                try
                {
                    string title = context.Request["CommentName"];
                    title = this.Shrink(title.IsEmpty() ? "[no title]" : title, 128);
                    string name = context.Request["UserName"];
                    name = this.Shrink( name.IsEmpty() ? "[anonymous]" : name, 128);
                    string message = this.Shrink(context.Request["CommentMessage"], 1024);

                    config.AddComment(new ExampleComment{Name = name, Title = title, Message = message});
                    context.Response.Write(JSON.Serialize(new {success = true}));
                }
                catch (Exception e)
                {
                    context.Response.Write(JSON.Serialize(new { success = false, msg = e.Message }));
                }

                context.Response.End();
            }
        }