From 5d8a5909bc2cfd446b6291c90e9b43950214aaca Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Mon, 25 Aug 2025 10:40:09 +0530 Subject: [PATCH] Added the check to check the ma user count --- Marco.Pms.Services/Controllers/TenantController.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Marco.Pms.Services/Controllers/TenantController.cs b/Marco.Pms.Services/Controllers/TenantController.cs index ccc2c26..de5cbe1 100644 --- a/Marco.Pms.Services/Controllers/TenantController.cs +++ b/Marco.Pms.Services/Controllers/TenantController.cs @@ -1146,6 +1146,14 @@ namespace Marco.Pms.Services.Controllers var currentSubscription = currentSubscriptionTask.Result; var utcNow = DateTime.UtcNow; + var activeUsers = await context.Employees.CountAsync(e => e.Email != null && e.ApplicationUserId != null); + + if (activeUsers < model.MaxUsers) + { + _logger.LogWarning("Employee {EmployeeId} add less max user than the active user in the tenant {TenantId}", loggedInEmployee.Id, tenant.Id); + return BadRequest(ApiResponse.ErrorResponse("Invalid Max user count", "Max User count must be higher than active user count", 400)); + } + // 6. If the tenant already has this plan, extend/renew it. if (currentSubscription != null && currentSubscription.PlanId == subscriptionPlan.Id) {