private void CreateCandidateProfileAsync(CandidateCVInfo value, int CandidateID) { Thread createCandidate = new Thread(() => CreateCandidateProfile(value, CandidateID)); createCandidate.IsBackground = true; createCandidate.Start(); }
public ActionResult <string> CreateCandidate([FromBody] CandidateCVInfo value, [FromQuery] string apikey, [FromQuery] string userkey, [FromQuery] string consumerkey, [FromQuery] string token, [FromQuery] int userid) { string jsonResult = ""; if (AuthenticateUser() == false) { return(Unauthorized()); } /* if (apikey != "123") * { * return Unauthorized(); * }*/ string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value; RTS.JobStation.Controller.Candidate CandidateController = new RTS.JobStation.Controller.Candidate(); 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.Candidate candidate = new RTS.JobStation.Models.Candidate(); candidate.cvTitle = value.cvTitle; candidate.Objective = value.Objective; candidate.RefNo = value.RefNo; candidate.ExternalRefNo = value.ExternalRefNo; candidate.NameFirst = value.NameFirst; candidate.NameMiddle = value.NameMiddle; candidate.NameLast = value.NameLast; candidate.cvFIle = value.cvFIle; candidate.cvMimeType = value.cvFIle.Substring(value.cvFIle.IndexOf(".") + 1, 3); candidate.DateOfBirth = value.DateOfBirth; candidate.Gender = value.Gender; candidate.ReligionID = value.ReligionID; candidate.CasteID = value.CasteID; candidate.MaritialStatus = value.MaritialStatus; candidate.NoOfDependant = value.NoOfDependant; candidate.Nationality = value.Nationality; candidate.CountryOfResidence = value.CountryOfResidence; candidate.CityID = value.CityID; candidate.VisaStatusID = value.VisaStatusID; candidate.NoticePeriod = value.NoticePeriod; candidate.Email = value.Email; candidate.uPassword = value.uPassword; candidate.MobileCountryCode = value.MobileCountryCode; candidate.MobileNo = value.MobileNo; candidate.Address = value.Address; candidate.PoBox = value.PoBox; candidate.FaxCountryCode = value.PoBox; candidate.FaxNo = value.FaxNo; candidate.isRelativeAtCompany = value.isRelativeAtCompany; candidate.RelativeDetails = value.RelativeDetails; candidate.WhyShurooq = value.WhyShurooq; candidate.WorkExperienceTotal = value.WorkExperienceTotal; candidate.WorkExperienceUAE = value.WorkExperienceUAE; candidate.WorkExperienceNonUAE = value.WorkExperienceNonUAE; candidate.RelevantExperience = value.RelevantExperience; candidate.UpdatedBy = Request.Headers["userid"]; candidate.UpdatedOn = DateTime.Now; string result = CandidateController.Insert(candidate, ref con, ref MyTran); if (result == "300") { return(StatusCode(501, "A candidate with " + value.Email + " already exist")); } int CandidateID = Int32.Parse(JobStation.DatabaseCommands.GetLastInsertedID(ref con, ref MyTran).ToString()); if (CandidateID == 0) { return(StatusCode(500, "Error. ")); } jsonResult = CandidateID.ToString(); CreateCandidateProfileAsync(value, CandidateID); return(Ok(jsonResult)); } catch { return(StatusCode(500)); } finally { RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran); RTS.JobStation.DatabaseCommands.CloseConnection(ref con); } }
private void CreateCandidateProfile(CandidateCVInfo value, int CandidateID) { string conStr = configuration.GetSection("Data").GetSection("ConntectionString").Value; 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); //Add Work History, Employee Profile RTS.JobStation.Controller.Workhistory EmployeeProfileController = new RTS.JobStation.Controller.Workhistory(); RTS.JobStation.Models.Workhistory EmployeeProfileModel = new RTS.JobStation.Models.Workhistory(); foreach (var WorkHistory in value.EmployeeProfile) { EmployeeProfileModel.CandidateID = CandidateID; EmployeeProfileModel.CountryID = WorkHistory.CountryID; EmployeeProfileModel.Description = WorkHistory.Description; EmployeeProfileModel.Designation = WorkHistory.Designation; EmployeeProfileModel.Employer = WorkHistory.Employer; EmployeeProfileModel.GrossMonthlySalary = WorkHistory.GrossMonthlySalary; EmployeeProfileModel.isLatestJob = WorkHistory.isLatestJob; EmployeeProfileModel.ReasonForLeaving = WorkHistory.ReasonForLeaving; EmployeeProfileModel.ReportingTo = WorkHistory.ReportingTo; EmployeeProfileModel.ToDate = WorkHistory.ToDate; EmployeeProfileModel.FromDate = WorkHistory.FromDate; EmployeeProfileModel.UpdatedBy = Request.Headers["userid"]; EmployeeProfileModel.UpdatedOn = DateTime.Now; EmployeeProfileController.Insert(EmployeeProfileModel, ref con, ref MyTran); } //Add Education History, Education Profile RTS.JobStation.Controller.Educationhistory EducationHistoryController = new RTS.JobStation.Controller.Educationhistory(); RTS.JobStation.Models.Educationhistory EducationHistoryModel = new RTS.JobStation.Models.Educationhistory(); foreach (var EducationHistory in value.EducationProfile) { EducationHistoryModel.CandidateID = CandidateID; EducationHistoryModel.CompletionYear = EducationHistory.CompletionYear; EducationHistoryModel.CountryID = EducationHistory.CountryID; EducationHistoryModel.Description = EducationHistory.Description; EducationHistoryModel.EducationQualificationID = EducationHistory.EducationQualificationID; EducationHistoryModel.ExamResult = EducationHistory.ExamResult; EducationHistoryModel.Institute = EducationHistory.Institute; EducationHistoryModel.UpdatedBy = Request.Headers["userid"]; EducationHistoryModel.UpdatedOn = DateTime.Now; EducationHistoryController.Insert(EducationHistoryModel, ref con, ref MyTran); } //Add Preffered Location RTS.JobStation.Controller.Candidateprefferedlocation CandidatePrefferedLocationController = new RTS.JobStation.Controller.Candidateprefferedlocation(); RTS.JobStation.Models.Candidateprefferedlocation CandidatePrefferedLocationModel = new RTS.JobStation.Models.Candidateprefferedlocation(); foreach (var Location in value.PrefferedLocation) { CandidatePrefferedLocationModel.CandidateID = CandidateID; CandidatePrefferedLocationModel.LocationID = Location.LocationID; CandidatePrefferedLocationModel.UpdatedBy = Request.Headers["userid"]; CandidatePrefferedLocationModel.UpdatedOn = DateTime.Now; CandidatePrefferedLocationController.Insert(CandidatePrefferedLocationModel, ref con, ref MyTran); } //Add Job Industry RTS.JobStation.Controller.Candidatejobindustry CandidatejobindustryController = new RTS.JobStation.Controller.Candidatejobindustry(); RTS.JobStation.Models.Candidatejobindustry CandidatejobindustryModel = new RTS.JobStation.Models.Candidatejobindustry(); foreach (var Industry in value.JobIndustry) { CandidatejobindustryModel.CandidateID = CandidateID; CandidatejobindustryModel.IndustryID = Industry.IndustryID; CandidatejobindustryModel.UpdatedBy = Request.Headers["userid"]; CandidatejobindustryModel.UpdatedOn = DateTime.Now; CandidatejobindustryController.Insert(CandidatejobindustryModel, ref con, ref MyTran); } } catch { } finally { RTS.JobStation.DatabaseCommands.CloseTransaction(ref MyTran); RTS.JobStation.DatabaseCommands.CloseConnection(ref con); }; }