public virtual TopicCategoryListModel PrepareTopicCategoryListModel(TopicSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get topics var topicCategories = _topicService.GetAllTopicCategories(); //filter topics //TODO: move filter to topic service if (!string.IsNullOrEmpty(searchModel.SearchKeywords)) { topicCategories = topicCategories.Where(topic => topic.Name?.ToLower()?.Contains(searchModel.SearchKeywords.ToLower()) ?? false).ToList(); } //prepare grid model var model = new TopicCategoryListModel { Data = topicCategories.PaginationByRequestModel(searchModel).Select(topicCategory => { var topicModel = topicCategory.ToModel <TopicCategoryModel>(); return(topicModel); }), Total = topicCategories.Count }; return(model); }
public virtual IActionResult List(TopicSearchModel searchModel) { //prepare model TopicListModel model = _topicModelFactory.PrepareTopicListModel(searchModel); return(Json(model)); }
public virtual IActionResult List() { //prepare model TopicSearchModel model = _topicModelFactory.PrepareTopicSearchModel(new TopicSearchModel()); return(View(model)); }
/// <summary> /// Prepare topic search model /// </summary> /// <param name="searchModel">Topic search model</param> /// <returns>Topic search model</returns> public virtual TopicSearchModel PrepareTopicSearchModel(TopicSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
public virtual IActionResult List(TopicSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics)) { return(AccessDeniedKendoGridJson()); } //prepare model var model = _topicModelFactory.PrepareTopicListModel(searchModel); return(Json(model)); }
public virtual async Task <IActionResult> List(TopicSearchModel searchModel) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTopics)) { return(await AccessDeniedDataTablesJson()); } //prepare model var model = await _topicModelFactory.PrepareTopicListModelAsync(searchModel); return(Json(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); }
/// <summary> /// Prepare topic search model /// </summary> /// <param name="searchModel">Topic search model</param> /// <returns>Topic search model</returns> public virtual TopicSearchModel PrepareTopicSearchModel(TopicSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare available stores _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
/// <summary> /// Prepare topic search model /// </summary> /// <param name="searchModel">Topic search model</param> /// <returns>Topic search model</returns> public virtual TopicSearchModel PrepareTopicSearchModel(TopicSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare available stores _baseAdminModelFactory.PrepareStores(searchModel.AvailableStores); searchModel.HideStoresList = _catalogSettings.IgnoreStoreLimitations || searchModel.AvailableStores.SelectionIsNotPossible(); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
/// <summary> /// Prepare paged topic list model /// </summary> /// <param name="searchModel">Topic search model</param> /// <returns>Topic list model</returns> public virtual async Task <TopicListModel> PrepareTopicListModelAsync(TopicSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get topics var topics = await _topicService.GetAllTopicsAsync(showHidden : true, keywords : searchModel.SearchKeywords, storeId : searchModel.SearchStoreId, ignoreAcl : true); var pagedTopics = topics.ToPagedList(searchModel); //prepare grid model var model = await new TopicListModel().PrepareToGridAsync(searchModel, pagedTopics, () => { return(pagedTopics.SelectAwait(async 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 = await _urlRecordService.GetSeNameAsync(topic, 0, true, false); if (!string.IsNullOrEmpty(topicModel.SystemName)) { topicModel.TopicName = topicModel.SystemName; } else { topicModel.TopicName = topicModel.Title; } return topicModel; })); }); return(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(); } //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); }