-
-
Save DeebiKaaRaviSankar/057eceab2cbbc8e645473ec04d48ec05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Authorize(Roles = DbConstants.Role_JobSeeker)] | |
// To get all non applied posted jobs | |
[HttpGet(DbConstants.Route_PostJobList + "/" + DbConstants.Route_GetNonAppliedJob)] | |
public async Task<List<PostJobResponseDTO>> GetNonAppliedPostJobs([FromQuery] SieveModel sieveModel) | |
{ | |
var user_id = _controllerService.GetUserId(HttpContext); | |
var appliedJobs = await _mapper.ProjectTo<AppliedJobResponseDTO>(_context.Users.AsNoTracking().Where(u => u.Id == user_id && !u.isDeleted) | |
.SelectMany(j => j.AppliedJobs) | |
.OrderByDescending(j => j.AppliedJobId)) | |
.ToListAsync(); | |
var postJobList = _context.PostJobDetails.AsNoTracking().Where(j => j.isDeleted == false); | |
postJobList = _sieveProcessor.Apply(sieveModel, postJobList); | |
var temp_postjobs = _mapper.Map<List<PostJobResponseDTO>>(postJobList); | |
List<int> appliedPostJobId = new List<int>(); | |
foreach (var appliedJob in appliedJobs) | |
{ | |
appliedPostJobId.Add(appliedJob.PostJobId); | |
} | |
temp_postjobs.ForEach(val => | |
{ | |
if (!appliedPostJobId.Contains(val.PostJobDetailId)) | |
{ | |
var employerProfile = _context.EmployerProfiles.Find(val.EmployerId); | |
var profilePicture = _context.ProfilePictures.Find(val.EmployerId); | |
if (employerProfile != null && profilePicture != null && !employerProfile.isDeleted) | |
{ | |
val.CompanyName = employerProfile.CompanyName!; | |
val.CompanyProfilePicture = profilePicture.ImagePath; | |
_postJobsResponse.Add(val); | |
} | |
} | |
} | |
); | |
return await Task.FromResult(_postJobsResponse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment