private async Task <PagedResultOutput <KeyHoldingDto> > ProcessGet(GetKeyHoldingsInput input) { var query = _manager.FindKeyHoldingList(input.Sorting); if (input.CommunityId.HasValue) { query = query.Where(k => k.CommunityId == input.CommunityId.Value); } if (input.HomeOwerId.HasValue) { query = query.Where(k => k.HomeOwerId == input.HomeOwerId.Value); } var totalCount = await query.CountAsync(); var items = await query.OrderByDescending(k => k.CreationTime).PageBy(input).ToListAsync(); return(new PagedResultOutput <KeyHoldingDto>( totalCount, items.Select( item => { var dto = item.MapTo <KeyHoldingDto>(); dto.CollectionTimeString = ProcessCollectionTime(dto.CollectionTime, dto.VisiteEndTime); var community = _communityManager.CommunityRepository.Get(dto.CommunityId); dto.CommunityName = community.Name; return dto; } ).ToList() )); }
public async Task <PagedResultOutput <KeyHoldingDto> > GetKeyHoldings(GetKeyHoldingsInput input) { using (CurrentUnitOfWork.EnableFilter(AbpZeroTemplateConsts.AdminCommunityFilterClass.Name)) { using (CurrentUnitOfWork.SetFilterParameter(AbpZeroTemplateConsts.AdminCommunityFilterClass.Name, AbpZeroTemplateConsts.AdminCommunityFilterClass.ParameterName, await GetAdminCommunityIdList())) { return(await ProcessGet(input)); } } }
public async virtual Task <IHttpActionResult> GetKeyHoldings(string userName, string token, int skipCount, int maxResultCount, string sorting = null, int?tenantId = null) { base.AuthUser(); using (CurrentUnitOfWork.SetTenantId(tenantId)) { var homeOwerUser = await _homeOwerUserManager.GetHomeOwerUserByUserName(userName); if (homeOwerUser.HomeOwerId == 0) { throw ErrorCodeTypeUtils.ThrowError(ErrorCodeType.HomeOwerNotExists); } var input = new GetKeyHoldingsInput(); input.HomeOwerId = homeOwerUser.HomeOwerId; input.MaxResultCount = maxResultCount; input.SkipCount = skipCount; if (!string.IsNullOrEmpty(sorting)) { input.Sorting = sorting; } return(Ok(await _keyHoldingService.GetAllKeyHoldings(input))); } }
public async Task <PagedResultOutput <KeyHoldingDto> > GetAllKeyHoldings(GetKeyHoldingsInput input) { return(await ProcessGet(input)); }