コード例 #1
0
ファイル: CommunityService.cs プロジェクト: LeviLv/Repair
        public async Task <QueryResult <CommunityDTO> > GetList(QueryCommunityModel model)
        {
            Expression <Func <Community, bool> > func = p => true;

            if (model.AdminId.HasValue)
            {
                func = func.And(p => p.AdminId == model.AdminId);
            }

            var user = await _userRepository.GetAllAsync();

            var communityList = await _repository.PageListAsync <CommunityDTO>(func.Compile(), p => p.Id.Value, model);

            var idList  = communityList.List.Select(p => p.Id).ToList();
            var manList = await _repairManRepository.GetListAsync(p => idList.Contains(p.CommunityId));

            communityList.List.ForEach(p =>
            {
                p.AdminName     = user.FirstOrDefault(x => x.Id == p.AdminId)?.Name;
                p.RepairManName = string.Join(',', manList.Where(x => x.CommunityId == p.Id).Select(x => x.RepairManName).ToList());
            });


            return(communityList);
        }
コード例 #2
0
        public async Task <JsonResult> GetCommunityList(QueryCommunityModel pageBase)
        {
            if (loginDto.CurrentId == 9)
            {
                pageBase.AdminId = null;
            }

            var list = await _communityService.GetList(pageBase);

            return(Jsons(list));
        }