private bool HasGeoLocation(SavedSearch savedSearch) { if (!savedSearch.HasGeoPoint()) { var locations = _locationSearchService.FindLocation(savedSearch.Location); var locationsList = locations == null ? new List <Location>() : locations.ToList(); if (locationsList.Any()) { var location = locationsList.First(); _logService.Info("Location {0} specified in saved search with id {1} was identified as {2}", savedSearch.Location, savedSearch.EntityId, location.Name); savedSearch.Location = location.Name; savedSearch.Latitude = location.GeoPoint.Latitude; savedSearch.Longitude = location.GeoPoint.Longitude; savedSearch.Hash = savedSearch.GetLatLonLocHash(); //Update saved search now we know the lat/long/hash _savedSearchWriteRepository.Save(savedSearch); } else { _logService.Info("Location {0} specified in saved search with id {1} could not be found", savedSearch.Location, savedSearch.EntityId); return(false); } } return(true); }
public SavedSearch Build() { var savedSearch = new SavedSearch { EntityId = Guid.NewGuid(), SearchMode = _searchMode, Keywords = _keywords, Location = _location, Latitude = _latitude, Longitude = _longitude, WithinDistance = _withinDistance, ApprenticeshipLevel = _apprenticeshipLevel, Category = _category, CategoryFullName = _categoryFullName, SubCategories = _subCategories, SubCategoriesFullName = _subCategoriesFullNames, SearchField = _searchField, AlertsEnabled = _alertsEnabled }; if (savedSearch.HasGeoPoint()) { savedSearch.Hash = savedSearch.GetLatLonLocHash(); } return(savedSearch); }