Example #1
0
        public async Task <JsonResult> GetRepairList(QueryRepairListModel pageBase)
        {
            pageBase.AdminId = loginDto.CurrentId;
            var list = await _repairListService.PageRepairList(pageBase);

            return(Jsons(list));
        }
Example #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);
        }