public async Task <PagedResultDto <BlogDto> > GetAllBlogsByPageAsync(PagedAndFilteredInputDto input) { PermissionChecker.Authorize(PermissionNames.Page_Blog); var em = AbpSession.GetUserEmail(); int totalCount = 0; List <Blog> list = new List <Blog>(); List <BlogDto> listDto = new List <BlogDto>(); var query = this._blogRepository.GetAll(); if (string.IsNullOrEmpty(input.Filter)) { if (input.From.HasValue && input.To.HasValue) { query = this._blogRepository.GetAll().Include("BlogTags").Where(p => p.CreatorUserId == AbpSession.UserId && ((p.CreationTime >= input.From && p.CreationTime <= input.To) || (p.LastModificationTime >= input.From && p.LastModificationTime <= input.To))); } else { query = this._blogRepository.GetAll().Include("BlogTags").Where(p => p.CreatorUserId == AbpSession.UserId); } } else { query = this._blogRepository.GetAll().Include("BlogTags").Where(p => p.CreatorUserId == AbpSession.UserId && (p.Title.Contains(input.Filter) || p.Content.Contains(input.Filter) || p.KeyWords.Contains(input.Filter) || p.Summary.Contains(input.Filter))); if (input.From.HasValue && input.To.HasValue) { query = query.Where(p => (p.CreationTime >= input.From && p.CreationTime <= input.To) || (p.LastModificationTime >= input.From && p.LastModificationTime <= input.To)); } } totalCount = await query.CountAsync(); list = await query.PageBy <Blog>(input).ToListAsync(); listDto = Mapper.Map <List <BlogDto> >(list); foreach (var iObj in list) { if (iObj.BlogTags != null && iObj.BlogTags.Count > 0) { var obj = listDto.FirstOrDefault(p => p.Id == iObj.Id); obj.SelectTags.AddRange(iObj.BlogTags.Select(p => p.TagId)); } } var resultList = new PagedResultDto <BlogDto>(totalCount, listDto); return(resultList); }