예제 #1
0
        private JobAd CreateJobAd(IEmployer employer, DateTime lastUpdatedTime, DateTime?modifiedTime)
        {
            var jobAd = _jobAdsCommand.PostTestJobAd(employer);

            jobAd.CreatedTime     = lastUpdatedTime;
            jobAd.LastUpdatedTime = lastUpdatedTime;
            _jobAdsRepository.UpdateJobAd(jobAd);

            // Delete what is already there.

            using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
            {
                var entity = (from i in dc.JobAdIndexingEntities where i.jobAdId == jobAd.Id select i).SingleOrDefault();
                if (entity != null)
                {
                    dc.JobAdIndexingEntities.DeleteOnSubmit(entity);
                    dc.SubmitChanges();
                }
            }

            if (modifiedTime != null)
            {
                using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
                {
                    dc.JobAdIndexingEntities.InsertOnSubmit(new JobAdIndexingEntity {
                        jobAdId = jobAd.Id, modifiedTime = modifiedTime.Value
                    });
                    dc.SubmitChanges();
                }
            }

            return(jobAd);
        }
예제 #2
0
        private Member CreateMember(int index, DateTime lastUpdatedTime, DateTime?modifiedTime)
        {
            var member = _memberAccountsCommand.CreateTestMember(index);

            member.CreatedTime     = lastUpdatedTime;
            member.LastUpdatedTime = lastUpdatedTime;
            _membersRepository.UpdateMember(member);

            var candidate = _candidatesRepository.GetCandidate(member.Id);

            candidate.LastUpdatedTime = lastUpdatedTime;
            _candidatesRepository.UpdateCandidate(candidate);

            // Delete what is already there.

            using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
            {
                var entity = (from i in dc.MemberIndexingEntities where i.memberId == member.Id select i).SingleOrDefault();
                if (entity != null)
                {
                    dc.MemberIndexingEntities.DeleteOnSubmit(entity);
                    dc.SubmitChanges();
                }
            }

            if (modifiedTime != null)
            {
                using (var dc = new MaintenanceDataContext(_connectionFactory.CreateConnection()))
                {
                    dc.MemberIndexingEntities.InsertOnSubmit(new MemberIndexingEntity {
                        memberId = member.Id, modifiedTime = modifiedTime.Value
                    });
                    dc.SubmitChanges();
                }
            }

            return(member);
        }