//to update and make changes the details of the candidate // here the data for a particular id is selected and displayed public ActionResult Update(int id) { string query = "select * from Career_Candidate where candidate_id=@id"; var parameter = new SqlParameter("@id", id); Career_Candidate career_Candidate = db.Career_Candidates.SqlQuery(query, parameter).FirstOrDefault(); return(View(career_Candidate)); }
// functionality to show the candidates along with option to add and remove job for that particular candidate who is applying for jobs. public ActionResult Show(int id) { //here we are selecting one particular candidate for particular id. string main_query = "select * from Career_Candidate where candidate_id = @id"; var pk_parameter = new SqlParameter("@id", id); Career_Candidate career_Candidate = db.Career_Candidates.SqlQuery(main_query, pk_parameter).FirstOrDefault(); //here we are getting data from job table where the job id is referred by the candidate table using bridging table. string aside_query = "select * from Career_Job inner join Career_JobCareer_Candidate on Career_Job.job_id = Career_JobCareer_Candidate.Career_Job_job_id where Career_JobCareer_Candidate.Career_Candidate_candidate_id=@id"; var fk_parameter = new SqlParameter("@id", id); List <Career_Job> jobs = db.Career_Jobs.SqlQuery(aside_query, fk_parameter).ToList(); // here we filling the drop down to add more job which arenot yet applied by candidate string all_Career_Jobs_query = "select * from Career_Job"; List <Career_Job> Alljobs = db.Career_Jobs.SqlQuery(all_Career_Jobs_query).ToList(); //using viewmodel for showing candidates and all the available jobs. showCandidates viewmodel = new showCandidates(); viewmodel.Career_Candidate = career_Candidate; viewmodel.Career_Jobs = jobs; viewmodel.all_Career_Jobs = Alljobs; return(View(viewmodel)); }