예제 #1
0
        public ActionResult Comments(int?filterByNewsItemId, GridCommand command)
        {
            IPagedList <NewsComment> comments;

            if (filterByNewsItemId.HasValue)
            {
                // Filter comments by news item.
                var query = _customerContentService.GetAllCustomerContent <NewsComment>(0, null).SourceQuery;
                query = query.Where(x => x.NewsItemId == filterByNewsItemId.Value);

                comments = new PagedList <NewsComment>(query, command.Page - 1, command.PageSize);
            }
            else
            {
                // Load all news comments.
                comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null, null, null, command.Page - 1, command.PageSize);
            }

            var customerIds = comments.Select(x => x.CustomerId).Distinct().ToArray();
            var customers   = _customerService.GetCustomersByIds(customerIds).ToDictionarySafe(x => x.Id);

            var model = new GridModel <NewsCommentModel>
            {
                Total = comments.TotalCount
            };

            model.Data = comments.Select(newsComment =>
            {
                customers.TryGetValue(newsComment.CustomerId, out var customer);

                var commentModel = new NewsCommentModel
                {
                    Id            = newsComment.Id,
                    NewsItemId    = newsComment.NewsItemId,
                    NewsItemTitle = newsComment.NewsItem.GetLocalized(x => x.Title),
                    CustomerId    = newsComment.CustomerId,
                    IpAddress     = newsComment.IpAddress,
                    CreatedOn     = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc),
                    CommentTitle  = newsComment.CommentTitle,
                    CommentText   = HtmlUtils.ConvertPlainTextToHtml(newsComment.CommentText.HtmlEncode()),
                    CustomerName  = customer.GetDisplayName(T)
                };

                return(commentModel);
            });

            return(new JsonResult
            {
                Data = model
            });
        }
        public ActionResult List(GridCommand command, ProductReviewListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            DateTime?createdOnFromValue = (model.CreatedOnFrom == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?createdToFromValue = (model.CreatedOnTo == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var productReviews = _customerContentService.GetAllCustomerContent <ProductReview>(0, null,
                                                                                               createdOnFromValue, createdToFromValue);
            var gridModel = new GridModel <ProductReviewModel>
            {
                Data = productReviews.PagedForCommand(command).Select(x =>
                {
                    var m = new ProductReviewModel();
                    PrepareProductReviewModel(m, x, false, true);
                    return(m);
                }),
                Total = productReviews.Count,
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #3
0
        public bool Match(CartRuleContext context, RuleExpression expression)
        {
            var query        = _customerContentService.GetAllCustomerContent <ProductReview>(context.Customer.Id, true).SourceQuery;
            var reviewsCount = query.Count();

            return(expression.Operator.Match(reviewsCount, expression.Value));
        }
예제 #4
0
        public ActionResult List(GridCommand command, ProductReviewListModel model)
        {
            DateTime?createdFrom = (model.CreatedOnFrom == null) ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?createdTo = (model.CreatedOnTo == null) ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var productReviews = _customerContentService.GetAllCustomerContent <ProductReview>(
                0,
                null,
                createdFrom,
                createdTo,
                command.Page - 1,
                command.PageSize);

            var gridModel = new GridModel <ProductReviewModel>
            {
                Total = productReviews.TotalCount
            };

            gridModel.Data = productReviews.Select(x =>
            {
                var m = new ProductReviewModel();
                PrepareProductReviewModel(m, x, false, true);
                return(m);
            });

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #5
0
        public ActionResult Comments(int?filterByNewsItemId, GridCommand command)
        {
            var gridModel = new GridModel <NewsCommentModel>();

            if (_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                IList <NewsComment> comments;
                if (filterByNewsItemId.HasValue)
                {
                    //filter comments by news item
                    var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value);
                    comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
                }
                else
                {
                    //load all news comments
                    comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null);
                }

                gridModel.Data = comments.PagedForCommand(command).Select(newsComment =>
                {
                    var commentModel = new NewsCommentModel();
                    var customer     = _customerService.GetCustomerById(newsComment.CustomerId);

                    commentModel.Id            = newsComment.Id;
                    commentModel.NewsItemId    = newsComment.NewsItemId;
                    commentModel.NewsItemTitle = newsComment.NewsItem.Title;
                    commentModel.CustomerId    = newsComment.CustomerId;
                    commentModel.IpAddress     = newsComment.IpAddress;
                    commentModel.CreatedOn     = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc);
                    commentModel.CommentTitle  = newsComment.CommentTitle;
                    commentModel.CommentText   = Core.Html.HtmlUtils.FormatText(newsComment.CommentText, false, true, false, false, false, false);

                    if (customer == null)
                    {
                        commentModel.CustomerName = "".NaIfEmpty();
                    }
                    else
                    {
                        commentModel.CustomerName = customer.GetFullName();
                    }

                    return(commentModel);
                });

                gridModel.Total = comments.Count;
            }
            else
            {
                gridModel.Data = Enumerable.Empty <NewsCommentModel>();

                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #6
0
        public ActionResult Comments(int?filterByBlogPostId, GridCommand command)
        {
            var model = new GridModel <BlogCommentModel>();

            if (_permissionService.Authorize(StandardPermissionProvider.ManageBlog))
            {
                IList <BlogComment> comments;
                if (filterByBlogPostId.HasValue)
                {
                    //filter comments by blog
                    var blogPost = _blogService.GetBlogPostById(filterByBlogPostId.Value);
                    comments = blogPost.BlogComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
                }
                else
                {
                    //load all blog comments
                    comments = _customerContentService.GetAllCustomerContent <BlogComment>(0, null);
                }

                model.Data = comments.PagedForCommand(command).Select(blogComment =>
                {
                    var commentModel = new BlogCommentModel();
                    var customer     = _customerService.GetCustomerById(blogComment.CustomerId);

                    commentModel.Id            = blogComment.Id;
                    commentModel.BlogPostId    = blogComment.BlogPostId;
                    commentModel.BlogPostTitle = blogComment.BlogPost.Title;
                    commentModel.CustomerId    = blogComment.CustomerId;
                    commentModel.IpAddress     = blogComment.IpAddress;
                    commentModel.CreatedOn     = _dateTimeHelper.ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc);
                    commentModel.Comment       = Core.Html.HtmlUtils.FormatText(blogComment.CommentText, false, true, false, false, false, false);

                    if (customer == null)
                    {
                        commentModel.CustomerName = "".NaIfEmpty();
                    }
                    else
                    {
                        commentModel.CustomerName = customer.GetFullName();
                    }

                    return(commentModel);
                });

                model.Total = comments.Count;
            }
            else
            {
                model.Data = Enumerable.Empty <BlogCommentModel>();

                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                Data = model
            });
        }
예제 #7
0
        public ActionResult Comments(int?filterByNewsItemId, GridCommand command)
        {
            var gridModel = new GridModel <NewsCommentModel>();

            IList <NewsComment> comments;

            if (filterByNewsItemId.HasValue)
            {
                //filter comments by news item
                var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value);
                comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
            }
            else
            {
                //load all news comments
                comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null);
            }

            gridModel.Data = comments.PagedForCommand(command).Select(newsComment =>
            {
                var commentModel = new NewsCommentModel();
                var customer     = _customerService.GetCustomerById(newsComment.CustomerId);

                commentModel.Id            = newsComment.Id;
                commentModel.NewsItemId    = newsComment.NewsItemId;
                commentModel.NewsItemTitle = newsComment.NewsItem.Title;
                commentModel.CustomerId    = newsComment.CustomerId;
                commentModel.IpAddress     = newsComment.IpAddress;
                commentModel.CreatedOn     = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc);
                commentModel.CommentTitle  = newsComment.CommentTitle;
                commentModel.CommentText   = HtmlUtils.ConvertPlainTextToHtml(newsComment.CommentText.HtmlEncode());

                if (customer == null)
                {
                    commentModel.CustomerName = "".NaIfEmpty();
                }
                else
                {
                    commentModel.CustomerName = customer.GetFullName();
                }

                return(commentModel);
            });

            gridModel.Total = comments.Count;


            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #8
