private static void CheckSubscriptionStart(SubscribableEdition edition, SubscriptionStartType subscriptionStartType) { switch (subscriptionStartType) { case SubscriptionStartType.Free: if (!edition.IsFree) { throw new Exception("This is not a free edition !"); } break; case SubscriptionStartType.Trial: if (!edition.HasTrial()) { throw new Exception("Trial is not available for this edition !"); } break; case SubscriptionStartType.Paid: if (edition.IsFree) { throw new Exception("This is a free edition and cannot be subscribed as paid !"); } break; } }
private async Task CheckEditionSubscriptionAsync(int editionId, SubscriptionStartType subscriptionStartType, SubscriptionPaymentGatewayType?gateway, string paymentId) { var edition = await _editionManager.GetByIdAsync(editionId) as SubscribableEdition; CheckSubscriptionStart(edition, subscriptionStartType); CheckPaymentCache(edition, subscriptionStartType, gateway, paymentId); }
private async Task <bool> IsNewRegisteredTenantActiveByDefault(SubscriptionStartType subscriptionStartType) { if (subscriptionStartType == SubscriptionStartType.Paid) { return(false); } return(await SettingManager.GetSettingValueForApplicationAsync <bool>(AppSettings.TenantManagement.IsNewRegisteredTenantActiveByDefault)); }
private void CheckPaymentCache(SubscribableEdition edition, SubscriptionStartType subscriptionStartType, SubscriptionPaymentGatewayType?gateway, string paymentId) { if (edition.IsFree || subscriptionStartType != SubscriptionStartType.Paid) { return; } if (!gateway.HasValue) { throw new Exception("Gateway cannot be empty !"); } if (paymentId.IsNullOrEmpty()) { throw new Exception("PaymentId cannot be empty !"); } var paymentCacheItem = _paymentCache.GetCacheItemOrNull(gateway.Value, paymentId); if (paymentCacheItem == null) { throw new UserFriendlyException(L("PaymentMightBeExpiredWarning")); } }
private async Task CheckEditionSubscriptionAsync(int editionId, SubscriptionStartType subscriptionStartType) { var edition = await _editionManager.GetByIdAsync(editionId) as SubscribableEdition; CheckSubscriptionStart(edition, subscriptionStartType); }