private void PopulateCountyId(DomainEmployer entity, Employer 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();
            }
        }
        public DomainEmployer Save(DomainEmployer employer)
        {
            var dbEmployer = _mapper.Map <DomainEmployer, Employer>(employer);

            PopulateCountyId(employer, dbEmployer);

            if (dbEmployer.EmployerId == 0)
            {
                dbEmployer.EmployerStatusTypeId = 1;
                dbEmployer.EmployerId           = (int)_getOpenConnection.Insert(dbEmployer);
            }
            else
            {
                const string sql = "SELECT * FROM dbo.Employer WHERE EmployerId = @EmployerId";

                var sqlParams = new
                {
                    dbEmployer.EmployerId
                };

                var existingEmployer = _getOpenConnection.Query <Employer>(sql, sqlParams).Single();

                dbEmployer.CountyId                  = existingEmployer.CountyId;
                dbEmployer.LocalAuthorityId          = existingEmployer.LocalAuthorityId;
                dbEmployer.GeocodeEasting            = existingEmployer.GeocodeEasting;
                dbEmployer.GeocodeNorthing           = existingEmployer.GeocodeNorthing;
                dbEmployer.PrimaryContact            = existingEmployer.PrimaryContact;
                dbEmployer.NumberofEmployeesAtSite   = existingEmployer.NumberofEmployeesAtSite;
                dbEmployer.NumberOfEmployeesInGroup  = existingEmployer.NumberOfEmployeesInGroup;
                dbEmployer.OwnerOrgnistaion          = existingEmployer.OwnerOrgnistaion;
                dbEmployer.CompanyRegistrationNumber = existingEmployer.CompanyRegistrationNumber;
                dbEmployer.TotalVacanciesPosted      = existingEmployer.TotalVacanciesPosted;
                dbEmployer.BeingSupportedBy          = existingEmployer.BeingSupportedBy;
                dbEmployer.LockedForSupportUntil     = existingEmployer.LockedForSupportUntil;
                dbEmployer.DisableAllowed            = existingEmployer.DisableAllowed;
                dbEmployer.TrackingAllowed           = existingEmployer.TrackingAllowed;

                _getOpenConnection.UpdateSingle(dbEmployer);
            }

            return(GetById(dbEmployer.EmployerId));
        }