/// <summary>
 /// Validates the post request.
 /// </summary>
 /// <param name="threadType">Type of the thread.</param>
 /// <param name="captchaInfo">The captcha information.</param>
 /// <param name="skipCaptia">if set to <c>true</c> [skip captia].</param>
 public static void ValidatePostRequest(string threadType, CaptchaInfo captchaInfo, bool skipCaptia)
 {
     CommentsWebServiceReflector.ValidatePostRequestReflect(threadType, captchaInfo, skipCaptia);
 }
Example #2
0
        private CommentResponse PostInternal(CommentCreateRequest request)
        {
            CommentsWebServiceReflector.Validate(request);

            CommentResponse result;

            try
            {
                var author = CommentsUtilitiesReflector.GetAuthor(request);
                var cs     = SystemManager.GetCommentsService();
                var thread = cs.GetThread(request.ThreadKey);

                if (thread == null)
                {
                    request.Thread.Key = request.ThreadKey;

                    CommentsWebServiceReflector.Validate(request.Thread);
                    CommentsWebServiceReflector.ValidatePostRequest(request.Thread.Type, request.Captcha, false);

                    var group = cs.GetGroup(request.Thread.GroupKey);
                    if (group == null)
                    {
                        CommentsWebServiceReflector.Validate(request.Thread.Group);

                        request.Thread.Group.Key = request.Thread.GroupKey;

                        var groupProxy = new GroupProxy(request.Thread.Group.Name, request.Thread.Group.Description, author)
                        {
                            Key = request.Thread.Group.Key
                        };
                        group = cs.CreateGroup(groupProxy);
                    }

                    var threadProxy = new ThreadProxy(request.Thread.Title, request.Thread.Type, group.Key, author)
                    {
                        Key        = request.Thread.Key,
                        Language   = request.Thread.Language,
                        DataSource = request.Thread.DataSource,
                        Behavior   = request.Thread.Behavior
                    };

                    thread = cs.CreateThread(threadProxy);
                }
                else
                {
                    if (thread.IsClosed)
                    {
                        throw new InvalidOperationException("Thread is closed.");
                    }

                    CommentsWebServiceReflector.ValidatePostRequest(thread.Type, request.Captcha, false);
                }

                result = this.SubmitCommentInternal(request, thread, author);
            }
            catch (InvalidOperationException ex)
            {
                throw new InvalidOperationException("Comment cannot be submitted at the moment. Please refresh the page and try again.", ex);
            }

            ServiceUtility.DisableCache();

            return(result);
        }
 /// <summary>
 /// Validates the specified request.
 /// </summary>
 /// <param name="request">The request.</param>
 public static void Validate(GroupCreateRequest request)
 {
     CommentsWebServiceReflector.ValidateReflect(request);
 }