예제 #1
0
		public IPagedList<ClientUser> GetClientUsersListByFilter(ClientUserFilter filter)
		{
			if (filter == null) throw new ArgumentNullException("filter");

			Expression<Func<ClientUser, bool>> where = PredicateBuilder.True<ClientUser>();
			if (!String.IsNullOrWhiteSpace(filter.LastName))
			{
				where = where.AndAlso(cu => cu.User.LastName.Contains(filter.LastName.Trim()));
			}
			if (filter.RoleId.HasValue)
			{
				where = where.AndAlso(cu => cu.User.Roles.Any(r => r.Id == filter.RoleId));
			}
			if (filter.Status.HasValue)
			{
				string status = filter.Status.ToString();
				where = where.AndAlso(cu => cu.StatusId == status);
			}
			if (!String.IsNullOrEmpty(filter.Email))
			{
				where = where.AndAlso(cu => cu.User.Email == filter.Email);
			}

			Func<IQueryable<ClientUser>, IOrderedQueryable<ClientUser>> orderBy = null;

			if (filter.IsAscending)
			{
				switch (filter.NameOfSortColumn)
				{
					case ClientFilterColumns.FirstName:
						orderBy = i => i.OrderBy(x => x.User.FirstName);
						break;
					case ClientFilterColumns.LastNameSort:
						orderBy = i => i.OrderBy(x => x.User.LastName);
						break;
					case ClientFilterColumns.Role:
						orderBy = i => i.OrderBy(x => x.User.Roles.FirstOrDefault().DisplayName);
						break;
					case ClientFilterColumns.Status:
						orderBy = i => i.OrderBy(x => x.StatusId);
						break;
					default:
						throw new NotSupportedException("Unknow Column Name");
				}
			}
			else
			{
				switch (filter.NameOfSortColumn)
				{
					case ClientFilterColumns.FirstName:
						orderBy = i => i.OrderByDescending(x => x.User.FirstName);
						break;
					case ClientFilterColumns.LastNameSort:
						orderBy = i => i.OrderByDescending(x => x.User.LastName);
						break;
					case ClientFilterColumns.Role:
						orderBy = i => i.OrderByDescending(x => x.User.Roles.FirstOrDefault().DisplayName);
						break;
					case ClientFilterColumns.Status:
						orderBy = i => i.OrderByDescending(x => x.StatusId);
						break;
					default:
						throw new NotSupportedException("Unknow Column Name");
				}
			}
			return _clientUserRepository.GetPaged(where, orderBy);
		}
예제 #2
0
		public ClientUsersListViewModel GetClientUsersListByFilter(ClientUserFilter filter)
		{
			if (filter == null) throw new ArgumentNullException("filter");

			var result = new ClientUsersListViewModel();

			result.ClientUsers = _clientUserManager.GetClientUsersListByFilter(filter);
			result.Filter = filter;

			return result;
		}
예제 #3
0
		private ClientUserFilter GetClientUserFilter()
		{
			var filter = new ClientUserFilter();
			filter.LastName = "test";
			filter.RoleId = (int)RoleType.SuperUser;
			filter.Status = ClientUserStatus.Active;

			return filter;
		}