protected void UpdateLastUsedTime(Guid memberId, Guid fileReferenceId, DateTime time) { var resumeFile = _candidatesRepository.GetResumeFile(memberId, fileReferenceId); resumeFile.LastUsedTime = time; _candidatesRepository.UpdateResumeFile(resumeFile); }
public void TestCreateResumeFiles() { var candidateId = Guid.NewGuid(); _candidatesCommand.CreateCandidate(new Candidate { Id = candidateId }); var file1 = _filesCommand.CreateTestFile(1, FileType.Resume); var resumeFileReference1 = new ResumeFileReference { FileReferenceId = file1.Id }; _candidateResumeFilesCommand.CreateResumeFile(candidateId, resumeFileReference1); var file2 = _filesCommand.CreateTestFile(2, FileType.Resume); var resumeFileReference2 = new ResumeFileReference { FileReferenceId = file2.Id }; _candidateResumeFilesCommand.CreateResumeFile(candidateId, resumeFileReference2); resumeFileReference1.LastUsedTime = DateTime.Now.AddDays(-1); _candidatesRepository.UpdateResumeFile(resumeFileReference1); resumeFileReference2.LastUsedTime = DateTime.Now.AddDays(-2); _candidatesRepository.UpdateResumeFile(resumeFileReference2); AssertResumeFile(resumeFileReference1, _candidateResumeFilesQuery.GetResumeFile(candidateId, file1.Id)); AssertResumeFile(resumeFileReference2, _candidateResumeFilesQuery.GetResumeFile(candidateId, file2.Id)); var resumeFileReferences = _candidateResumeFilesQuery.GetResumeFiles(candidateId); Assert.AreEqual(2, resumeFileReferences.Count); // 1 should come first because it was used last. AssertResumeFile(resumeFileReference1, resumeFileReferences[0]); AssertResumeFile(resumeFileReference2, resumeFileReferences[1]); AssertResumeFile(resumeFileReference1, _candidateResumeFilesQuery.GetLastUsedResumeFile(candidateId)); }
void ICandidateResumeFilesCommand.ValidateFile(string fileName, FileContents fileContents) { // Check the file extension. var extension = Path.GetExtension(fileName); if (string.IsNullOrEmpty(extension)) { throw new InvalidResumeExtensionException(extension); } if (!ValidExtensions.Contains(extension.TrimStart('.').ToLower())) { throw new InvalidResumeExtensionException(extension); } // Must not be too large. if (fileContents.Length > Constants.MaxResumeFileSize) { throw new FileTooLargeException { MaxFileSize = Constants.MaxResumeFileSize } } ; } void ICandidateResumeFilesCommand.CreateResumeFile(Guid candidateId, ResumeFileReference resumeFileReference) { resumeFileReference.Prepare(); resumeFileReference.Validate(); _repository.CreateResumeFile(candidateId, resumeFileReference); } void ICandidateResumeFilesCommand.UpdateLastUsedTime(ResumeFileReference resumeFileReference) { resumeFileReference.LastUsedTime = DateTime.Now; resumeFileReference.Validate(); _repository.UpdateResumeFile(resumeFileReference); } }