예제 #1
0
        public ActionResult List(DataSourceRequest command, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topicModels = _topicService.GetAllTopics(model.SearchStoreId, true)
                              .Select(x => x.ToModel())
                              .ToList();

            //little hack here:
            //we don't have paging supported for topic list page
            //now ensure that topic bodies are not returned. otherwise, we can get the following error:
            //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
            foreach (var topic in topicModels)
            {
                topic.Body = "";
            }
            var gridModel = new DataSourceResult
            {
                Data  = topicModels,
                Total = topicModels.Count
            };

            return(Json(gridModel));
        }
예제 #2
0
        public ActionResult List(GridCommand command, TopicListModel model)
        {
            var gridModel = new GridModel <TopicModel>();

            if (_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                var topics = _topicService.GetAllTopics(model.SearchStoreId);

                gridModel.Data = topics.Select(x =>
                {
                    var item        = x.ToModel();
                    item.WidgetZone = x.WidgetZone.SplitSafe(",");
                    // otherwise maxJsonLength could be exceeded
                    item.Body = "";
                    return(item);
                });

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

                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }
        public virtual ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var model = new TopicListModel();

            #region Extensions by QuanNH
            //stores
            var _workContext = Nop.Core.Infrastructure.EngineContext.Current.Resolve <Nop.Core.IWorkContext>();
            var AllStores    = _storeService.GetAllStoresByEntityName(_workContext.CurrentCustomer.Id, "Stores");
            if (AllStores.Count <= 0)
            {
                AllStores = _storeService.GetAllStores();
                model.AvailableStores.Add(new SelectListItem()
                {
                    Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
                });
            }
            foreach (var s in AllStores)
            {
                model.AvailableStores.Add(new SelectListItem()
                {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            #endregion

            return(View(model));
        }
예제 #4
0
        public ActionResult List(GridCommand command, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topics    = _topicService.GetAllTopics(model.SearchStoreId);
            var gridModel = new GridModel <TopicModel>
            {
                Data = topics.Select(x => {
                    var item = x.ToModel();
                    // otherwise maxJsonLength could be exceeded
                    item.Body = "";
                    return(item);
                }),
                Total = topics.Count
            };

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }
예제 #5
0
        public virtual IActionResult List(DataSourceRequest command, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedKendoGridJson());
            }

            var topics = _topicService.GetAllTopics(model.SearchStoreId, true, true);

            if (!string.IsNullOrEmpty(model.SearchKeywords))
            {
                topics = topics.Where(t => (t.Title?.Contains(model.SearchKeywords) ?? false) || (t.Body?.Contains(model.SearchKeywords) ?? false)).ToList();
            }

            var topicModels = topics
                              .Select(x => x.ToModel())
                              .ToList();

            //little performance optimization: ensure that "Body" is not returned
            foreach (var topic in topicModels)
            {
                topic.Body = "";
            }
            var gridModel = new DataSourceResult
            {
                Data  = topicModels,
                Total = topicModels.Count
            };

            return(Json(gridModel));
        }
예제 #6
0
        public virtual IActionResult List(TopicSearchModel searchModel)
        {
            //prepare model
            TopicListModel model = _topicModelFactory.PrepareTopicListModel(searchModel);

            return(Json(model));
        }
        public IActionResult List(DataSourceRequest command, TopicListModel model)
        {
            var topicModels = _topicService.GetAllTopics(model.SearchStoreId, true)
                              .Select(x => x.ToModel())
                              .ToList();

            if (!string.IsNullOrEmpty(model.Name))
            {
                topicModels = topicModels.Where
                                  (x => x.SystemName.ToLowerInvariant().Contains(model.Name.ToLowerInvariant()) ||
                                  x.Title.ToLowerInvariant().Contains(model.Name.ToLowerInvariant())).ToList();
            }
            //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
            foreach (var topic in topicModels)
            {
                topic.Body = "";
            }
            var gridModel = new DataSourceResult
            {
                Data  = topicModels,
                Total = topicModels.Count
            };

            return(Json(gridModel));
        }
예제 #8
0
        /// <summary>
        /// 活动专题列表
        /// </summary>
        public ActionResult List(string topicSN, string topicTitle, string startTime, string endTime, string sortColumn, string sortDirection, int pageSize = 15, int pageNumber = 1)
        {
            string condition = AdminTopic.AdminGetTopicListCondition(topicSN, topicTitle, startTime, endTime);
            string sort      = AdminTopic.AdminGetTopicListSort(sortColumn, sortDirection);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminTopic.AdminGetTopicCount(condition));

            TopicListModel model = new TopicListModel()
            {
                TopicList     = AdminTopic.AdminGetTopicList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel     = pageModel,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                TopicTitle    = topicTitle,
                StartTime     = startTime,
                EndTime       = endTime
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&topicSN={5}&topicTitle={6}&startTime={7}&endTime={8}",
                                                          Url.Action("list"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn,
                                                          sortDirection,
                                                          topicSN,
                                                          topicTitle,
                                                          startTime,
                                                          endTime));
            return(View(model));
        }
