| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using static Diligent.WebAPI.Data.Entities.Applicant;
-
- namespace Diligent.WebAPI.Business.Extensions
- {
- public static class ApplicantExtensions
- {
- public static IQueryable<Applicant> FilterByExperience(this IQueryable<Applicant> query, int minExperience, int maxExperience)
- {
- if (minExperience == 0 && maxExperience == 0 || minExperience > maxExperience) return query;
- return query.Where(x => x.Experience >= minExperience && x.Experience < maxExperience);
- }
-
-
- public static IQueryable<Applicant> FilterByEmploymentType(this IQueryable<Applicant> query, string? employmentType)
- {
- if (employmentType == null) return query;
- return query.Where(x => x.TypeOfEmployment == Enum.Parse<TypesOfEmployment>(employmentType));
- }
-
- public static IQueryable<Applicant> FilterByDateOfApplication(this IQueryable<Applicant> query, DateTime? minDateOfApplication, DateTime? maxDateOfApplication)
- {
- if (minDateOfApplication == null) return query;
- if (minDateOfApplication > maxDateOfApplication) return query;
- if (maxDateOfApplication == null) return query.Where(x => x.DateOfApplication >= minDateOfApplication && x.DateOfApplication <= DateTime.Now);
- return query.Where(x => x.DateOfApplication >= minDateOfApplication && x.DateOfApplication < maxDateOfApplication);
- }
-
- public static List<Applicant> FilterByTechnologies(this List<Applicant> query, string[]? technologies)
- {
- if (technologies is null)
- {
- return query;
- }
-
- List<Applicant> filteredApplicants = new();
-
- for (int i = 0; i < query.Count; i++)
- {
- for (int j = 0; j < query[i].TechnologyApplicants.Count; j++)
- {
- bool s = false;
- for (int n = 0; n < technologies.Length; n++)
- {
- if (query[i].TechnologyApplicants[j].Technology.Name.ToLower() == technologies[n].ToLower())
- {
- s = true;
- break;
- }
- }
- if (s)
- {
- filteredApplicants.Add(query[i]);
- break;
- }
- }
- }
-
- return filteredApplicants;
- }
- }
- }
|