Esempio n. 1
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            ArticleTypeWidget currentWidget = widget as ArticleTypeWidget;
            var service = new ArticleTypeService();
            var filter  = new Data.DataFilter().Where("ParentID", Data.OperatorType.Equal, currentWidget.ArticleTypeID);
            int ac      = 0;

            int.TryParse(httpContext.Request.QueryString["ac"], out ac);
            return(widget.ToWidgetPart(new ArticleTypeWidgetViewModel
            {
                ArticleTypes = service.Get(filter),
                CurrentType = service.Get(currentWidget.ArticleTypeID),
                TargetPage = currentWidget.TargetPage.IsNullOrEmpty() ? httpContext.Request.Url.PathAndQuery.ToLower() : currentWidget.TargetPage,
                ArticleTypeID = ac
            }));
        }
Esempio n. 2
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            var currentWidget      = widget as ArticleListWidget;
            var articleTypeService = new ArticleTypeService();
            var categoryEntity     = articleTypeService.Get(currentWidget.ArticleCategoryID);
            int pageIndex          = 0;
            int ac = 0;

            int.TryParse(httpContext.Request.QueryString["ac"], out ac);
            int.TryParse(httpContext.Request.QueryString["p"], out pageIndex);
            var filter = new Data.DataFilter();

            filter.Where("IsPublish=true");
            filter.OrderBy("PublishDate", OrderType.Descending);
            var articleService = new ArticleService();
            var page           = new Data.Pagination {
                PageIndex = pageIndex, PageSize = currentWidget.PageSize ?? 20
            };

            if (ac != 0)
            {
                filter.Where("ArticleCategoryID", OperatorType.Equal, ac);
            }
            else if (currentWidget.ArticleCategoryID.HasValue)
            {
                filter.Where("ArticleCategoryID", OperatorType.Equal, currentWidget.ArticleCategoryID);
            }
            return(widget.ToWidgetPart(new ArticleListWidgetViewModel
            {
                Articles = currentWidget.IsPageable ? articleService.Get(filter, page) : articleService.Get(filter),
                Widget = currentWidget,
                Pagin = page,
                CategoryTitle = categoryEntity == null ? "" : categoryEntity.Title,
                IsPageable = currentWidget.IsPageable
            }));
        }