Exemple #1
0
        void IJobAdsRepository.UpdateJobAdSearch(JobAdSearch search)
        {
            using (var dc = CreateContext())
            {
                var entity = GetSavedJobSearchEntity(dc, search.Id);
                if (entity == null)
                {
                    return;
                }

                // Need to delete all existing criteria.

                if (entity.JobSearchCriteriaSetEntity != null)
                {
                    if (entity.JobSearchCriteriaSetEntity.JobSearchCriteriaEntities != null && entity.JobSearchCriteriaSetEntity.JobSearchCriteriaEntities.Count > 0)
                    {
                        dc.JobSearchCriteriaEntities.DeleteAllOnSubmit(entity.JobSearchCriteriaSetEntity.JobSearchCriteriaEntities);
                    }
                    dc.JobSearchCriteriaSetEntities.DeleteOnSubmit(entity.JobSearchCriteriaSetEntity);
                }

                search.MapTo(entity, _criteriaPersister);

                try
                {
                    dc.SubmitChanges();
                }
                catch (SqlException ex)
                {
                    CheckDuplicates(ex);
                    throw;
                }
            }
        }
Exemple #2
0
        public static SavedJobSearchEntity Map(this JobAdSearch search, ICriteriaPersister criteriaPersister)
        {
            var entity = new SavedJobSearchEntity {
                id = search.Id
            };

            search.MapTo(entity, criteriaPersister);
            return(entity);
        }