private IQueryable <Location> CreateGetLikeLocationsQuery(EcaLocation location) { //A note here, you can't simply look for locations by name and type i.e. a city named franklin, //there are already over 30 cities named frankling; therefore, you have to look for a location with //its parent locations if they are known also, so the city Franklin, in Tennessee, in the US. var query = this.Context.Locations.Select(x => x); var locationType = LocationType.GetStaticLookup(location.LocationTypeId); Contract.Assert(locationType != LocationType.Address, "An address should only be created through the address location methods."); if (locationType == LocationType.Building || locationType == LocationType.Place) { if (location.CityId.HasValue) { query = query.Where(x => x.CityId == location.CityId); } } if (location.DivisionId.HasValue) { query = query.Where(x => x.DivisionId == location.DivisionId); } if (location.CountryId.HasValue) { query = query.Where(x => x.CountryId == location.CountryId); } query = query.Where(x => x.LocationName != null && x.LocationName.Trim().ToLower() == location.LocationName.Trim().ToLower()); return(query); }
/// <summary> /// Creates a new LocationValidationEntity. /// </summary> /// <param name="location">The location containing new or updated location details.</param> /// <param name="contextCountry">The country the location belongs to.</param> /// <param name="contextDivision">The division the location belongs to.</param> /// <param name="contextCity">The city the location belongs to.</param> /// <param name="contextRegion">The region the location belongs to.</param> public LocationValidationEntity(EcaLocation location, Location contextRegion, Location contextCountry, Location contextDivision, Location contextCity) { this.LocationName = location.LocationName; this.LocationTypeId = location.LocationTypeId; this.Latitude = location.Latitude; this.Longitude = location.Longitude; this.Country = contextCountry; this.Division = contextDivision; this.City = contextCity; this.Region = contextRegion; }
private LocationValidationEntity GetLocationValidationEntity(EcaLocation location, Location region, Location country, Location division, Location city) { return(new LocationValidationEntity(location, region, country, division, city)); }