瀏覽代碼

HiddenFilter

zinab_elgendy 6 月之前
父節點
當前提交
ec7dbe5122

+ 33 - 0
MTWorkHR.Application/Services/Task/ProjectService.cs

@@ -13,6 +13,7 @@ using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Core.Email;
 using MTWorkHR.Core.Entities;
 using MTWorkHR.Infrastructure.UnitOfWorks;
+using System.Linq.Dynamic.Core;
 
 namespace MTWorkHR.Application.Services
 {
@@ -84,6 +85,38 @@ namespace MTWorkHR.Application.Services
             var response = Mapper.MapperObject.Mapper.Map<ProjectDto>(entity);
             return response;
         }
+        public override async Task<PagingResultDto<ProjectDto>> GetAll(PagingInputDto PagingInputDto)
+        {
+            var res = await _unitOfWork.Project.GetAllWithChildrenAsync();
+            var query = res.Item1;
+           
+            if (PagingInputDto.HiddenFilter != null)
+            {
+                query = query.Where(PagingInputDto.HiddenFilter);
+            }
+            if (PagingInputDto.Filter != null)
+            {
+                var filter = PagingInputDto.Filter;
+                query = query.Where(u => u.NameAr.Contains(filter));
+            }
+
+            var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
+
+            var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
+
+            var total = await query.CountAsync();
+
+            var list = MapperObject.Mapper
+                .Map<IList<ProjectDto>>(await page.ToListAsync());
+
+            var response = new PagingResultDto<ProjectDto>
+            {
+                Result = list,
+                Total = total
+            };
+
+            return response;
+        }
 
     }
 }

+ 5 - 0
MTWorkHR.Application/Services/Task/UserTaskService.cs

@@ -7,6 +7,7 @@ using MTWorkHR.Application.Mapper;
 using MTWorkHR.Core.Global;
 using Microsoft.EntityFrameworkCore;
 using System.Linq.Dynamic.Core;
+using MTWorkHR.Core.IDto;
 
 namespace MTWorkHR.Application.Services
 {
@@ -49,6 +50,10 @@ namespace MTWorkHR.Application.Services
                 query = query.Where(m => m.AssignedUserId == _globalInfo.UserId);
 
             }
+            if (PagingInputDto.HiddenFilter != null)
+            {
+                query = query.Where(PagingInputDto.HiddenFilter);
+            }
             if (PagingInputDto.Filter != null)
             {
                 var filter = PagingInputDto.Filter;