private void UpdateVacancySync(VacancyInfo value, int VacacnyID) { string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value; RTS.JobStation.Controller.Vacancy VacancyController = new RTS.JobStation.Controller.Vacancy(); MySql.Data.MySqlClient.MySqlConnection con = null; MySql.Data.MySqlClient.MySqlTransaction MyTran = null; try { con = RTS.JobStation.DatabaseCommands.OpenConnection(); MyTran = RTS.JobStation.DatabaseCommands.OpenTransaction(ref con); //Get Candidate Basic Info GetCandidateBasicInfo RTS.JobStation.Models.Vacancy vacancy = new RTS.JobStation.Models.Vacancy(); vacancy.VacancyID = VacacnyID; vacancy.ProcessID = value.ProcessID; vacancy.OpenPositions = value.OpenPositions; vacancy.DesignationID = value.DesignationID; vacancy.Title = value.JobTitle; vacancy.JobDescription = value.JobDescription; vacancy.JobSkill = value.JobSkill; vacancy.JobSkill = value.JobDuty; vacancy.EducationInfo = value.EducationInfo; vacancy.NationalityInfo = value.NationalityInfo; vacancy.UpdatedBy = Request.Headers["userid"]; vacancy.UpdatedOn = DateTime.Now; string result = VacancyController.Update_vacancy_UpdateVacancy(vacancy, ref con, ref MyTran); RTS.JobStation.Controller.Employeerequest EmpReqController = new RTS.JobStation.Controller.Employeerequest(); RTS.JobStation.Models.Employeerequest EmpReqModel = new RTS.JobStation.Models.Employeerequest(); EmpReqModel.RequestedByUserID = value.RequestedByUserID; EmpReqModel.RequestingDepartment = value.RequestingDepartmentID; EmpReqModel.PositionName = value.JobTitle; EmpReqModel.PositionTypeID = value.PositionTypeID; EmpReqModel.NoOfEmployeeRequired = value.OpenPositions; EmpReqModel.UpdatedBy = Request.Headers["userid"]; EmpReqModel.UpdatedOn = DateTime.Now; EmpReqModel.EmployeeRequestID = EmpReqController.GetEmployeeRequestID(ref con, ref MyTran, VacacnyID); EmpReqController.Update(EmpReqModel, ref con, ref MyTran); // return Ok("Vacancy Created"); } catch { // return StatusCode(500); } finally { RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran); RTS.JobStation.DatabaseCommands.CloseConnection(ref con); } }
private void AddVacancySync(VacancyInfo value) { string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value; RTS.JobStation.Controller.Vacancy VacancyController = new RTS.JobStation.Controller.Vacancy(); MySql.Data.MySqlClient.MySqlConnection con = null; MySql.Data.MySqlClient.MySqlTransaction MyTran = null; try { con = RTS.JobStation.DatabaseCommands.OpenConnection(); MyTran = RTS.JobStation.DatabaseCommands.OpenTransaction(ref con); //Get Candidate Basic Info GetCandidateBasicInfo RTS.JobStation.Models.Vacancy vacancy = new RTS.JobStation.Models.Vacancy(); vacancy.ProcessID = value.ProcessID; vacancy.OpenPositions = value.OpenPositions; vacancy.DesignationID = value.DesignationID; vacancy.Title = value.JobTitle; vacancy.JobDescription = value.JobDescription; vacancy.JobSkill = value.JobSkill; vacancy.JobSkill = value.JobDuty; vacancy.EducationInfo = value.EducationInfo; vacancy.NationalityInfo = value.NationalityInfo; vacancy.UpdatedBy = Request.Headers["userid"]; vacancy.UpdatedOn = DateTime.Now; string result = VacancyController.Insert_vacancy_AddVacancy(vacancy, ref con, ref MyTran); int VacancyID = Int32.Parse(JobStation.DatabaseCommands.GetLastInsertedID(ref con, ref MyTran).ToString()); RTS.JobStation.Controller.Employeerequest EmpReqController = new RTS.JobStation.Controller.Employeerequest(); RTS.JobStation.Models.Employeerequest EmpReqModel = new RTS.JobStation.Models.Employeerequest(); EmpReqModel.RequestedByUserID = value.RequestedByUserID; EmpReqModel.RequestingDepartment = value.RequestingDepartmentID; EmpReqModel.PositionName = value.JobTitle; EmpReqModel.PositionTypeID = value.PositionTypeID; EmpReqModel.NoOfEmployeeRequired = value.OpenPositions; EmpReqModel.UpdatedBy = Request.Headers["userid"]; EmpReqModel.UpdatedOn = DateTime.Now; EmpReqController.Insert(EmpReqModel, ref con, ref MyTran); int EmployeeRequestID = Int32.Parse(JobStation.DatabaseCommands.GetLastInsertedID(ref con, ref MyTran).ToString()); RTS.JobStation.Controller.Jobrequestederf JobReqController = new RTS.JobStation.Controller.Jobrequestederf(); RTS.JobStation.Models.Jobrequestederf JobReqModel = new RTS.JobStation.Models.Jobrequestederf(); JobReqModel.VacancyID = VacancyID; JobReqModel.EmployeeRequestID = EmployeeRequestID; JobReqModel.UpdatedBy = Request.Headers["userid"]; JobReqModel.UpdatedOn = DateTime.Now; JobReqController.Insert(JobReqModel, ref con, ref MyTran); AddJobInterviewerInfo(value.JobInterviewerList, VacancyID, ref con, ref MyTran); // return Ok("Vacancy Created"); //Add to JobDepartment and JobEntity RTS.JobStation.Controller.Jobentity JobEntityController = new RTS.JobStation.Controller.Jobentity(); RTS.JobStation.Models.Jobentity JobEntityModel = new RTS.JobStation.Models.Jobentity(); JobEntityModel.EntityID = value.RequestingEntityID; JobEntityModel.VacancyID = VacancyID; JobEntityModel.UpdatedBy = Request.Headers["userid"]; JobEntityController.Insert(JobEntityModel, ref con, ref MyTran); RTS.JobStation.Controller.Jobdepartment JobDepartmentController = new RTS.JobStation.Controller.Jobdepartment(); RTS.JobStation.Models.Jobdepartment JobDepartmentModel = new RTS.JobStation.Models.Jobdepartment(); JobDepartmentModel.DepartmentID = value.RequestingDepartmentID; JobDepartmentModel.VacancyID = VacancyID; JobDepartmentModel.UpdatedBy = Request.Headers["userid"]; JobDepartmentController.Insert(JobDepartmentModel, ref con, ref MyTran); } catch { // return StatusCode(500); } finally { RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran); RTS.JobStation.DatabaseCommands.CloseConnection(ref con); } }