private void AssignToReviewer(Models.JobApplication applicant) { if (applicant == null || applicant.ReviewStatus != ReviewStatus.New) { return; } var applicantService = new JobApplicationProvider(); var positionTypeService = new JobPositionTypeProvider(); var reviewerService = new ReviewerProvider(); var ghDataStore = GreenHouseDataStore.Instance; var job = ghDataStore.GetJobById(applicant.JobId); if (job == null || job.Status != JobStates.Open) { applicant.ReviewStatus = ReviewStatus.JobClosed; applicantService.Update(applicant); _logger.InfoFormat("Applicant {0} is closed because it's job ({1}) is either deleted or not opened", applicant.Id, job?.Id); return; } if (applicant.Source == ApplicantSources.Referral && AppConfigsProvider.ReferralsHandlingConfigs.IsEnabled) { applicant.ReviewStatus = ReviewStatus.HandledAsReferral; applicantService.Update(applicant); SendEmailForReferral(applicant, job); _logger.InfoFormat("Applicant {0} of job {1} has been handled as a referral", applicant.Id, job.Id); return; } var positionTypeStr = job.GetCustomFieldValue(JobCustomFields.PositionType); var positionType = positionTypeService.GetList(p => p.Name == positionTypeStr).FirstOrDefault(); if (positionType == null) { _logger.WarnFormat("Position Type '{0}' is not available.", positionTypeStr); return; } var selectedReviewer = GetNextReviewer(positionType); if (selectedReviewer == null) { _logger.WarnFormat("Can not get any reviewers for the applicant {0}. It's either because there is no reviewers configured for this position type or all reviewers all not in working hours.", applicant.Id); return; } selectedReviewer.RecentAssignedAt = DateTime.UtcNow; selectedReviewer.AssignedCount++; applicant.ReviewerId = selectedReviewer.Id; applicant.ReviewStatus = ReviewStatus.Assigned; applicant.AssignedToReviewerAt = DateTime.UtcNow; applicantService.Update(applicant); reviewerService.Update(selectedReviewer); _logger.InfoFormat("Applicant {0} has been assigned to reviewer {1}", applicant.Id, selectedReviewer.Id); SendAssignmentEmail(selectedReviewer, applicant, job); }
public ActionResult Edit(Reviewer reviewer) { if (ModelState.IsValid) { var service = new ReviewerProvider(); service.Update(reviewer); var message = new MessageViewModel() { Type = MessageType.Success, Title = "Success", Content = string.Format("Reviewer {0} ({1}) has been updated...", reviewer.Name, reviewer.Email), }; TempData["Message"] = message; return(RedirectToAction("Index")); } return(View(reviewer)); }
private void ProcUpdate(JobApplication applicant) { var applicantsProvider = new JobApplicationProvider(); var reviewerProvider = new ReviewerProvider(); var ghStore = GreenHouseDataStore.Instance; Reviewer reviewer = null; if (applicant == null || applicant.Id == 0) { return; } var apiJobApplication = ghStore.GetApplicationById(applicant.Id.ToString()); var appliedJob = ghStore.GetJobById(applicant.JobId); if (applicant.ReviewerId.HasValue) { reviewer = reviewerProvider.Get(applicant.ReviewerId.Value); } //applicant deleted if (apiJobApplication == null || apiJobApplication.Id == 0) { applicant.ReviewStatus = Models.ReviewStatus.Deleted; applicantsProvider.Update(applicant); _logger.WarnFormat("Applicant {0} has been deleted from Greenhosue", applicant.Id); return; } if (apiJobApplication.CurrentStage == null) { applicant.ReviewStatus = ReviewStatus.Error; applicantsProvider.Update(applicant); _logger.WarnFormat("Cant not resolve current stage for applicant {0}", applicant.Id); return; } //applicant accepted and moved to another stage if (apiJobApplication.CurrentStage.Name != ApplicationStages.ApplicationReviewCV) { applicant.ReviewStatus = ReviewStatus.Accepted; applicant.RejectedOrAcceptedAt = apiJobApplication.AcceptedAt; applicantsProvider.Update(applicant); if (reviewer != null) { reviewer.AdvanceCount++; reviewerProvider.Update(reviewer); } _logger.WarnFormat("Applicant {0} has been accepted and moved to next stage by reviewer {1}", applicant.Id, reviewer != null ? reviewer.Id : 0); } //applicant is still at CV / Review stage and was rejected if (apiJobApplication.CurrentStage.Name == ApplicationStages.ApplicationReviewCV && apiJobApplication.RejectedAt.HasValue) { applicant.ReviewStatus = ReviewStatus.Rejected; applicant.RejectAt = apiJobApplication.RejectedAt.Value; applicant.RejectedOrAcceptedAt = apiJobApplication.RejectedAt.Value; applicant.RejectionReason = apiJobApplication.RejectionReason; applicantsProvider.Update(applicant); if (reviewer != null) { reviewer.RejectCount++; reviewerProvider.Update(reviewer); } _logger.WarnFormat("Applicant {0} has been rejected by reviewer {1}", applicant.Id, reviewer?.Id ?? 0); } //Applied job was removed or closed if (appliedJob == null || appliedJob.Status != JobStates.Open) { applicant.ReviewStatus = ReviewStatus.JobClosed; applicantsProvider.Update(applicant); _logger.WarnFormat("Applicant {0} has been closed because its job {1} is either deleted or closed", applicant.Id, applicant.JobId); } }