Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<IActionResult> FindJobs(int? id)
- {
- if (id == null)
- {
- return NotFound();
- }
- var volunteer = await _context.Volunteers
- .Include(v => v.TalentVolunteers)
- .ThenInclude(v => v.Talent)
- .FirstOrDefaultAsync(m => m.VolunteerID == id);
- if (volunteer == null)
- {
- return NotFound();
- }
- var jobs = new List<Job>();
- var talentVolunteers = new HashSet<int>(volunteer.TalentVolunteers.Select(t => t.TalentID));
- foreach (var talent in _context.JobTalents)
- {
- if (talentVolunteers.Contains(talent.TalentID))
- {
- var selectedJob = _context.Jobs
- .Include(t => t.JobTalents)
- .ThenInclude(v => v.Talent)
- .SingleOrDefault(t => t.JobID == talent.JobID);
- jobs.Add(selectedJob);
- }
- }
- var volunteersFindJobsViewModel = _mapper.Map<Volunteer, VolunteersFindJobsViewModel>(volunteer);
- volunteersFindJobsViewModel.Jobs = jobs;
- return View(volunteersFindJobsViewModel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement