コード例 #1
0
ファイル: RangeTests.cs プロジェクト: formist/LinkMe
        private Member CreateMember(int index)
        {
            var member = CreateMember(index, null);

            // Update all the times.

            var date = DateTime.Now.AddDays(-1 * index);

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

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

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

            var resume = _resumesRepository.GetResume(candidate.ResumeId.Value);

            resume.CreatedTime     = date;
            resume.LastUpdatedTime = date;
            _resumesRepository.UpdateResume(resume);

            _memberSearchService.UpdateMember(member.Id);
            return(member);
        }
コード例 #2
0
        private Member CreateMember(int index, int days)
        {
            var lastUpdatedTime = DateTime.Now.AddDays(-1 * days);

            var member = CreateMember(index);

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

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

            _candidateResumesCommand.AddTestResume(candidate);

            candidate.DesiredSalary = new Salary {
                UpperBound = days * 1000, Currency = Currency.AUD, Rate = SalaryRate.Year
            };
            candidate.LastUpdatedTime = lastUpdatedTime;
            _candidatesRepository.UpdateCandidate(candidate);

            // Use the repository directly so that the last updated time is not overridden by the command.

            var resume = _resumesQuery.GetResume(candidate.ResumeId.Value);

            resume.LastUpdatedTime = lastUpdatedTime;
            _resumesRepository.UpdateResume(resume);

            _memberSearchService.UpdateMember(member.Id);
            return(member);
        }
コード例 #3
0
        private Member CreateMember(DateTime candidateLastUpdatedTime, DateTime resumeLastUpdatedTime)
        {
            // Create the member.

            var member = CreateMember(0);

            member.CreatedTime     = DateTime.Now.AddMonths(-3);
            member.LastUpdatedTime = member.CreatedTime;
            _membersRepository.UpdateMember(member);

            // Update the candidate.

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

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

            // Update the resume.

            Assert.IsNotNull(candidate.ResumeId);
            var resume = _resumesQuery.GetResume(candidate.ResumeId.Value);

            resume.LastUpdatedTime = resumeLastUpdatedTime;
            _resumesRepository.UpdateResume(resume);

            return(member);
        }
コード例 #4
0
        public void TestSetCurrent()
        {
            var today       = DateTime.Now.Date;
            var oneWeekAgo  = today.AddDays(-7);
            var twoWeeksAgo = today.AddDays(-14);

            var member    = CreateMember();
            var candidate = _candidatesQuery.GetCandidate(member.Id);
            var resume    = new Resume {
                Other = "Other"
            };

            _candidateResumesCommand.CreateResume(candidate, resume);

            // Set last update times.

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

            resume.LastUpdatedTime = twoWeeksAgo;
            _resumesRepository.UpdateResume(resume);

            LogIn(member);

            AssertJsonSuccess(SetCurrent());
            AssertMember(member, candidate, resume, true);

            // Check the times.

            var updatedCandidate = _candidatesQuery.GetCandidate(candidate.Id);

            Assert.AreNotEqual(oneWeekAgo, updatedCandidate.LastUpdatedTime.Date);

            // It would be nice to check down to finer granularity but rounding etc gets in the way.  Just check that it has changed.

            Assert.IsTrue((DateTime.Now - candidate.LastUpdatedTime).TotalMinutes > 1);
            Assert.IsTrue((DateTime.Now - updatedCandidate.LastUpdatedTime).TotalMinutes <= 1);

            var updatedResume = _resumesQuery.GetResume(candidate.ResumeId.Value);

            Assert.AreNotEqual(twoWeeksAgo, updatedResume.LastUpdatedTime.Date);

            Assert.IsTrue((DateTime.Now - resume.LastUpdatedTime).TotalMinutes > 1);
            Assert.IsTrue((DateTime.Now - updatedResume.LastUpdatedTime).TotalMinutes <= 1);
        }
コード例 #5
0
        private void UpdateMember(Member member, Candidate candidate, Resume resume, DateTime lastUpdatedTime)
        {
            member.CreatedTime     = lastUpdatedTime;
            member.LastUpdatedTime = lastUpdatedTime;
            _membersRepository.UpdateMember(member);

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

            resume.LastUpdatedTime = DateTime.Now.AddDays(-2);
            _resumesRepository.UpdateResume(resume);

            _memberSearchService.UpdateMember(member.Id);
        }
コード例 #6
0
ファイル: CandidatesCommand.cs プロジェクト: formist/LinkMe
        void ICandidatesCommand.UpdateCandidate(Candidate candidate)
        {
            // Keep track of changes.

            var originalCandidate = _repository.GetCandidate(candidate.Id);

            // Change and save.

            PrepareUpdate(candidate);
            candidate.Validate();
            _repository.UpdateCandidate(candidate);

            // Fire events.

            Fire(candidate, originalCandidate);
        }
コード例 #7
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);
        }