public virtual IActionResult TopicTemplates(TopicTemplateSearchModel searchModel) { //prepare model TopicTemplateListModel model = _templateModelFactory.PrepareTopicTemplateListModel(searchModel); return(Json(model)); }
/// <summary> /// Prepare paged topic template list model /// </summary> /// <param name="searchModel">Topic template search model</param> /// <returns>Topic template list model</returns> public virtual TopicTemplateListModel PrepareTopicTemplateListModel(TopicTemplateSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get topic templates var topicTemplates = _topicTemplateService.GetAllTopicTemplates().ToPagedList(searchModel); //prepare grid model var model = new TopicTemplateListModel().PrepareToGrid(searchModel, topicTemplates, () => topicTemplates.Select(template => template.ToModel <TopicTemplateModel>())); return(model); }
/// <summary> /// Prepare paged topic template list model /// </summary> /// <param name="searchModel">Topic template search model</param> /// <returns>Topic template list model</returns> public virtual TopicTemplateListModel PrepareTopicTemplateListModel(TopicTemplateSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get topic templates var topicTemplates = _topicTemplateService.GetAllTopicTemplates(); //prepare grid model var model = new TopicTemplateListModel { //fill in model values from the entity Data = topicTemplates.PaginationByRequestModel(searchModel).Select(template => template.ToModel <TopicTemplateModel>()), Total = topicTemplates.Count }; return(model); }