Exemplo n.º 1
0
 public IEnumerable<UserDetailsModel> Get(
     UserSearchCriteriaModel criteria = null, bool includeIssues = false)
 {
     return Service<UserService>().GetUserDetails(criteria, includeIssues);
 }
Exemplo n.º 2
0
 public IEnumerable<UserSummaryModel> Summary(UserSearchCriteriaModel criteria = null)
 {
     return Service<UserService>().GetUserSummaries(criteria);
 }
Exemplo n.º 3
0
 public IList<UserDetailsModel> GetUserDetails(
     UserSearchCriteriaModel criteria = null, bool includeIssues = false)
 {
     return Search(criteria).Select(u => BuildUserDetails(u, includeIssues)).ToList();
 }
Exemplo n.º 4
0
 public IList<UserSummaryModel> GetUserSummaries(UserSearchCriteriaModel criteria = null)
 {
     return Search(criteria).Select(Map<UserSummaryModel>).ToList();
 }
Exemplo n.º 5
0
        IList<User> Search(UserSearchCriteriaModel criteria)
        {
            if (criteria == null) criteria = new UserSearchCriteriaModel();

            var users = Repo<User>().Find(u => u.IsDeleted != true);

            if (criteria.UserRoleId.HasValue)
                users = users.Where(u => u.UserRoleId == criteria.UserRoleId.Value);

            if (criteria.MultiColumnSearch == null)
            {
                if (criteria.UserNameSearch != null)
                    users = users.Where(u => u.UserName.Contains(criteria.UserNameSearch));
                if (criteria.FirstSearch != null)
                    users = users.Where(u => u.First.Contains(criteria.FirstSearch));
                if (criteria.LastSearch != null)
                    users = users.Where(u => u.Last.Contains(criteria.LastSearch));
                if (criteria.EmailSearch != null)
                    users = users.Where(u => u.Email.Contains(criteria.EmailSearch));
            }
            else
            {
                users = users.Where(u => u.UserName.Contains(criteria.MultiColumnSearch) ||
                    u.First.Contains(criteria.MultiColumnSearch) ||
                    u.Last.Contains(criteria.MultiColumnSearch) ||
                    u.Email.Contains(criteria.MultiColumnSearch));
            }

            if (criteria.SortField == "First") users = users.OrderBy(u => u.First);
            else if (criteria.SortField == "Last") users = users.OrderBy(u => u.Last);
            else if (criteria.SortField == "Email") users = users.OrderBy(u => u.Email);
            else users = users.OrderBy(u => u.UserName);

            return users.Skip(criteria.Skip ?? 0).Take(criteria.Take ?? 10).ToList();
        }