Esempio n. 1
0
        public void CreateReview(string domainKey, string threadType, Guid itemId, string itemTitle, string message, decimal?rating, string status)
        {
            var cs          = SystemManager.GetCommentsService();
            var authorProxy = new AuthorProxy(ClaimsManager.GetCurrentUserId().ToString());

            var domainProxy = new GroupProxy("TestDomain", "TestDomainDescription", authorProxy)
            {
                Key = domainKey
            };

            cs.CreateGroup(domainProxy);

            var culture = this.GetCurrentCulture();

            var threadProxy = new ThreadProxy(itemTitle, threadType, domainKey, authorProxy)
            {
                Key = itemId.ToString() + "_" + culture + "_review", Language = culture
            };
            var thread = cs.CreateThread(threadProxy);

            DateTime dateCreated = DateTime.UtcNow.AddMinutes(5);

            var commentProxy = new CommentProxy(message, thread.Key, authorProxy, SystemManager.CurrentHttpContext.Request.UserHostAddress, rating)
            {
                Status = status, DateCreated = dateCreated
            };

            cs.CreateComment(commentProxy);
        }
Esempio n. 2
0
        private static void EnsureBlogPostGroupExists(string groupKey, IAuthor author, ICommentService cs)
        {
            GroupFilter groupFilter = new GroupFilter();

            groupFilter.GroupKey.Add(groupKey);
            var group = cs.GetGroups(groupFilter).SingleOrDefault();

            if (group == null)
            {
                var groupProxy = new GroupProxy("Group title", "blog posts in provider", author)
                {
                    Key = groupKey
                };
                group = cs.CreateGroup(groupProxy);
            }
        }
Esempio n. 3
0
        private void PopulateGroupsDropdown()
        {
            _pbe.CmbGroups.Items.Clear();
            _pbe.CmbReports.Items.Clear();
            _pbe.CmbPages.Items.Clear();

            foreach (var group in _pbe.PbiGroups)
            {
                var groupProxy = new GroupProxy
                {
                    Text  = group.Name,
                    Value = group
                };
                _pbe.CmbGroups.Items.Add(groupProxy);
            }
        }
        public void CreateReview(string domainKey, string threadType, Guid itemId, string itemTitle, string message, decimal? rating, string status)
        {
            var cs = SystemManager.GetCommentsService();
            var authorProxy = new AuthorProxy(ClaimsManager.GetCurrentUserId().ToString());

            var domainProxy = new GroupProxy("TestDomain", "TestDomainDescription", authorProxy) { Key = domainKey };
            cs.CreateGroup(domainProxy);

            var threadProxy = new ThreadProxy(itemTitle, threadType, domainKey, authorProxy) { Key = itemId.ToString() + "_en_review", Language = "en" };
            var thread = cs.CreateThread(threadProxy);

            DateTime dateCreated = DateTime.UtcNow.AddMinutes(5);

            var commentProxy = new CommentProxy(message, thread.Key, authorProxy, SystemManager.CurrentHttpContext.Request.UserHostAddress, rating)
                                { Status = status, DateCreated = dateCreated };
            cs.CreateComment(commentProxy);
        }
Esempio n. 5
0
        public async Task GroupProxy_SendAsync_ArrayArgumentNotExpanded()
        {
            object[] resultArgs = null;

            var o = new Mock <HubLifetimeManager <FakeHub> >();

            o.Setup(m => m.SendGroupAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <object[]>(), It.IsAny <CancellationToken>()))
            .Callback <string, string, object[], CancellationToken>((groupName, methodName, args, _) => { resultArgs = args; })
            .Returns(Task.CompletedTask);

            var proxy = new GroupProxy <FakeHub>(o.Object, string.Empty);

            var data = Encoding.UTF8.GetBytes("Hello world");
            await proxy.SendAsync("Method", data);

            Assert.NotNull(resultArgs);
            var arg = (byte[])Assert.Single(resultArgs);

            Assert.Same(data, arg);
        }
Esempio n. 6
0
 /// <summary>Create a instance, wrapping the specified proxy</summary>
 public GroupNHibernateImpl(Func <IFrozenContext> lazyCtx, GroupProxy proxy)
     : base(lazyCtx) // do not pass proxy to base data object
 {
     this.Proxy       = proxy;
     _isExportGuidSet = Proxy.ID > 0;
 }
Esempio n. 7
0
        private static void EnsureBlogPostGroupExists(string groupKey, IAuthor author, ICommentService cs)
        {
            GroupFilter groupFilter = new GroupFilter();
            groupFilter.GroupKey.Add(groupKey);
            var group = cs.GetGroups(groupFilter).SingleOrDefault();

            if (group == null)
            {
                var groupProxy = new GroupProxy("Group title", "blog posts in provider", author) { Key = groupKey };
                group = cs.CreateGroup(groupProxy);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
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;
        }