using CandidateReviewBusinessLogic.OfficePackage; using CandidateReviewBusinessLogic.OfficePackage.HelperModels; using CandidateReviewContracts.BindingModels; using CandidateReviewContracts.BusinessLogicsContracts; using CandidateReviewContracts.SearchModels; using CandidateReviewContracts.StoragesContracts; using CandidateReviewContracts.ViewModels; namespace CandidateReviewBusinessLogic.BusinessLogic { public class ReportLogic : IReportLogic { private readonly IResumeStorage _resumeStorage; private readonly IUserStorage _userStorage; private readonly IVacancyStorage _vacancyStorage; private readonly AbstractSaveToPdf _saveToPdf; public ReportLogic(IResumeStorage resumeStorage, AbstractSaveToPdf saveToPdf, IUserStorage userStorage, IVacancyStorage vacancyStorage) { _resumeStorage = resumeStorage; _saveToPdf = saveToPdf; _userStorage = userStorage; _vacancyStorage = vacancyStorage; } public ResumeViewModel GetResume(ReportBindingModel model) { var resume = _resumeStorage.GetElement(new ResumeSearchModel { Id = model.ResumeId }); resume.UserName = _userStorage.GetElement(new UserSearchModel { Id = resume.UserId }).Surname + " " + _userStorage.GetElement(new UserSearchModel { Id = resume.UserId }).Name + " " + _userStorage.GetElement(new UserSearchModel { Id = resume.UserId }).LastName; resume.VacancyName = _vacancyStorage.GetElement(new VacancySearchModel { Id = resume.VacancyId }).JobTitle; if (resume != null) { return resume; } return null; } public void SaveResumeToPdf(ReportBindingModel model) { _saveToPdf.CreateDocReportResume(new PdfInfo { FileName = model.FileName, Title = GetResume(model).VacancyName, Resume = GetResume(model) }); } } }