public Paginated <ProfileResponseDto> Search(string uid, IEnumerable <int> skills, LocationRadius locationRadius, int page, int pageSize) { IEnumerable <int> skillsParam = null; string uidParam = null; LocationRadius locationRadiusParam = null; if (skills != null && skills.Count() > 0) { skillsParam = skills; } if (!string.IsNullOrEmpty(uid)) { uidParam = uid; } if (locationRadius != null && locationRadius.Radius > 0) { locationRadius.Validate(); locationRadiusParam = new LocationRadius() { Radius = locationRadius.Radius * 1000, Longitude = locationRadius.Longitude, Latitude = locationRadius.Latitude }; } return(_profilesRepository.Search(uidParam, skillsParam, locationRadiusParam, page, pageSize).To <ProfileResponseDto> (_profileMapper.map)); }
private Dictionary <string, string> FiltersAsStringDictionary() { Dictionary <string, string> filters = new Dictionary <string, string>(); filters.Add("term", SearchTerm); filters.Add("location", Location); filters.Add("radius", LocationRadius != 0 ? LocationRadius.ToString() : null); filters.Add("categories", Categories); return(filters); }
public static void Validate(this LocationRadius locationRadius) { if (!(locationRadius.Longitude.IsLongitude() && locationRadius.Latitude.IsLatitude())) { throw new InvalidInputException("Not correct Coordinates"); } if (locationRadius.Radius < 0 || locationRadius.Radius > MAX_RADIUS) { throw new InvalidInputException($"Maximum supported radius is {MAX_RADIUS}"); } }
public Paginated <Profile> Search(string uid, IEnumerable <int> skills, LocationRadius locationRadius, int page, int pageSize) { using (var context = _ctxFactory.Get()) { var res = context.Profiles.Include(p => p.ProfileSkills).ThenInclude(ps => ps.Skill).AsQueryable <Profile>(); if (skills != null) { res = res.Where(p => p.ProfileSkills.Where(s => skills.Contains(s.SkillID)).Count().Equals(skills.Count())); } if (!string.IsNullOrEmpty(uid)) { res = res.Where(p => p.UID.Equals(uid)); } if (locationRadius != null) { res = res.Where(p => p.Point.Distance(_geometryMapper.map(locationRadius)) <= locationRadius.Radius); } return(new Paginated <Profile>(page, pageSize, res)); } }
public Point map(LocationRadius locationRadius) { return(map(locationRadius.Latitude, locationRadius.Longitude)); }