private async Task <PagedResultOutput <ContentDto> > PrecessGet(GetContentsInput input) { var query = (IQueryable <Content>) from c in _contentManager.ContentRepository.GetAll() orderby input.Sorting select c; if (input.ChannelId.HasValue && input.ChannelId.Value > 0) { query = query.Where(r => r.ChannelId == input.ChannelId.Value); } if (input.SelectTypes.Count > 0) { query = query.Where(r => (input.SelectTypes.Contains(0) && r.IsRecommend) || (input.SelectTypes.Contains(1) && r.IsTop) || (input.SelectTypes.Contains(2) && r.IsColor) || (input.SelectTypes.Contains(3) && r.IsHot)); } var totalCount = await query.CountAsync(); var items = await query.OrderByDescending(r => r.CreationTime).PageBy(input).ToListAsync(); return(new PagedResultOutput <ContentDto>( totalCount, items.Select( item => { var dto = item.MapTo <ContentDto>(); if (!string.IsNullOrEmpty(dto.ImageUrl)) { dto.ImageUrl = PageUtils.AddProtocolToUrl(PageUtils.ParseNavigationUrl(PathUtils.AddVirtualToPath(PageUtils.GetUrlWithAppDir(item.App, dto.ImageUrl)), HttpContext.Current.Request.Url.Host)).Replace("\\", "/"); } if (!string.IsNullOrEmpty(dto.FileUrl)) { dto.FileUrl = PageUtils.AddProtocolToUrl(PageUtils.ParseNavigationUrl(PathUtils.AddVirtualToPath(PageUtils.GetUrlWithAppDir(item.App, dto.FileUrl)), HttpContext.Current.Request.Url.Host)).Replace("\\", "/"); } if (!string.IsNullOrEmpty(dto.VideoUrl)) { dto.VideoUrl = PageUtils.AddProtocolToUrl(PageUtils.ParseNavigationUrl(PathUtils.AddVirtualToPath(PageUtils.GetUrlWithAppDir(item.App, dto.VideoUrl)), HttpContext.Current.Request.Url.Host)).Replace("\\", "/"); } return dto; } ).ToList() )); }