Hi All,
I'm Working on a project where Job ID and Resume ID are Primary Key and Resume ID is the Foreigh Key for Job Table. Resumes need to be mapped to different Job ID. How I can achieve it.
Also Once the Job gets closed Resume Should not be shown in other Jobs. How to achieve it in .Net MVS project.
Thanks in Advance
Akshaya

Aman GuptaRank #193 · 12.4K reputationPosted Aug 23, 2024, 1:50 AM EDT
Hi Akshaya,
To achieve the requirements in your .NET MVC project, here’s how you can approach it:
1. Database Design:
2. Mapping Resumes to Different Job IDs:
You would create or update records in the JobResumeMapping table to map resumes to different jobs.
Example method to map a resume to a job:
public void MapResumeToJob(int jobId, int resumeId) { using (var context = new YourDbContext()) { var mapping = new JobResumeMapping { JobID = jobId, ResumeID = resumeId }; context.JobResumeMappings.Add(mapping); context.SaveChanges(); } }3. Preventing Resume from Showing in Other Jobs Once the Job is Closed:
You should filter out resumes mapped to closed jobs.
Example of how to do it in a query:
var openJobsWithResumes = context.JobResumeMappings .Where(jrm => jrm.Job.JobStatus == "Active") .Include(jrm => jrm.Resume) .ToList();public void CloseJob(int jobId) { using (var context = new YourDbContext()) { var job = context.Jobs.Find(jobId); if (job != null) { job.JobStatus = "Closed"; context.SaveChanges(); } } }4. Ensure UI Logic:
@foreach (var job in Model.Jobs) { if (job.JobStatus == "Active") { // Display resumes mapped to this job } }5. Additional Considerations:
6. Business Logic in the Controller:
This setup should cover your needs for mapping resumes to different jobs while ensuring that once a job is closed, its associated resumes are no longer available for other jobs.