예제 #9
0
        public IActionResult List()
        {
            var model = new TopicListModel
            {
                IsSingleStoreMode = _storeContext.IsSingleStoreMode()
            };

            return(View(model));
        }
예제 #10
0
        public ActionResult List(GridCommand command, TopicListModel model)
        {
            var gridModel = new GridModel <TopicModel>();

            if (Services.Permissions.Authorize(StandardPermissionProvider.ManageTopics))
            {
                var topics = _topicService.GetAllTopics(model.SearchStoreId, command.Page - 1, command.PageSize).AlterQuery(q =>
                {
                    var q2 = q;

                    if (model.SystemName.HasValue())
                    {
                        q2 = q2.Where(x => x.SystemName.Contains(model.SystemName));
                    }

                    if (model.Title.HasValue())
                    {
                        q2 = q2.Where(x => x.Title.Contains(model.Title));
                    }

                    if (model.RenderAsWidget.HasValue)
                    {
                        q2 = q2.Where(x => x.RenderAsWidget == model.RenderAsWidget.Value);
                    }

                    if (model.WidgetZone.HasValue())
                    {
                        q2 = q2.Where(x => x.WidgetZone.Contains(model.WidgetZone));
                    }

                    return(q2);
                });

                gridModel.Data = topics.Select(x =>
                {
                    var item        = x.ToModel();
                    item.WidgetZone = x.WidgetZone.SplitSafe(",");
                    // otherwise maxJsonLength could be exceeded
                    item.Body = "";
                    return(item);
                });

                gridModel.Total = topics.TotalCount;
            }
            else
            {
                gridModel.Data = Enumerable.Empty <TopicModel>();
                NotifyAccessDenied();
            }

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }
예제 #11
0
        public IActionResult List()
        {
            TopicListModel model = new TopicListModel()
            {
                Apps      = AppSvc.LoadApps().ToList(),
                Exchanges = TopicSvc.LoadExchanges().ToList()
            };

            return(View(model));
        }
예제 #12
0
        public ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var model = new TopicListModel();

            return(View(model));
        }
예제 #13
0
        public ActionResult List(DataTablesParam dataTableParam, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            //  var SearchSiteId = dataTableParam.bQueryModel.Items.FirstOrDefault().Value.ToString().ToInt();
            var topics = _topicService.GetAllTopics(model.SearchSiteId);

            return(DataTablesResult.Create(topics.Select(x => x.ToModel()).AsQueryable(), dataTableParam));
        }
예제 #14
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (NavigationContext.QueryString.Keys.Count > 0)
     {
         topic = NavigationContext.QueryString["topic"];
         this.topics.Topic = NavigationContext.QueryString["title"];
         this.topics.parentTopic = topic;
     }
     if (e.NavigationMode == NavigationMode.Back)
         topics = App.topicList.Pop();
     base.OnNavigatedTo(e);
 }
예제 #15
0
        public ActionResult List()
        {
            var model = new TopicListModel();

            foreach (var s in Services.StoreService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            return(View(model));
        }
예제 #16
0
        /// <summary>
        /// Prepare paged topic list model
        /// </summary>
        /// <param name="searchModel">Topic search model</param>
        /// <returns>Topic list model</returns>
        public virtual TopicListModel PrepareTopicListModel(TopicSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get topics
            var topics = _topicService.GetAllTopics(showHidden: true,
                                                    storeId: searchModel.SearchStoreId,
                                                    ignorAcl: true);

            //filter topics
            //TODO: move filter to topic service
            if (!string.IsNullOrEmpty(searchModel.SearchKeywords))
            {
                topics = topics.Where(topic => (topic.Title?.Contains(searchModel.SearchKeywords) ?? false) ||
                                      (topic.Body?.Contains(searchModel.SearchKeywords) ?? false)).ToList();
            }

            var pagedTopics = topics.ToList().ToPagedList(searchModel);

            //prepare grid model
            var model = new TopicListModel().PrepareToGrid(searchModel, pagedTopics, () =>
            {
                return(pagedTopics.Select(topic =>
                {
                    //fill in model values from the entity
                    var topicModel = topic.ToModel <TopicModel>();

                    //little performance optimization: ensure that "Body" is not returned
                    topicModel.Body = string.Empty;

                    topicModel.SeName = _urlRecordService.GetSeName(topic, 0, true, false);

                    if (!string.IsNullOrEmpty(topicModel.SystemName))
                    {
                        topicModel.TopicName = topicModel.SystemName;
                    }
                    else
                    {
                        topicModel.TopicName = topicModel.Title;
                    }

                    return topicModel;
                }));
            });

            return(model);
        }
        public virtual async Task <TopicListModel> PrepareTopicListModel()
        {
            var model = new TopicListModel();

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = ""
            });
            foreach (var s in await _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Shortcut, Value = s.Id.ToString()
                });
            }
            return(model);
        }
