public DepartmentWithUsersSpecification(DepartmentSpecParams departmentParams)
            : base(x => (string.IsNullOrEmpty(departmentParams.Search) || x.Name.ToLower().Contains(departmentParams.Search)))
        {
            AddInclude(x => x.Users);
            ApplyPaging(departmentParams.PageSize * (departmentParams.PageIndex - 1), departmentParams.PageSize);


            if (!string.IsNullOrEmpty(departmentParams.Sort))
            {
                switch (departmentParams.Sort)
                {
                case "nameAsc":
                    AddOrderBy(p => p.Name);
                    break;

                case "nameDesc":
                    AddOrderByDescending(p => p.Name);
                    break;

                default:
                    AddOrderBy(n => n.Name);
                    break;
                }
            }
        }
Beispiel #2
0
 public DepartmentWithUsersCountSpecification(DepartmentSpecParams departmentParams) : base(x =>
                                                                                            (string.IsNullOrEmpty(departmentParams.Search) || x.Name.ToLower().Contains(departmentParams.Search)))
 {
 }