feat: implement module purchase dialog with subscription type selection, auto-renew, and dependency checks, replacing the dedicated purchase page.
This commit is contained in:
@@ -244,7 +244,7 @@ public class ModulesController : ControllerBase
|
||||
Dependencies = module.GetDependencies().ToList(),
|
||||
RoutePath = module.RoutePath,
|
||||
IsAvailable = module.IsAvailable,
|
||||
IsEnabled = module.IsCore || (module.Subscription?.IsValid() ?? false),
|
||||
IsEnabled = module.IsCore || ((module.Subscription?.IsEnabled ?? false) && (module.Subscription?.IsValid() ?? false)),
|
||||
Subscription = module.Subscription != null ? MapSubscriptionToDto(module.Subscription) : null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ModuleService
|
||||
if (module.IsCore)
|
||||
return true;
|
||||
|
||||
return module.Subscription?.IsValid() ?? false;
|
||||
return (module.Subscription?.IsEnabled ?? false) && (module.Subscription?.IsValid() ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -200,7 +200,7 @@ public class ModuleService
|
||||
|
||||
// Verifica se altri moduli dipendono da questo
|
||||
var dependentModules = await GetDependentModulesAsync(code);
|
||||
var activeDependents = dependentModules.Where(m => m.Subscription?.IsValid() ?? false).ToList();
|
||||
var activeDependents = dependentModules.Where(m => (m.Subscription?.IsEnabled ?? false) && (m.Subscription?.IsValid() ?? false)).ToList();
|
||||
if (activeDependents.Any())
|
||||
throw new InvalidOperationException(
|
||||
$"I seguenti moduli attivi dipendono da questo modulo: {string.Join(", ", activeDependents.Select(m => m.Name))}");
|
||||
|
||||
@@ -72,9 +72,6 @@ public class ModuleSubscription : BaseEntity
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (!IsEnabled)
|
||||
return false;
|
||||
|
||||
// Se non c'è data di scadenza, è valido (licenza perpetua o core module)
|
||||
if (!EndDate.HasValue)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user