public async Task <PagedResultOutput <DoorDto> > GetDoors(GetDoorsInput input) { using (CurrentUnitOfWork.EnableFilter(AbpZeroTemplateConsts.AdminCommunityFilterClass.Name)) { using (CurrentUnitOfWork.SetFilterParameter(AbpZeroTemplateConsts.AdminCommunityFilterClass.Name, AbpZeroTemplateConsts.AdminCommunityFilterClass.ParameterName, await GetAdminCommunityIdList())) { var query = _manager.FindDoorList(input.Sorting); if (input.CommunityId.HasValue) { query = query.Where(d => d.CommunityId == input.CommunityId.Value); } if (input.HomeOwerId.HasValue) { var homeOwer = await _homeOwerManager.HomeOwerRepository.FirstOrDefaultAsync(input.HomeOwerId.Value); var ds = homeOwer.Doors.ToList(); var dIds = new List <long>(); ds.ForEach(d => { dIds.Add(d.Id); }); query = from d in query where dIds.Contains(d.Id) select d; } var totalCount = await query.CountAsync(); var items = await query.OrderByDescending(d => d.CreationTime).PageBy(input).ToListAsync(); return(new PagedResultOutput <DoorDto>( totalCount, items.Select( item => { var dto = item.MapTo <DoorDto>(); return dto; } ).ToList() )); } } }
public async Task <List <DoorDto> > GetAllDoors(GetDoorsInput input) { var query = _manager.FindDoorList(input.Sorting); if (input.CommunityId.HasValue) { query = query.Where(d => d.CommunityId == input.CommunityId.Value); } if (input.HomeOwerId.HasValue) { var homeOwer = await _homeOwerManager.HomeOwerRepository.FirstOrDefaultAsync(input.HomeOwerId.Value); var ds = homeOwer.Doors.ToList(); var dIds = new List <long>(); ds.ForEach(d => { dIds.Add(d.Id); }); query = from d in query where dIds.Contains(d.Id) select d; } var totalCount = await query.CountAsync(); var items = await query.OrderByDescending(d => d.CreationTime).ToListAsync(); List <DoorDto> list = new List <DoorDto>(); items.ForEach(i => { list.Add(Mapper.Map <DoorDto>(i)); }); return(list); }