0
        public ActionResult Comments(int?filterByBlogPostId, GridCommand command)
        {
            var model = new GridModel <BlogCommentModel>();

            IList <BlogComment> comments;

            if (filterByBlogPostId.HasValue)
            {
                //filter comments by blog
                var blogPost = _blogService.GetBlogPostById(filterByBlogPostId.Value);
                comments = blogPost.BlogComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
            }
            else
            {
                //load all blog comments
                comments = _customerContentService.GetAllCustomerContent <BlogComment>(0, null);
            }

            model.Data = comments.PagedForCommand(command).Select(blogComment =>
            {
                var commentModel = new BlogCommentModel();
                var customer     = _customerService.GetCustomerById(blogComment.CustomerId);

                commentModel.Id            = blogComment.Id;
                commentModel.BlogPostId    = blogComment.BlogPostId;
                commentModel.BlogPostTitle = blogComment.BlogPost.Title;
                commentModel.CustomerId    = blogComment.CustomerId;
                commentModel.IpAddress     = blogComment.IpAddress;
                commentModel.CreatedOn     = _dateTimeHelper.ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc);
                commentModel.Comment       = HtmlUtils.ConvertPlainTextToHtml(blogComment.CommentText.HtmlEncode());

                if (customer == null)
                {
                    commentModel.CustomerName = "".NaIfEmpty();
                }
                else
                {
                    commentModel.CustomerName = customer.GetFullName();
                }

                return(commentModel);
            });

            model.Total = comments.Count;

            return(new JsonResult
            {
                Data = model
            });
        }
