From 2996441f52474ed4e8f48ad36668c4f9dddb8cd5 Mon Sep 17 00:00:00 2001 From: cesnimda Date: Fri, 3 Jul 2026 03:56:06 +0200 Subject: [PATCH] perf: drop duplicated company-existence query in job Create The create path ran the same Companies.AnyAsync existence check twice. Co-Authored-By: Claude Fable 5 --- JobTrackerApi/Controllers/JobApplicationsController.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/JobTrackerApi/Controllers/JobApplicationsController.cs b/JobTrackerApi/Controllers/JobApplicationsController.cs index 4f0ba63..793df02 100644 --- a/JobTrackerApi/Controllers/JobApplicationsController.cs +++ b/JobTrackerApi/Controllers/JobApplicationsController.cs @@ -1405,9 +1405,7 @@ Canonical profile: if (title.Length == 0) return BadRequest("Job title is required."); if (request.CompanyId <= 0) return BadRequest("Valid companyId is required."); - var companyOk = await _db.Companies.AnyAsync(c => c.Id == request.CompanyId, cancellationToken); - if (!companyOk) return BadRequest("companyId does not exist."); - + // Scoped by the Company query filter, so this also rejects another user's companyId. var companyExists = await _db.Companies.AnyAsync(c => c.Id == request.CompanyId, cancellationToken); if (!companyExists) return BadRequest("companyId does not exist.");