private static SimplePredicate FilterApplicationState(ApplicationFilterDto filter) { if (filter.StateNumber == null) { return null; } return new SimplePredicate(nameof(Application.StateId), ValueComparingOperator.Equal, filter.StateNumber); }
private static SimplePredicate FilterApplicationJobOfferId(ApplicationFilterDto filter) { if (filter.JobOfferId.Equals(Guid.Empty)) { return null; } return new SimplePredicate(nameof(Application.JobOfferId), ValueComparingOperator.Equal, filter.JobOfferId); }
public async Task <ActionResult> ApplicationList(Guid jobOfferId) { var filter = new ApplicationFilterDto { JobOfferId = jobOfferId }; var result = await ApplicationFacade.GetApplicationsAsync(filter); var model = new ApplicationListModel { Filter = filter, Applications = new List <ApplicationDto>(result.Items), JobOfferId = jobOfferId }; return(View(model)); }
public async Task <ActionResult> ApplicationList() { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var filter = new ApplicationFilterDto { ApplicantId = applicant.Id }; var result = await ApplicationFacade.GetApplicationsAsync(filter); var model = new ApplicationListModel { Filter = filter, Applications = new List <ApplicationDto>(result.Items), ApplicantId = applicant.Id }; return(View(model)); }
public async Task <ActionResult> ApplicationList(ApplicationListModel model) { var filter = new ApplicationFilterDto { ApplicantId = model.ApplicantId }; if (model.State != null) { filter.StateNumber = (int)model.State; } var result = await ApplicationFacade.GetApplicationsAsync(filter); model.Applications = new List <ApplicationDto>(result.Items); return(View(model)); }
public async Task <IActionResult> GetApplicationsPackage([FromBody] ApplicationFilterDto filter) { var user = await GetUserProfile(); if (user.CoreUserDto.Access < AccessEnum.Admin) { return(Unauthorized()); } var applications = _readOnlyRepository.Table <Application, int>().ToList(); var applicationDtos = new List <ApplicationDto>(); var countryDtos = new List <CountryDto>(); var stateDtos = new List <StateDto>(); bool filtered; applications.ForEach(application => { if (countryDtos.All(dto => dto.Id != application.Country)) { //Add applications country to countryDtos as it does not yet exist var country = _readOnlyRepository.GetById <Country, int>(application.Country); var countryDto = _mapper.Map <CountryDto>(country); countryDtos.Add(countryDto); } if (application.State != 0 && stateDtos.All(dto => dto.Id != application.State)) { //Add applications state to stateDtos as it does not yet exist var state = _readOnlyRepository.GetById <State, int>(application.State); var stateDto = _mapper.Map <StateDto>(state); stateDtos.Add(stateDto); } filtered = false; if (filter.Countries != null) { if (filter.Countries.All(f => f != application.Country)) { filtered = true; } } if (!filtered && filter.States != null) { if (filter.States.All(f => f != application.State)) { filtered = true; } } if (!filtered && filter.AgeDate != default && filter.MaximumAge != 0) { //TODO age max filter } if (!filtered && filter.AgeDate != default && filter.MinimumAge != 0) { //TODO age min filter } if (!filtered) { applicationDtos.Add(_mapper.Map <ApplicationDto>(application)); } }); //Sort all lists in order of ID var applicationCount = applicationDtos.Count; applicationDtos = applicationDtos.OrderBy(a => a.Id).ToList(); countryDtos = countryDtos.OrderBy(c => c.Id).ToList(); stateDtos = stateDtos.OrderBy(s => s.Id).ToList(); //applicationDtos = applicationDtos.Skip((filter.Page - 1) * filter.ResultsPerPage).ToList(); //applicationDtos = applicationDtos.Take(filter.ResultsPerPage).ToList(); var package = new ApplicationsPackageDto { ApplicationCount = applicationCount, Applications = applicationDtos, ApplicationCountries = countryDtos, ApplicationStates = stateDtos }; return(Ok(package)); }
public async Task <IActionResult> GetDefaultFilter() { var filter = new ApplicationFilterDto(); return(Ok(filter)); }
/// <summary> /// Gets applications according to filter /// </summary> /// <returns>applications</returns> public async Task <QueryResultDto <ApplicationDto, ApplicationFilterDto> > GetApplicationsAsync(ApplicationFilterDto filter) { using (UnitOfWorkProvider.Create()) { return(await applicationService.ListApplicationsAsync(filter)); } }
protected override IQuery<Application> ApplyWhereClause(IQuery<Application> query, ApplicationFilterDto filter) { var definedPredicates = new List<IPredicate>(); AddIfDefined(FilterApplicationApplicantId(filter), definedPredicates); AddIfDefined(FilterApplicationJobOfferId(filter), definedPredicates); AddIfDefined(FilterApplicationState(filter), definedPredicates); if (definedPredicates.Count == 0) { return query; } if (definedPredicates.Count == 1) { return query.Where(definedPredicates.First()); } var wherePredicate = new CompositePredicate(definedPredicates); return query.Where(wherePredicate); }