public async Task <ActionResult <IEnumerable <RecruiterDTO> > > GetAllRecruiters() { var query = from recruiter in _context.Recruiters join recruiterUser in _context.Users on recruiter.UserId equals recruiterUser.Id join company in _context.Companies on recruiter.CompanyId equals company.CompanyId select new RecruiterDTO() { User = AuthController.UserToDTO(recruiterUser), Company = CompaniesController.CompanyToDTO(company) }; return(await query.ToListAsync()); }
public async Task <ActionResult <RecruiterDTO> > GetRecruiter(long companyId, string recruiterId) { var query = from recruiter in _context.Recruiters join recruiterUser in _context.Users on recruiter.UserId equals recruiterUser.Id join company in _context.Companies on recruiter.CompanyId equals company.CompanyId where recruiter.CompanyId == companyId && recruiter.UserId == recruiterId select new RecruiterDTO() { User = AuthController.UserToDTO(recruiterUser), Company = CompaniesController.CompanyToDTO(company) }; return(await query.FirstOrDefaultAsync()); }
private async Task <RecruiterDTO> RecruiterToDTO(Recruiter recruiterInfo) { var query = from recruiter in _context.Recruiters join recruiterUser in _context.Users on recruiter.UserId equals recruiterUser.Id join company in _context.Companies on recruiter.CompanyId equals company.CompanyId where recruiter.CompanyId == recruiterInfo.CompanyId && recruiter.UserId == recruiterInfo.UserId select new RecruiterDTO() { User = AuthController.UserToDTO(recruiterUser), Company = CompaniesController.CompanyToDTO(company) }; return(await query.FirstOrDefaultAsync()); }