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)); }
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)); }
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 }); }
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)); }
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)); }
/// <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)); }
public IActionResult List() { var model = new TopicListModel { IsSingleStoreMode = _storeContext.IsSingleStoreMode() }; return(View(model)); }
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 }); }
public IActionResult List() { TopicListModel model = new TopicListModel() { Apps = AppSvc.LoadApps().ToList(), Exchanges = TopicSvc.LoadExchanges().ToList() }; return(View(model)); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics)) { return(AccessDeniedView()); } var model = new TopicListModel(); return(View(model)); }
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)); }
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); }
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)); }
/// <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); }
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 }); }
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)); }
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 }); }
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)); }
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)); }
/// <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)); }