public IActionResult List(int page, string q) { var query = _tagsManager.GetQueryable(); if (!string.IsNullOrWhiteSpace(q)) { query = query.Where(t => t.Name.Contains(q)); } var models = query.ToPagedList(page, TableListItem, s => s.Select(t => t.ToModel()).ToList()); return(View(models)); }
private async Task SetTitleAsync(string title, string keyworlds = null, string description = null, int page = 0) { var titleParts = new List <string>(); if (string.IsNullOrEmpty(title)) { titleParts.Add(_basicSettings.Title); titleParts.Add(_basicSettings.Description); } else { titleParts.Add(title); titleParts.Add(_basicSettings.Title); } if (page > 1) { titleParts.Add("Page:" + page); } if (string.IsNullOrEmpty(description)) { description = _basicSettings.Description; } //if (string.IsNullOrEmpty(title)) //{ // title = _basicSettings.Title + " | " + _basicSettings.Description; // description = _basicSettings.Description; //} //if (page > 1) // title = title + " | Page " + page; if (string.IsNullOrEmpty(keyworlds)) { var allCategoryName = await Task.FromResult(_categoryManager.GetQueryable().Select(t => t.Name).ToList()); var allTags = await Task.FromResult(_tagManager.GetQueryable().Select(t => t.Name).ToList()); keyworlds = string.Join(",", allCategoryName); } ViewData["Title"] = string.Join(" | ", titleParts.ToArray()); ViewData["KeyWorlds"] = keyworlds; ViewData["Description"] = description; }
/// <summary> /// wp.getTags method /// </summary> /// <param name="blogId">The blog id.</param> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <returns>list of tags</returns> internal async Task <List <string> > GetKeywords(string blogId, string userName, string password) { var keywords = new List <string>(); var currentUser = await GetVerifyUserAsync(userName, password); //if (!_permissionChecker.IsValid(currentUser, PermissionKeys.PostCreate)) //{ // return keywords; //} keywords.AddRange(_tagsManager.GetQueryable().Select(t => t.Name).ToList()); return(keywords); }
protected void PrepareViewModel(PostViewModel model, Post entity) { model.AllCategories = _categoryManager.GetQueryable().Select(t => t.ToModel()).ToList(); model.AllTags = _tagsManager.GetQueryable().Select(t => t.Name).ToArray(); if (entity != null) { model.SelectCategories = entity.Categories.Select(t => t.CategoryId).ToList(); if (entity.Tags != null) { // model.TagsString = string.Join(", ", entity.Tags.Select(t => t.Tags.Name).ToList()); model.SelectTags = entity.Tags.Select(t => t.Tags.Name).ToArray(); } } }
public async Task <IViewComponentResult> InvokeAsync() { var tagsList = await Task.FromResult(_tagsManager.GetQueryable()); var models = new List <TagsViewModel>(); foreach (var item in tagsList) { models.Add(new TagsViewModel() { Name = item.Name, Count = await _tagsManager.GetPostsCountAsync(item.Id), }); } return(View(models)); }
public IActionResult Index() { //var model = new DashboardViewModel() //{ // TotalPostsCount = Task.FromResult(_postManager.GetQueryable().Count()).Result, // TotalPagesCount = Task.FromResult(_pageManager.GetQueryable().Count()).Result, // TotalCategoriesCount = Task.FromResult(_categoryManager.GetQueryable().Count()).Result, // TotalTagsCount = Task.FromResult(_tagsManager.GetQueryable().Count()).Result, //}; var model = new DashboardViewModel() { TotalPostsCount = _postManager.GetQueryable().Count(), TotalPagesCount = _pageManager.GetQueryable().Count(), TotalCategoriesCount = _categoryManager.GetQueryable().Count(), TotalTagsCount = _tagsManager.GetQueryable().Count(), TotalCommentsCount = _commentManager.GetQueryable().Count(t => !t.IsDeleted), }; return(View(model)); }