private void PopulateCountyId(VacancyLocation entity, Entities.VacancyLocation dbVacancyLocation) { if (!string.IsNullOrWhiteSpace(entity.Address?.County)) { dbVacancyLocation.CountyId = _getOpenConnection.QueryCached <int>(_cacheDuration, @" SELECT CountyId FROM dbo.County WHERE FullName = @CountyFullName", new { CountyFullName = entity.Address.County }).SingleOrDefault(); } }
private void MapCountyId(Entities.VacancyLocation dbVacancyLocation, VacancyLocation result) { // Not all the vacancies have CountyId (before being accepted by QA). // A multilocation vacancy (more than one location) doesn't have anything in the address fields. if (dbVacancyLocation.CountyId > 0) { result.Address.County = _getOpenConnection.QueryCached <string>(_cacheDuration, @" SELECT FullName FROM dbo.County WHERE CountyId = @CountyId", new { CountyId = dbVacancyLocation.CountyId }).SingleOrDefault(); } }
private void MapLocalAuthorityCode(Entities.VacancyLocation dbVacancyLocation, VacancyLocation result) { if (dbVacancyLocation.LocalAuthorityId.HasValue) { result.LocalAuthorityCode = _getOpenConnection.QueryCached <string>(_cacheDuration, @" SELECT CodeName FROM dbo.LocalAuthority WHERE LocalAuthorityId = @LocalAuthorityId", new { dbVacancyLocation.LocalAuthorityId }).Single(); } else { result.LocalAuthorityCode = null; } }
private void PopulateLocalAuthorityId(VacancyLocation entity, Entities.VacancyLocation dbVacancyLocation) { if (!string.IsNullOrWhiteSpace(entity.LocalAuthorityCode)) { dbVacancyLocation.LocalAuthorityId = _getOpenConnection.QueryCached <int>(_cacheDuration, @" SELECT LocalAuthorityId FROM dbo.LocalAuthority WHERE CodeName = @LocalAuthorityCode", new { entity.LocalAuthorityCode }).Single(); } else { dbVacancyLocation.LocalAuthorityId = null; } }