Ejemplo n.º 1
0
        public async Task <PagedResultDto <ProjectDto> > GetProjects(BasePagedAndSortedResultRequestDto filter)
        {
            PagedResultDto <ProjectDto> result;

            // 默认开启租户过滤,所以不在展示
            using (DataFilter.Enable <ISoftDelete>())
            {
                var target = (await ProjectRepository.GetListAsync()).WhereIf(!filter.Filter.IsNullOrWhiteSpace(), t => t.Name.Contains(filter.Filter));
                // 排序
                target = !string.IsNullOrEmpty(filter.Sorting) ? target.OrderBy(c => filter.Sorting) : target.OrderByDescending(t => t.CreationTime);
                var count       = target.Count();
                var projectList = target.Skip(filter.SkipCount).Take(filter.MaxResultCount).ToList();
                result = new PagedResultDto <ProjectDto>(count, ObjectMapper.Map <IList <Projects.Project>, List <ProjectDto> >(projectList));
                return(result);
            }
        }
Ejemplo n.º 2
0
        public async Task <ServiceResult> GetProjects([FromQuery] BasePagedAndSortedResultRequestDto filter)
        {
            var project = await ProjectService.GetProjects(filter);

            return(await ServiceResult <IList <ProjectDto> > .PageList(project.Items.ToList(), project.TotalCount, string.Empty));
        }