diff --git a/Marco.Pms.Services/Controllers/TenantController.cs b/Marco.Pms.Services/Controllers/TenantController.cs index b6b4ff4..e09fe35 100644 --- a/Marco.Pms.Services/Controllers/TenantController.cs +++ b/Marco.Pms.Services/Controllers/TenantController.cs @@ -932,6 +932,14 @@ namespace Marco.Pms.Services.Controllers return StatusCode(409, ApiResponse.ErrorResponse("Tenant cannot be created", "A user with the specified email already exists.", 409)); } + var industry = await context.Industries.FirstOrDefaultAsync(i => i.Id == model.IndustryId); + + if (industry == null) + { + _logger.LogWarning("Industry not found while creating the tenant enquire"); + return NotFound(ApiResponse.ErrorResponse("Industry not found", "Industry not found", 404)); + } + // Map DTO to domain model and assign new Guid var tenantEnquire = _mapper.Map(model); tenantEnquire.Id = Guid.NewGuid();