diff --git a/Marco.Pms.Model/TenantModels/SubscriptionPlan.cs b/Marco.Pms.Model/TenantModels/SubscriptionPlan.cs
index e4c1f37..4bdf838 100644
--- a/Marco.Pms.Model/TenantModels/SubscriptionPlan.cs
+++ b/Marco.Pms.Model/TenantModels/SubscriptionPlan.cs
@@ -10,6 +10,6 @@
public enum PLAN_FREQUENCY
{
- MONTHLY = 0, QUARTERLY = 1, HALF_MONTHLY = 2, YEARLY = 3
+ MONTHLY = 0, QUARTERLY = 1, HALF_YEARLY = 2, YEARLY = 3
}
}
diff --git a/Marco.Pms.Services/Controllers/TenantController.cs b/Marco.Pms.Services/Controllers/TenantController.cs
index 21fa0c8..c8e712b 100644
--- a/Marco.Pms.Services/Controllers/TenantController.cs
+++ b/Marco.Pms.Services/Controllers/TenantController.cs
@@ -69,6 +69,7 @@ namespace Marco.Pms.Services.Controllers
/// The number of records to return per page.
/// The page number to retrieve.
/// A paginated list of tenants matching the criteria.
+
[HttpGet("list")]
public async Task GetTenantList([FromQuery] string? searchString, string? filter, int pageSize = 20, int pageNumber = 1)
{
@@ -617,7 +618,7 @@ namespace Marco.Pms.Services.Controllers
{
PLAN_FREQUENCY.MONTHLY => utcNow.AddMonths(1),
PLAN_FREQUENCY.QUARTERLY => utcNow.AddMonths(3),
- PLAN_FREQUENCY.HALF_MONTHLY => utcNow.AddMonths(6),
+ PLAN_FREQUENCY.HALF_YEARLY => utcNow.AddMonths(6),
PLAN_FREQUENCY.YEARLY => utcNow.AddMonths(12),
_ => utcNow // default if unknown
};
@@ -845,7 +846,7 @@ namespace Marco.Pms.Services.Controllers
{
PLAN_FREQUENCY.MONTHLY => currentSubscription.EndDate.AddMonths(1),
PLAN_FREQUENCY.QUARTERLY => currentSubscription.EndDate.AddMonths(3),
- PLAN_FREQUENCY.HALF_MONTHLY => currentSubscription.EndDate.AddMonths(6),
+ PLAN_FREQUENCY.HALF_YEARLY => currentSubscription.EndDate.AddMonths(6),
PLAN_FREQUENCY.YEARLY => currentSubscription.EndDate.AddMonths(12),
_ => currentSubscription.EndDate
};
@@ -856,7 +857,7 @@ namespace Marco.Pms.Services.Controllers
{
PLAN_FREQUENCY.MONTHLY => utcNow.AddMonths(1),
PLAN_FREQUENCY.QUARTERLY => utcNow.AddMonths(3),
- PLAN_FREQUENCY.HALF_MONTHLY => utcNow.AddMonths(6),
+ PLAN_FREQUENCY.HALF_YEARLY => utcNow.AddMonths(6),
PLAN_FREQUENCY.YEARLY => utcNow.AddMonths(12),
_ => utcNow
};
@@ -891,7 +892,7 @@ namespace Marco.Pms.Services.Controllers
{
PLAN_FREQUENCY.MONTHLY => utcNow.AddMonths(1),
PLAN_FREQUENCY.QUARTERLY => utcNow.AddMonths(3),
- PLAN_FREQUENCY.HALF_MONTHLY => utcNow.AddMonths(6),
+ PLAN_FREQUENCY.HALF_YEARLY => utcNow.AddMonths(6),
PLAN_FREQUENCY.YEARLY => utcNow.AddMonths(12),
_ => utcNow
};
@@ -1047,8 +1048,6 @@ namespace Marco.Pms.Services.Controllers
}
}
-
-
#endregion
#region =================================================================== Subscription Plan APIs ===================================================================
@@ -1110,183 +1109,81 @@ namespace Marco.Pms.Services.Controllers
}
}
-
-
+ ///
+ /// Creates a new subscription plan with details for each frequency (monthly, quarterly, half-yearly, yearly).
+ /// Only employees with root status and 'ManageTenants' permission can create plans.
+ ///
[HttpPost("create/subscription-plan")]
- public async Task CreateSubscriptionPlan1([FromBody] SubscriptionPlanDto model)
+ public async Task CreateSubscriptionPlan([FromBody] SubscriptionPlanDto model)
{
+ // Step 1: Authenticate and check permissions
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
await using var _context = await _dbContextFactory.CreateDbContextAsync();
using var scope = _serviceScopeFactory.CreateScope();
-
var _permissionService = scope.ServiceProvider.GetRequiredService();
- // A root user should have access regardless of the specific permission.
+ // Permission check: root user or explicit ManageTenants permission
var isRootUser = loggedInEmployee.ApplicationUser?.IsRootUser ?? false;
var hasPermission = await _permissionService.HasPermission(PermissionsMaster.ManageTenants, loggedInEmployee.Id);
-
- if (!hasPermission || !isRootUser)
+ if (!(hasPermission && isRootUser))
{
- _logger.LogWarning("Permission denied: User {EmployeeId} attempted to list tenants without 'ManageTenants' permission or root access.", loggedInEmployee.Id);
+ _logger.LogWarning("Permission denied: User {EmployeeId} attempted to create a subscription plan.", loggedInEmployee.Id);
return StatusCode(403, ApiResponse