public bool UploadResume(string username, string title, string description, HttpPostedFileBase content) { var docType = Helpers.GetWebUploadType(content.ContentType); var list = uow.ValueRepository.GetStopwords(); var stopwords = fileFactory.GetStopwordsFile(DocumentType.Set, list); IResumeFile file; //get bytes int contentLength = content.ContentLength; byte[] bytes = content.GetBytes(); switch (docType) { case DocumentType.Word: { string tmpPath = tempFileService.CreateTempFile(bytes, content.FileName, contentLength); file = fileFactory.GetResumeFile(DocumentType.Word, stopwords, tmpPath); tempFileService.DeleteTempFile(tmpPath); break; } default: { //process bytes file = fileFactory.GetResumeFile(DocumentType.Bytes, stopwords, bytes); break; } } if (bytes == null) { throw new NullReferenceException("Could not retrieve bytes form upload."); } //build entity graph List <Keyword> words = new List <Keyword>(); foreach (var w in file) { words.Add(new Keyword() { Word = w.ToString() }); } var resume = new Resume(title, description, words, bytes, content.ContentType); resume.User = uow.UserRepository.GetUserByUsername(username); uow.ResumeRepository.InsertResume(resume); return(uow.Save()); }
public ListingService(IUnitOfWork uow, IGitHubAPI github, IListingPreprocessFactory preprocessFact, IFileFactory fileFact) { this.uow = uow; this.github = github; var list = uow.ValueRepository.GetStopwords(); ghPreprocess = (GitHubPreprocess)preprocessFact.GetPreprocess(ListingSource.Github, fileFact.GetStopwordsFile(DocumentType.Set, list)); }