/// <summary> /// Assign new job boards to the job /// </summary> /// <param name="jobBoards"></param> /// <param name="jobDetails"></param> /// <param name="jobId"></param> /// <returns></returns> private bool SaveJobJobBoards(IEnumerable<SelectedJobBoard> jobBoards, Job jobDetails, int jobId) { // get the updating user // if updating user is a // 1) HR Manager - Set all the approved flags to true and send an email to RecuitGenie // 2) Recruit manager - Set the recruit manager approved tag to true and send an email to HR manager for Approval // 3) User - Send an email to both HR and Recruit manager for approval return true; }
/// <summary> /// Do not replace the body if the object is null /// </summary> /// <param name="rawBody"></param> /// <param name="contactId"></param> /// <param name="jobId"></param> /// <param name="userId"></param> /// <param name="consultantid"></param> /// <param name="clientId"></param> /// <param name="candidate"></param> /// <param name="job"></param> /// <param name="cUser"></param> /// <param name="consultant"></param> /// <param name="client"></param> /// <param name="intRequestId"></param> /// <param name="timeSlotId"></param> /// <returns></returns> public string GetOriginalBodyForPreview(string rawBody, int contactId = 0, int jobId = 0, int userId = 0, int consultantid = 0, int clientId = 0, Candidate candidate = null, Job job = null, User cUser = null, User consultant = null, Client client = null, int intRequestId = 0, int timeSlotId = 0) { // get contact by id if (contactId > 0) candidate = new Contacts().GetCandidate(contactId); //retrieve objects if null and have an id passed if (job == null && jobId > 0) job = new Jobs().GetJob(jobId); if (cUser == null && userId > 0) cUser = new Users().GetUser(userId); if (consultant == null && consultantid > 0) consultant = new Users().GetUser(consultantid); if (client == null && clientId > 0) client = new Clients().GetClient(clientId); InterviewRequest intRequest = null; if (intRequestId > 0) { intRequest = new Interviews().GetInterviewRequest(intRequestId); } TimeSlot timeSlot = null; if (timeSlotId > 0) { timeSlot = new Interviews().GetTimeSlot(timeSlotId); } //Contact if (candidate != null) { var pwdlink = "http://www.resonatesearch.co.uk/reset-password.aspx?token=" + candidate.RefId; rawBody = rawBody.Replace("#ContactTitle#", candidate.Title); rawBody = rawBody.Replace("#ContactForename#", candidate.Forename); rawBody = rawBody.Replace("#ContactSurname#", candidate.Surname); rawBody = rawBody.Replace("#ContactJobTitle#", candidate.JobTitle); rawBody = rawBody.Replace("#ContactEmployer#", candidate.Employer); rawBody = rawBody.Replace("#ContactEmail#", candidate.Email); rawBody = rawBody.Replace("#ContactPassword#", candidate.Password); if (string.IsNullOrEmpty(candidate.Password)) rawBody = rawBody.Replace("#PasswordResetLink#", "If you wish to create a password for your account on Resonate Search please click link below:<br/><a href='" + pwdlink + "'>" + pwdlink + "</a><br/>"); else rawBody = rawBody.Replace("#PasswordResetLink#", ""); } //Job if (job != null) { rawBody = rawBody.Replace("#VacancyTitle#", job.JobTitle); rawBody = rawBody.Replace("#VacancyRef#", job.Ref); rawBody = rawBody.Replace("#VacancyBenefits#", job.Benefits); rawBody = rawBody.Replace("#VacancyOverview#", job.Overview); } // User if (cUser != null) { rawBody = rawBody.Replace("#UserForename#", cUser.Forename); rawBody = rawBody.Replace("#UserSurname#", cUser.Surname); rawBody = rawBody.Replace("#UserEmail#", cUser.Email); rawBody = rawBody.Replace("#UserMobile#", cUser.Mobile); rawBody = rawBody.Replace("#UserPassword#", cUser.Password); rawBody = rawBody.Replace("#UserJobTitle#", cUser.JobTitle); } // Consultant if (consultant != null) { rawBody = rawBody.Replace("#ConsultantForename#", consultant.Forename); rawBody = rawBody.Replace("#ConsultantSurname#", consultant.Surname); rawBody = rawBody.Replace("#ConsultantEmail#", consultant.Email); rawBody = rawBody.Replace("#ConsultantMobile#", consultant.Mobile); rawBody = rawBody.Replace("#ConsultantJobTitle#", consultant.Password); } // Client if (client != null) { rawBody = rawBody.Replace("#ClientName#", client.ClientName); rawBody = rawBody.Replace("#ClientEmail#", client.Email); } // Interview Request if (intRequest != null) { var requestLink = "http://www.resonatesearch.co.uk/interview/interview-request.aspx?ref=" + intRequest.RefId; rawBody = rawBody.Replace("#InterviewRequestLink#", requestLink); } // Time Slot if (timeSlot != null) { rawBody = rawBody.Replace("#InterviewDate#", "Interview Date: <b>" + Convert.ToDateTime(timeSlot.SlotDate).ToString("dd MMM, yyyy") + " - " + timeSlot.SlotTime + "</b>"); rawBody = rawBody.Replace("#Duration#", "Duration:<b> " + GetDurationText(timeSlot.Duration) + "</b>"); rawBody = rawBody.Replace("#InterviewLocation#", timeSlot.Location != null ? GetInterviewLocation(timeSlot) : ""); rawBody = rawBody.Replace("#Interviewers#", timeSlot.Interviewers != null && timeSlot.Interviewers.Any() ? GetInterviewers(timeSlot) : ""); } return rawBody; }
/// <summary> /// This function add/update job details /// </summary> /// <param name="jobDetails"></param> /// <returns></returns> // ReSharper disable once FunctionComplexityOverflow public PostPutResponse AddUpdateJob(Job jobDetails) { var context = new dbDataContext(); int jobId = jobDetails.JobId; var response = new PostPutResponse { DisplayError = "", IsError = false, ObjectId = -1 }; // Create or retrieve the job var job = context.tbl_Jobs.FirstOrDefault(t => t.JobId == jobDetails.JobId) ?? new tbl_Job(); // Assign job values job.JobTitle = jobDetails.JobTitle; job.ClientId = jobDetails.ClientId; job.Ref = jobDetails.Ref; job.Benefits = jobDetails.Benefits; job.Overview = jobDetails.Overview; job.JobDescription = jobDetails.JobDescription; job.JobLocation = jobDetails.JobLocation; job.JobApplicationPageLink = jobDetails.JobApplicationPageLink; job.Published = jobDetails.Published; job.Archived = jobDetails.Archived; job.Deleted = jobDetails.Deleted; job.NotificationEmail = jobDetails.NotificationEmail; job.JobType = jobDetails.JobType; job.ContractType = jobDetails.ContractType; job.PostedBy = jobDetails.PostedBy; job.ExpiryDate = jobDetails.ExpiryDate; job.LastUpdatedDate = DateTime.Now; job.Manager = jobDetails.Manager; job.SalaryType = jobDetails.SalaryType; job.MinSalary = jobDetails.MinSalary; job.MaxSalary = jobDetails.MaxSalary; job.SearchLocationType = jobDetails.SearchLocationType; job.HoursOrDaysPerWeek = jobDetails.HoursOrDaysPerWeek; job.MinSalaryAnnum = CalculateAnnualSalary(job.MinSalary, jobDetails.SalaryType, jobDetails.HoursOrDaysPerWeek); job.MaxSalaryAnnum = CalculateAnnualSalary(job.MaxSalary, jobDetails.SalaryType, jobDetails.HoursOrDaysPerWeek); if (!(jobDetails.SalaryType == "hour" || jobDetails.SalaryType == "day")) job.HoursOrDaysPerWeek = 0; job.StartDate = jobDetails.StartDate; job.AllUserAccess = jobDetails.AllUserAccess; try { // Add/Update Job if (job.JobId <= 0) { job.RefId = Guid.NewGuid().ToString(); job.CreatedDate = DateTime.Now; context.tbl_Jobs.InsertOnSubmit(job); } context.SubmitChanges(); } catch (Exception e) { response.ActualError = e.ToString(); response.DisplayError = "Error " + (jobId > 0 ? "updating" : "adding") + " the job!"; response.IsError = true; } if (job.JobId > 0) { jobDetails.JobId = job.JobId; // Save Job Locations context.tbl_JobLocations.DeleteAllOnSubmit(context.tbl_JobLocations.Where(t => t.JobId == job.JobId)); context.SubmitChanges(); if (jobDetails.LocationIds != null) { foreach ( var locId in jobDetails.LocationIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { context.tbl_JobLocations.InsertOnSubmit(new tbl_JobLocation { JobId = job.JobId, LocationId = int.Parse(locId), Type = job.SearchLocationType }); } context.SubmitChanges(); } // Save Job Sectors context.tbl_JobSectors.DeleteAllOnSubmit(context.tbl_JobSectors.Where(t => t.JobId == job.JobId)); context.SubmitChanges(); if (jobDetails.SectorIds != null) { foreach (var secId in jobDetails.SectorIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) ) { context.tbl_JobSectors.InsertOnSubmit(new tbl_JobSector { JobId = job.JobId, SectorId = int.Parse(secId) }); } context.SubmitChanges(); } // Save Job Users context.tbl_JobUsers.DeleteAllOnSubmit(context.tbl_JobUsers.Where(t => t.JobId == job.JobId)); context.SubmitChanges(); if (jobDetails.JobUserIds != null) { foreach (var userId in jobDetails.JobUserIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { context.tbl_JobUsers.InsertOnSubmit(new tbl_JobUser { JobId = job.JobId, UserId = int.Parse(userId) }); } context.SubmitChanges(); } // Save Job Killer Questions if (jobDetails.KillerQuestions != null && jobDetails.KillerQuestions.ToList().Count > 0) { var objKillerQuestions = new KillerQuestions(); foreach (var killerQuestion in jobDetails.KillerQuestions) { killerQuestion.JobId = job.JobId; objKillerQuestions.AddEditKillerQuestion(killerQuestion); } // re-calculate the killer question score for applications objKillerQuestions.CalculateKillerQuestionScoreForJob(jobDetails.JobId); } // Save Documents if (jobDetails.Documents != null) { jobDetails.Documents.ToList().ForEach(t => t.RefId = job.JobId); new Documents().SaveDocuments(jobDetails.Documents); } // save job - job boards if (jobDetails.JobBoards != null) { SaveJobJobBoards(jobDetails.JobBoards, jobDetails, job.JobId); } //add history new Histories().AddHistory(new History { RefId = job.JobId, RefType = "Job", ClientUserId = jobDetails.ClientUserId, TypeId = jobId < 1 ? 5 : 6, SubRefType = "ClientUser", SubRefId = jobDetails.ClientUserId }); // If new job send notification email to client if (jobId < 1) { // TODO - Send Notification Email } response.ObjectId = jobDetails.JobId; } return response; }