// GET candidate by id public InterviewCandidate Get(string id) { IList <InterviewCandidate> allCandidates = service.GetAllCandidates(); InterviewCandidate candidate = allCandidates.Where(c => c.Id == id).FirstOrDefault(); return(candidate); }
// delete the candidate public void Delete(string id) { IList <InterviewCandidate> allCandidates = service.GetAllCandidates(); InterviewCandidate candidate = allCandidates.Where(c => c.Id == id).FirstOrDefault(); allCandidates.Remove(candidate); // call the service method to delete the values. service.SaveChanges(allCandidates); }
// update existing candidate public void Put(InterviewCandidate candidate) { //sample logic IList <InterviewCandidate> allCandidates = service.GetAllCandidates(); InterviewCandidate oldCandidateData = allCandidates.Where(c => c.Id == candidate.Id).FirstOrDefault(); allCandidates.Remove(oldCandidateData); allCandidates.Add(candidate); // call the service method to update the values. service.SaveChanges(allCandidates); }
// Add new candidate public void Post([FromBody] InterviewCandidate candidate) { // call the service method to save the values. //sample logic IList <InterviewCandidate> allCandidates = service.GetAllCandidates(); allCandidates.Add(candidate); // call the service method to save the values. service.SaveChanges(allCandidates); }