Пример #1
0
        public override IQueryable <T> Filtering(IQueryable <T> query, Sungero.Domain.FilteringEventArgs e)
        {
            if (_filter == null)
            {
                return(query);
            }

            if (_filter.Active || _filter.Closed)
            {
                query = query.Where(r => _filter.Active && r.Status == Status.Active ||
                                    _filter.Closed && r.Status == Status.Closed);
            }

            if (_filter.JobTitle != null)
            {
                query = query.Where(r => Equals(r.JobTitle, _filter.JobTitle));
            }

            if (_filter.Department != null)
            {
                var employees = Departments.GetAllUsersInGroup(_filter.Department).ToList();
                query = query.Where(r => employees.Contains(r));
            }

            if (_filter.BusinessUnit != null)
            {
                var employees = Company.BusinessUnits.GetAllUsersInGroup(_filter.BusinessUnit).ToList();
                query = query.Where(r => employees.Contains(r));
            }

            return(query);
        }