private void SetViews(IEmployer employer, IEnumerable <Guid> memberIds, IEnumerable <EmployerMemberView> views) { // Get everything. var candidates = _candidatesQuery.GetCandidates(memberIds); var resumeIds = (from c in candidates where c.ResumeId != null select c.ResumeId.Value).ToList(); var resumes = _resumesQuery.GetResumes(resumeIds); var viewedMembers = GetViewedMemberIds(employer, memberIds); var flaggedCandidates = _candidateFlagListsQuery.GetFlaggedCandidateIds(employer, memberIds); var mobileCandidates = _candidateFoldersQuery.GetInMobileFolderCandidateIds(employer, memberIds); var folderedCandidates = _candidateFoldersQuery.GetFolderCounts(employer, memberIds); var noteCounts = _candidateNotesQuery.GetNoteCounts(employer, memberIds); foreach (var view in views) { var viewId = view.Id; var candidate = (from c in candidates where c.Id == viewId select c).Single(); var resume = candidate.ResumeId == null ? null : (from r in resumes where r.Id == candidate.ResumeId.Value select r).Single(); view.Set( candidate, resume, viewedMembers.Contains(viewId), flaggedCandidates.Contains(viewId), mobileCandidates.Contains(viewId), folderedCandidates.ContainsKey(viewId) ? folderedCandidates[viewId] : 0, noteCounts.ContainsKey(viewId) ? noteCounts[viewId] : 0); } }
private void AssertCandidates(IEmployer employer, params EmployerMemberView[] members) { var candidateIds = _candidateFoldersQuery.GetInMobileFolderCandidateIds(employer); Assert.AreEqual(members.Length, candidateIds.Count); foreach (var member in members) { var memberId = member.Id; Assert.IsTrue((from c in candidateIds where c == memberId select c).Any()); } }
protected void AssertFolderEntries(IEmployer employer, CandidateFolder folder, ICollection <Member> inFolderMembers, ICollection <Member> notInFolderMembers) { // IsInFolder foreach (var inFolderMember in inFolderMembers) { Assert.IsTrue(_candidateFoldersQuery.IsInFolder(employer, folder.Id, inFolderMember.Id)); } foreach (var notInFolderMember in notInFolderMembers) { Assert.IsFalse(_candidateFoldersQuery.IsInFolder(employer, folder.Id, notInFolderMember.Id)); } if (folder.FolderType == FolderType.Mobile) { foreach (var member in inFolderMembers) { Assert.IsTrue(_candidateFoldersQuery.IsInMobileFolder(employer, member.Id)); } foreach (var member in notInFolderMembers) { Assert.IsFalse(_candidateFoldersQuery.IsInMobileFolder(employer, member.Id)); } } // GetInFolderCandidateIds Assert.IsTrue((from m in inFolderMembers select m.Id).CollectionEqual(_candidateFoldersQuery.GetInFolderCandidateIds(employer, folder.Id))); if (folder.FolderType == FolderType.Mobile) { Assert.IsTrue((from m in inFolderMembers select m.Id).CollectionEqual(_candidateFoldersQuery.GetInMobileFolderCandidateIds(employer, from m in inFolderMembers.Concat(notInFolderMembers) select m.Id))); } // GetInFolderCounts. var counts = _candidateFoldersQuery.GetInFolderCounts(employer); if (counts.ContainsKey(folder.Id)) { Assert.AreEqual(inFolderMembers.Count, counts[folder.Id]); } else { Assert.AreEqual(inFolderMembers.Count, 0); } }