Exemple #1
0
        public async Task <QueryResult <RepairManDTO> > GetRepairManList(QueryRepairManModel pageBase)
        {
            var sql = "select u.* from Community c right join Users u on c.RepairManId = u.Id where u.IsAdmin = 0 and u.IsRepairMan = 1 ";

            if (!string.IsNullOrWhiteSpace(pageBase.mobile))
            {
                sql += $" and u.mobile = '{pageBase.mobile}' ";
            }

            if (pageBase.communnityId.HasValue)
            {
                sql += $" and c.id = {pageBase.communnityId.Value} ";
            }

            var list = await DapperService.PageList <RepairManDTO>(sql, pageBase, "group by u.id");

            var commList = await _communityService.GetAllAsync();

            list.List.ForEach(p =>
            {
                var nameList    = commList.Where(x => x.RepairManId == p.Id).Select(x => x.Name).ToList();
                p.CommunityName = string.Join(",", nameList);
                p.AdminName     = commList.FirstOrDefault(x => x.AdminId == p.Id)?.Name;
            });
            return(list);
        }
Exemple #2
0
        public async Task <QueryResult <RepairListDTO> > PageRepairList(QueryRepairListModel pageBase)
        {
            var sql = @"select 
                    r.*,
                    c.`Name` as CommunityName,
                    (select name from Users where id = r.RepairManId) as RepairManName
                    from 
                    Community c 
                    join RepairList r on r.CommunityId = c.Id where 1=1 ";

            if (pageBase.AdminId.HasValue)
            {
                sql += $" and c.AdminId = {pageBase.AdminId.Value} ";
            }

            if (pageBase.StatusEnum.HasValue)
            {
                sql += $" and r.status = {pageBase.StatusEnum.Value} ";
            }

            var list = await DapperService.PageList <RepairListDTO>(sql, pageBase);

            var user = await _userRepository.GetAllAsync();

            list.List.ForEach(p =>
            {
                p.statusName = ((RepairStatusEnum)p.Status).GetDisplayName();
                p.User       = user.FirstOrDefault(x => x.Id == p.UserId);
            });

            return(list);
        }
Exemple #3
0
        public async Task <QueryResult <User> > GetUserList2(QueryUserModel pageBase)
        {
            var comm = await _communityService.FirstOrDefult(p => p.AdminId == pageBase.AdminId);

            var sql = $" SELECT u.* from RepairMan r RIGHT JOIN Users u ON u.Id = r.UserId where r.CommunityId = {comm.Id} ";

            var list = await DapperService.PageList <User>(sql, pageBase);

            return(list);
        }
Exemple #4
0
        public async Task <QueryResult <User> > GetAllRepair(QueryUserModel pageBase)
        {
            var comm = await _communityService.FirstOrDefult(p => p.AdminId == pageBase.AdminId);

            var sql = $" SELECT * FROM Users WHERE IsRepairMan = 1 ";

            var list = await DapperService.PageList <User>(sql, pageBase);

            return(list);
        }
Exemple #5
0
        public async Task <QueryResult <RepairManDTO> > GetAllRepairManList(QueryRepairManModel pageBase)
        {
            var sql = $" SELECT * from Users where IsRepairMan = 1 ";

            if (!string.IsNullOrWhiteSpace(pageBase.mobile))
            {
                sql += $" and Mobile = '{pageBase.mobile}' ";
            }

            var list = await DapperService.PageList <RepairManDTO>(sql, pageBase);

            var commList = await _repairManRepository.GetAllAsync();

            list.List.ForEach(p =>
            {
                p.CommunityName = string.Join(',', commList.Where(x => x.UserId == p.Id).Select(x => x.CommunityName).ToList());
            });
            return(list);
        }