public async Task <IHttpActionResult> GetAllUsers([FromUri] UserFilterBindingModel filter)
        {
            var users = await UserManager.FilterUsers(filter);

            var filteredCount = await UserManager.Users.FilteredCountAsync(filter);

            var result = CollectionResponseDto <UserDto, User> .Create(users, UserDto.CreateFromModel, filteredCount);

            return(Ok(result));
        }
        public async Task <IHttpActionResult> GetAllDepartments([FromUri] DepartmentFilterBindingModel filter)
        {
            var departments = await DepartmentsService.Instance.Query().FilterQuery(filter).ToListAsync();

            var filteredCount = await DepartmentsService.Instance.Query().FilteredCountAsync(filter);

            var result = CollectionResponseDto <DepartmentDto, DepartmentExtended> .Create(departments.SelectExtended(),
                                                                                           DepartmentDto.CreateFromModel, filteredCount);

            return(Ok(result));
        }
        public async Task <IHttpActionResult> GetAllMatches([FromUri] UserQueriesBindingModel queries)
        {
            var filter = new UserFilter();

            if (queries != null && queries.FieldsQueries != null && queries.FieldsQueries.Any())
            {
                filter = queries.FieldsQueries.Aggregate(filter,
                                                         (current, query) => UserFilter.CreateFromUserQuery(query, current));
            }
            else
            {
                return(Ok(ResponseDto <UserMatchDto> .NotFound()));
            }

            var users = await UserManager.FilterUsers(filter);

            var result = CollectionResponseDto <UserMatchDto, User> .Create(users, user => UserMatchDto.CreateFromModel(user, queries.FieldsQueries), users.Count);

            return(Ok(result));
        }
        public async Task <IHttpActionResult> GetAllMatches([FromUri] DepartmentQueriesBindingModel queries)
        {
            var filter = new DepartmentFilter();

            if (queries != null && queries.FieldsQueries != null && queries.FieldsQueries.Any())
            {
                filter = queries.FieldsQueries.Aggregate(filter,
                                                         (current, query) => DepartmentFilter.CreateFromDepartmentQuery(query, current));
            }
            else
            {
                return(Ok(ResponseDto <DepartmentMatchDto> .NotFound()));
            }

            var departments = await DepartmentsService.Instance.Query().FilterQuery(filter).ToListAsync();

            var result = CollectionResponseDto <DepartmentMatchDto, DepartmentExtended> .Create(departments.SelectExtended(),
                                                                                                user => DepartmentMatchDto.CreateFromModel(user, queries.FieldsQueries), departments.Count);

            return(Ok(result));
        }