private IQueryable <Employee> GetSingleActiveEmployeesSearchQuery(SearchEmployeeParameterDTO parameters) { IQueryable <Employee> query = GetBaseBuilder(parameters) .OnlyActive() .WithoutTeam() .Build(); return(query); }
public async Task <IActionResult> FilterSingleActiveEmployees([FromQuery] SearchEmployeeParameterDTO parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } parameters.CurrentUserCompanyId = (await GetCurrentUser()).CompanyId; SearchResponseDTO <EmployeeDTO> result = _service.SearchSingleActiveEmployees(parameters); return(Ok(result)); }
public SearchResponseDTO <EmployeeDTO> SearchSingleActiveEmployees(SearchEmployeeParameterDTO parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } SearchResponseDTO <Employee> result = SearchEmployeesWithQuery(parameters, GetSingleActiveEmployeesSearchQuery); return(new SearchResponseDTO <EmployeeDTO> { Items = _mapper.Map <IEnumerable <EmployeeDTO> >(result.Items).Do(employee => SetHiringRate(employee, 1)), TotalCount = result.TotalCount }); }
private IEmployeeSearchQueryBuilder GetBaseBuilder(SearchEmployeeParameterDTO parameters) { return(_queryBuilder.SetBaseEmployeesInfo(true, true) .SetFirstName(parameters.FirstName) .SetLastName(parameters.LastName) .SetPosition(_mapper.Map <Position?>(parameters.Position)) .SetProfession(_mapper.Map <Profession?>(parameters.Profession)) .SetPrimaryTechnology(_mapper.Map <Technology?>(parameters.PrimaryTechnology)) .SetCompanyId(parameters.CompanyId) .SetMyEmployees(parameters.MyEmployees, parameters.CurrentUserCompanyId) .SetTeamId(parameters.TeamId) .SetExperience(parameters.ExperienceFrom, parameters.ExperienceTo) .SetHiringHourRate( parameters.MinHiringHourRate.HasValue ? GetInitialRate(parameters.MinHiringHourRate.Value) : (decimal?)null, parameters.MaxHiringHourRate.HasValue ? GetInitialRate(parameters.MaxHiringHourRate.Value) : (decimal?)null )); }
private SearchResponseDTO <Employee> SearchEmployeesWithQuery( SearchEmployeeParameterDTO parameters, Func <SearchEmployeeParameterDTO, IQueryable <Employee> > getEmployeeFunction) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.Page.HasValue && parameters.Page.Value < 0 || parameters.PerPage.HasValue && parameters.PerPage.Value < 0) { throw new InvalidPaginationParametersException(); } IQueryable <Employee> query = getEmployeeFunction(parameters); int totalCount = query.Count(); if (parameters.Page.HasValue && parameters.Page != 0 && parameters.PerPage.HasValue) { query = query.Skip((parameters.Page.Value - 1) * parameters.PerPage.Value); } if (parameters.PerPage.HasValue) { query = query.Take(parameters.PerPage.Value); } List <Employee> employees = query.ToList(); return(new SearchResponseDTO <Employee> { Items = employees, TotalCount = totalCount }); }
private IQueryable <Employee> GetEmployeesSearchQuery(SearchEmployeeParameterDTO parameters) { IQueryable <Employee> query = GetBaseBuilder(parameters).Build(); return(query); }