예제 #9
0
        public ActionResult Comments(int?filterByNewsItemId, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            IList <NewsComment> comments;

            if (filterByNewsItemId.HasValue)
            {
                //filter comments by news item
                var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value);
                comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
            }
            else
            {
                //load all news comments
                comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null);
            }

            var gridModel = new GridModel <NewsCommentModel>
            {
                Data = comments.PagedForCommand(command).Select(newsComment =>
                {
                    var commentModel           = new NewsCommentModel();
                    commentModel.Id            = newsComment.Id;
                    commentModel.NewsItemId    = newsComment.NewsItemId;
                    commentModel.NewsItemTitle = newsComment.NewsItem.Title;
                    commentModel.CustomerId    = newsComment.CustomerId;
                    var customer = newsComment.Customer;
                    commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest");
                    commentModel.IpAddress    = newsComment.IpAddress;
                    commentModel.CreatedOn    = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc);
                    commentModel.CommentTitle = newsComment.CommentTitle;
                    commentModel.CommentText  = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false);
                    return(commentModel);
                }),
                Total = comments.Count,
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #10
0
        public ActionResult Comments(int?filterByBlogPostId, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageBlog))
            {
                return(AccessDeniedView());
            }

            IList <BlogComment> comments;

            if (filterByBlogPostId.HasValue)
            {
                //filter comments by blog
                var blogPost = _blogService.GetBlogPostById(filterByBlogPostId.Value);
                comments = blogPost.BlogComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
            }
            else
            {
                //load all blog comments
                comments = _customerContentService.GetAllCustomerContent <BlogComment>(0, null);
            }

            var gridModel = new GridModel <BlogCommentModel>
            {
                Data = comments.PagedForCommand(command).Select(blogComment =>
                {
                    var commentModel           = new BlogCommentModel();
                    commentModel.Id            = blogComment.Id;
                    commentModel.BlogPostId    = blogComment.BlogPostId;
                    commentModel.BlogPostTitle = blogComment.BlogPost.Title;
                    commentModel.CustomerId    = blogComment.CustomerId;
                    commentModel.IpAddress     = blogComment.IpAddress;
                    commentModel.CreatedOn     = _dateTimeHelper.ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc);
                    commentModel.Comment       = Core.Html.HtmlHelper.FormatText(blogComment.CommentText, false, true, false, false, false, false);
                    return(commentModel);
                }),
                Total = comments.Count,
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #11
0
        public ActionResult List(GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }

            var productReviews = _customerContentService.GetAllCustomerContent <ProductReview>(0, null);
            var gridModel      = new GridModel <ProductReviewModel>
            {
                Data = productReviews.PagedForCommand(command).Select(x =>
                {
                    var m = new ProductReviewModel();
                    PrepareProductReviewModel(m, x, false, true);
                    return(m);
                }),
                Total = productReviews.Count,
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }