diff --git a/src/EventHub.Domain.Shared/EventHubDomainSharedModule.cs b/src/EventHub.Domain.Shared/EventHubDomainSharedModule.cs index f686ff2..9cd1cad 100644 --- a/src/EventHub.Domain.Shared/EventHubDomainSharedModule.cs +++ b/src/EventHub.Domain.Shared/EventHubDomainSharedModule.cs @@ -1,4 +1,6 @@ +using System.Collections.Generic; using EventHub.Localization; +using EventHub.Organizations; using EventHub.Web; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AuditLogging; @@ -26,7 +28,7 @@ namespace EventHub typeof(AbpSettingManagementDomainSharedModule), typeof(BlobStoringDatabaseDomainSharedModule), typeof(PaymentDomainSharedModule) - )] + )] public class EventHubDomainSharedModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) @@ -58,8 +60,23 @@ namespace EventHub { options.MapCodeNamespace("EventHub", typeof(EventHubResource)); }); - + Configure(configuration.GetSection("AppUrls")); + + context.Services.AddOptions>() + .Bind(configuration.GetSection(OrganizationPlanInfoOptions.OrganizationPlanInfo)) + .Validate(config => + { + foreach (var planInfo in config) + { + if (planInfo.IsActive) + { + return planInfo.OnePremiumPeriodAsMonth > planInfo.CanBeExtendedAfterHowManyMonths; + } + } + + return true; + }, "OnePremiumPeriodAsMonth must be greater than CanBeExtendedAfterHowManyMonths."); } } -} +} \ No newline at end of file diff --git a/src/EventHub.Domain.Shared/Organizations/OrganizationPlanInfoOptions.cs b/src/EventHub.Domain.Shared/Organizations/OrganizationPlanInfoOptions.cs new file mode 100644 index 0000000..adb68ec --- /dev/null +++ b/src/EventHub.Domain.Shared/Organizations/OrganizationPlanInfoOptions.cs @@ -0,0 +1,27 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace EventHub.Organizations +{ + public class OrganizationPlanInfoOptions + { + public const string OrganizationPlanInfo = "Organization:PlanInfo"; + + public OrganizationPlanType PlanType { get; set; } + + [DefaultValue(true)] + public bool IsActive { get; set; } + + [Range(1.0, 100.0, ErrorMessage = "Value for {0} must be between {1} and {2}.")] + public float Price { get; set; } = 1.0f; + + [DefaultValue(true)] + public bool IsExtendable { get; set; } + + [Range(1, 12, ErrorMessage = "Value for {0} must be between {1} and {2}.")] + public int CanBeExtendedAfterHowManyMonths { get; set; } + + [Range(1, 24, ErrorMessage = "Value for {0} must be between {1} and {2}.")] + public int OnePremiumPeriodAsMonth { get; set; } + } +} \ No newline at end of file diff --git a/src/EventHub.Domain.Shared/Organizations/OrganizationPlanType.cs b/src/EventHub.Domain.Shared/Organizations/OrganizationPlanType.cs new file mode 100644 index 0000000..c48cdd7 --- /dev/null +++ b/src/EventHub.Domain.Shared/Organizations/OrganizationPlanType.cs @@ -0,0 +1,7 @@ +namespace EventHub.Organizations +{ + public enum OrganizationPlanType : byte + { + Premium, + } +} \ No newline at end of file