Пример #1
0
        public UsersWithAddressSpecification(UsersSpecParams usersParams) : base(x =>
                                                                                 (string.IsNullOrEmpty(usersParams.Search) || x.DisplayName.ToLower().Contains(usersParams.Search))
                                                                                 )
        {
            AddInclude(x => x.Address);
            AddOrderBy(x => x.DisplayName);
            ApplyPaging(usersParams.PageSize * (usersParams.PageIndex - 1), usersParams.PageSize);

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

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

                default:
                    AddOrderBy(n => n.Email);
                    break;
                }
            }
        }
Пример #2
0
 public UsersWithFiltersForCountSpecification(UsersSpecParams usersParams)  : base(x =>
                                                                                   (string.IsNullOrEmpty(usersParams.Search) || x.DisplayName.ToLower().Contains(usersParams.Search)))
 {
 }