/// <summary> /// Executes the command /// </summary> virtual public void Execute(UpdateJobSearchMetricsCmdParams cmdParams) { var unitOfWork = _serviceFactory.GetService<IUnitOfWork>(); // Retrieve the job search var jobSearch = new JobSearchByIdQuery(unitOfWork).WithJobSearchId(cmdParams.JobSearchId).Execute(); // Rebuild Metrics jobSearch.Metrics.NumCompaniesCreated = unitOfWork.Companies.Fetch().Count(x => x.JobSearchID == cmdParams.JobSearchId); jobSearch.Metrics.NumContactsCreated = unitOfWork.Contacts.Fetch().Count(x => x.Company.JobSearchID == cmdParams.JobSearchId); jobSearch.Metrics.NumApplyTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.ApplyToFirmTaskCategory) .Count(); jobSearch.Metrics.NumApplyTasksCompleted = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.ApplyToFirmTaskCategory) .Where(x => x.CompletionDate != null) .Count(); jobSearch.Metrics.NumPhoneInterviewTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.PhoneInterviewTaskCategory) .Count(); jobSearch.Metrics.NumInPersonInterviewTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.InPersonInterviewTaskCategory) .Count(); // Update the entity unitOfWork.Commit(); }
/// <summary> /// Executes the command /// </summary> virtual public void Execute(UpdateJobSearchMetricsCmdParams cmdParams) { var unitOfWork = _serviceFactory.GetService <IUnitOfWork>(); // Retrieve the job search var jobSearch = new JobSearchByIdQuery(unitOfWork).WithJobSearchId(cmdParams.JobSearchId).Execute(); // Rebuild Metrics jobSearch.Metrics.NumCompaniesCreated = unitOfWork.Companies.Fetch().Count(x => x.JobSearchID == cmdParams.JobSearchId); jobSearch.Metrics.NumContactsCreated = unitOfWork.Contacts.Fetch().Count(x => x.Company.JobSearchID == cmdParams.JobSearchId); jobSearch.Metrics.NumApplyTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.ApplyToFirmTaskCategory) .Count(); jobSearch.Metrics.NumApplyTasksCompleted = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.ApplyToFirmTaskCategory) .Where(x => x.CompletionDate != null) .Count(); jobSearch.Metrics.NumPhoneInterviewTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.PhoneInterviewTaskCategory) .Count(); jobSearch.Metrics.NumInPersonInterviewTasksCreated = unitOfWork.Tasks.Fetch() .Where(x => x.Company.JobSearchID == cmdParams.JobSearchId) .Where(x => x.Category == MJLConstants.InPersonInterviewTaskCategory) .Count(); // Update the entity unitOfWork.Commit(); }
/// <summary> /// Executes the command /// </summary> /// <returns></returns> /// <exception cref="MJLEntityNotFoundException">Thrown when the specified job search is not found</exception> public virtual JobSearch Execute() { // Retrieve the job search var search = new JobSearchByIdQuery(_unitOfWork).WithJobSearchId(_jobSearchId).Execute(); if (search == null) { throw new MJLEntityNotFoundException(typeof(JobSearch), _jobSearchId); } // Retrieve the calling user var user = new UserByIdQuery(_unitOfWork).WithUserId(_userId).Execute(); if (user == null) { throw new MJLEntityNotFoundException(typeof(User), _userId); } // Only edit the properties that were requested if (_newName != null) { search.Name = _newName; } if (_newDesc != null) { search.Description = _newDesc; } if (_resetHiddenStatusList) { search.HiddenCompanyStatuses = string.Empty; } // Append to the hidden company status list if (_hiddenStatuses.Count > 0) { foreach (string status in _hiddenStatuses) { search.HiddenCompanyStatuses += status + ";"; } } // Create the history record search.History.Add(new JobSearchHistory { HistoryAction = MJLConstants.HistoryUpdate, DateModified = DateTime.Now, AuthoringUser = user, Name = search.Name, Description = search.Description, HiddenCompanyStatuses = search.HiddenCompanyStatuses }); // Commit _unitOfWork.Commit(); return(search); }
public void Execute_Returns_Null_JobSearch_When_Id_Not_Found() { // Setup InitializeTestEntities(); int id = _jobSearch.Id + 100; // Act JobSearch result = new JobSearchByIdQuery(_unitOfWork).WithJobSearchId(id).Execute(); // Verify Assert.IsNull(result, "Query returned a non-null job search"); }
public void Can_Retrieve_JobSearch_By_Id() { // Setup InitializeTestEntities(); // Act JobSearch result = new JobSearchByIdQuery(_unitOfWork).WithJobSearchId(_jobSearch.Id).Execute(); // Verify Assert.IsNotNull(result, "Command returned a null job search"); Assert.AreEqual(_jobSearch.Id, result.Id, "Returned job search had an incorrect id value"); Assert.AreEqual(_jobSearch.Name, result.Name, "Returned job search had an incorrect id value"); }
public JobSearchController(JobSearchesByUserIdQuery jobSearchesByIdQuery, JobSearchByIdQuery jobSearchByIdQuery, CreateJobSearchForUserCommand createJobSearchCommand, EditJobSearchCommand editJobSearchCommand, OpenTasksByJobSearchQuery openTasksByJobSearchQuery, EditUserCommand editUserCommand, EntitySearchQuery entitySearchQuery, UserByIdQuery userByIdQuery, StartNextJobSearchMilestoneCommand startNextMilestoneCmd, IProcess <ByJobSearchParams, JobsearchExportViewModel> exportProcess, IServiceFactory serviceFactory) { _jobSearchByIdQuery = jobSearchByIdQuery; _jobSearchesByUserIdQuery = jobSearchesByIdQuery; _createJobSearchCommand = createJobSearchCommand; _editJobSearchCommand = editJobSearchCommand; _openTasksByJobSearchQuery = openTasksByJobSearchQuery; _editUserCommand = editUserCommand; _entitySearchQuery = entitySearchQuery; _serviceFactory = serviceFactory; _userByIdQuery = userByIdQuery; _startNextMilestoneCmd = startNextMilestoneCmd; _exportProcess = exportProcess; }
public JobSearchController(JobSearchesByUserIdQuery jobSearchesByIdQuery, JobSearchByIdQuery jobSearchByIdQuery, CreateJobSearchForUserCommand createJobSearchCommand, EditJobSearchCommand editJobSearchCommand, OpenTasksByJobSearchQuery openTasksByJobSearchQuery, EditUserCommand editUserCommand, EntitySearchQuery entitySearchQuery, UserByIdQuery userByIdQuery, StartNextJobSearchMilestoneCommand startNextMilestoneCmd, IProcess<ByJobSearchParams, JobsearchExportViewModel> exportProcess, IServiceFactory serviceFactory) { _jobSearchByIdQuery = jobSearchByIdQuery; _jobSearchesByUserIdQuery = jobSearchesByIdQuery; _createJobSearchCommand = createJobSearchCommand; _editJobSearchCommand = editJobSearchCommand; _openTasksByJobSearchQuery = openTasksByJobSearchQuery; _editUserCommand = editUserCommand; _entitySearchQuery = entitySearchQuery; _serviceFactory = serviceFactory; _userByIdQuery = userByIdQuery; _startNextMilestoneCmd = startNextMilestoneCmd; _exportProcess = exportProcess; }
/// <summary> /// Executes the command /// </summary> /// <returns></returns> /// <exception cref="MJLEntityNotFoundException">Thrown when the specified job search is not found</exception> public virtual JobSearch Execute() { // Retrieve the job search var search = new JobSearchByIdQuery(_unitOfWork).WithJobSearchId(_jobSearchId).Execute(); if (search == null) throw new MJLEntityNotFoundException(typeof(JobSearch), _jobSearchId); // Retrieve the calling user var user = new UserByIdQuery(_unitOfWork).WithUserId(_userId).Execute(); if (user == null) throw new MJLEntityNotFoundException(typeof(User), _userId); // Only edit the properties that were requested if (_newName != null) search.Name = _newName; if (_newDesc != null) search.Description = _newDesc; if (_resetHiddenStatusList) search.HiddenCompanyStatuses = string.Empty; // Append to the hidden company status list if (_hiddenStatuses.Count > 0) foreach (string status in _hiddenStatuses) search.HiddenCompanyStatuses += status + ";"; // Create the history record search.History.Add(new JobSearchHistory { HistoryAction = MJLConstants.HistoryUpdate, DateModified = DateTime.Now, AuthoringUser = user, Name = search.Name, Description = search.Description, HiddenCompanyStatuses = search.HiddenCompanyStatuses }); // Commit _unitOfWork.Commit(); return search; }
public JobSearchExportProcess(JobSearchByIdQuery jobsearchQuery) { _jobsearchQuery = jobsearchQuery; }