| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Diligent.WebAPI.Business.Extensions
- {
- public static class AdExtensions
- {
- public static IQueryable<Ad> FilterByExperience(this IQueryable<Ad> query, int minExperience, int maxExperience) =>
- minExperience >= maxExperience ? query.Where(x => x.MinimumExperience >= minExperience && x.MinimumExperience <= maxExperience)
- : query.Where(x => x.MinimumExperience >= minExperience && x.MinimumExperience <= maxExperience);
- public static IQueryable<Ad> FilterByWorkType(this IQueryable<Ad> query, string workHour) =>
- workHour.ToLower() == "parttime" ? query.Where(x => x.WorkHour == WorkHours.PartTime) : query.Where(x => x.WorkHour == WorkHours.FullTime);
- public static IQueryable<Ad> FilterByEmploymentType(this IQueryable<Ad> query, string employmentType) =>
- employmentType.ToLower() == "intership" ? query.Where(x => x.EmploymentType == EmploymentTypes.Intership) : query.Where(x => x.EmploymentType == EmploymentTypes.Work);
-
- public static List<Ad> FilterByTechnologies(this List<Ad> query, string[] technologies)
- {
- if (technologies.Length == 0)
- {
- return query;
- }
-
- List<Ad> filteredAds = new List<Ad>();
-
- for (int i = 0; i < query.Count(); i++)
- {
- for (int j = 0; j < query[i].Technologies.Count(); j++)
- {
- var s = 0;
-
- for (int k = 0; k < technologies.Length; k++)
- {
- if (query[i].Technologies[j].Name.ToLower() == technologies[k].ToLower())
- {
- s = 1;
- }
- }
-
- if (s == 1)
- {
- filteredAds.Add(query[i]);
- break;
- }
- }
- }
-
- return filteredAds;
- }
- }
- }
|