예제 #18
0
        public ActionResult List(GridCommand command, TopicListModel model)
        {
            var gridModel = new GridModel <TopicModel>();
            var topics    = _topicService.GetAllTopics(model.SearchStoreId, command.Page - 1, command.PageSize, true).AlterQuery(q =>
            {
                var q2 = q;

                if (model.SystemName.HasValue())
                {
                    q2 = q2.Where(x => x.SystemName.Contains(model.SystemName));
                }

                if (model.Title.HasValue())
                {
                    q2 = q2.Where(x => x.Title.Contains(model.Title) || x.ShortTitle.Contains(model.Title));
                }

                if (model.RenderAsWidget.HasValue)
                {
                    q2 = q2.Where(x => x.RenderAsWidget == model.RenderAsWidget.Value);
                }

                if (model.WidgetZone.HasValue())
                {
                    q2 = q2.Where(x => x.WidgetZone.Contains(model.WidgetZone));
                }

                return(q2.OrderBy(x => x.SystemName));
            });

            gridModel.Data = topics.Select(x =>
            {
                var item        = x.ToModel();
                item.WidgetZone = x.WidgetZone.SplitSafe(",");
                // Otherwise maxJsonLength could be exceeded.
                item.Body = "";
                return(item);
            });

            gridModel.Total = topics.TotalCount;

            return(new JsonResult
            {
                MaxJsonLength = int.MaxValue,
                Data = gridModel
            });
        }
예제 #19
0
        public ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var model = new TopicListModel();

            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            return(View(model));
        }
예제 #20
0
        public ActionResult List(GridCommand command, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topics    = _topicService.GetAllTopics(model.SearchStoreId);
            var gridModel = new GridModel <TopicModel>
            {
                Data  = topics.Select(x => x.ToModel()),
                Total = topics.Count
            };

            return(new JsonResult
            {
                Data = gridModel
            });
        }
예제 #21
0
        public virtual IActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var model = new TopicListModel();

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            return(View(model));
        }
예제 #22
0
        public async Task <IActionResult> TopicList(GridCommand command, TopicListModel model)
        {
            var query = _db.Topics
                        .ApplyStoreFilter(model.SearchStoreId)
                        .AsNoTracking();

            if (model.SystemName.HasValue())
            {
                query = query.Where(x => x.SystemName.Contains(model.SystemName));
            }

            if (model.Title.HasValue())
            {
                query = query.Where(x => x.Title.Contains(model.Title) || x.ShortTitle.Contains(model.Title));
            }

            if (model.RenderAsWidget.HasValue)
            {
                query = query.Where(x => x.RenderAsWidget == model.RenderAsWidget.Value);
            }

            if (model.WidgetZone.HasValue())
            {
                query = query.Where(x => x.WidgetZone.Contains(model.WidgetZone));
            }

            query = query.ApplyGridCommand(command, false);

            var topicItems = await query.ToPagedList(command.Page - 1, command.PageSize).LoadAsync();

            var gridModel = new GridModel <TopicModel>
            {
                Rows  = await topicItems.AsEnumerable().SelectAsync(async x => await PrepareTopicListModelAsync(x)).AsyncToList(),
                Total = topicItems.TotalCount
            };

            return(Json(gridModel));
        }
예제 #23
0
        /// <summary>
        /// Prepare paged topic list model
        /// </summary>
        /// <param name="searchModel">Topic search model</param>
        /// <returns>Topic list model</returns>
        public virtual TopicListModel PrepareTopicListModel(TopicSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get topics
            var topics = _topicService.GetAllTopics(showHidden: true,
                                                    storeId: searchModel.SearchStoreId,
                                                    ignorAcl: true);

            //filter topics
            //TODO: move filter to topic service
            if (!string.IsNullOrEmpty(searchModel.SearchKeywords))
            {
                topics = topics.Where(topic => (topic.Title?.Contains(searchModel.SearchKeywords) ?? false) ||
                                      (topic.Body?.Contains(searchModel.SearchKeywords) ?? false)).ToList();
            }

            //prepare grid model
            var model = new TopicListModel
            {
                Data = topics.PaginationByRequestModel(searchModel).Select(topic =>
                {
                    //fill in model values from the entity
                    var topicModel = topic.ToModel <TopicModel>();

                    //little performance optimization: ensure that "Body" is not returned
                    topicModel.Body = string.Empty;

                    return(topicModel);
                }),
                Total = topics.Count
            };

            return(model);
        }
        public ActionResult List(DataSourceRequest command, TopicListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics))
            {
                return(AccessDeniedView());
            }

            var topicModels = _topicService.GetAllTopics(model.SearchStoreId, true, true)
                              .Select(x => x.ToModel())
                              .ToList();

            //little performance optimization: ensure that "Body" is not returned
            foreach (var topic in topicModels)
            {
                topic.Body = "";
            }
            var gridModel = new DataSourceResult
            {
                Data  = topicModels,
                Total = topicModels.Count
            };

            return(Json(gridModel));
        }