@@ -21,7 +21,37 @@
Description
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -124,14 +154,16 @@
private async Task OnSubmit()
{
- var sub = SubscriptionRepository.Add(new()
- {
- Name = Model.Name,
- Description = Model.Description
- });
+ var sub = await SubscriptionService.Create(
+ Model.Name,
+ Model.Description,
+ Model.Currency,
+ Model.Price,
+ Model.Duration
+ );
+
+ await SubscriptionService.UpdateLimits(sub, Limits.ToArray());
- await SubscriptionAdminService.SaveLimits(sub, Limits.ToArray());
-
NavigationManager.NavigateTo("/admin/subscriptions");
}
}
\ No newline at end of file
diff --git a/Moonlight/Shared/Views/Domains/Create.razor b/Moonlight/Shared/Views/Domains/Create.razor
index d731acda..e5efd8ea 100644
--- a/Moonlight/Shared/Views/Domains/Create.razor
+++ b/Moonlight/Shared/Views/Domains/Create.razor
@@ -130,12 +130,12 @@
Model = new();
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
- Subscription = await SubscriptionService.GetCurrent();
+ Subscription = await SubscriptionService.GetActiveSubscription(User);
AllowOrder = DomainRepository
.Get()
.Include(x => x.Owner)
- .Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit("domains")).Amount;
+ .Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "domains")).Amount;
await lazyLoader.SetText("Loading shared domains");
SharedDomains = SharedDomainRepository.Get().ToArray();
@@ -146,7 +146,7 @@
if (DomainRepository
.Get()
.Include(x => x.Owner)
- .Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit("domains")).Amount)
+ .Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "domains")).Amount)
{
var domain = await DomainService.Create(Model.Name, Model.SharedDomain, User);
diff --git a/Moonlight/Shared/Views/Profile/Subscriptions.razor b/Moonlight/Shared/Views/Profile/Subscriptions.razor
deleted file mode 100644
index ed0cb110..00000000
--- a/Moonlight/Shared/Views/Profile/Subscriptions.razor
+++ /dev/null
@@ -1,111 +0,0 @@
-@page "/profile/subscriptions"
-
-@using Moonlight.Shared.Components.Navigations
-@using Moonlight.App.Services
-@using Moonlight.App.Database.Entities
-@using Moonlight.App.Helpers
-@using Moonlight.App.Services.Interop
-
-@inject ConfigService ConfigService
-@inject AlertService AlertService
-@inject SubscriptionService SubscriptionService
-@inject SmartTranslateService SmartTranslateService
-
-
-
-
-
-
-

-
-
-
-
- @if (Subscription == null)
- {
- var config = ConfigService
- .Get()
- .Moonlight.Subscriptions.SellPass;
-
- var enableSellpass = config.Enable;
- var url = config.Url;
-
-
-
-
-
-
-
-
-
- if (enableSellpass)
- {
-
- }
- }
- else
- {
- var d = User.SubscriptionSince.AddDays(User.SubscriptionDuration).ToUniversalTime();
-
-
- Active until @(Formatter.FormatDateOnly(d))
-
-
- Current subscription: @(Subscription.Name)
-
-
- @(Subscription.Description)
-
-
- We will send you a notification upon subscription expiration
-
-
-
-
-
- }
-
-
-
-
-
-
-@code
-{
- [CascadingParameter]
- public User User { get; set; }
-
- private Subscription? Subscription;
- private LazyLoader LazyLoader;
-
- private string Code = "";
-
- private async Task Load(LazyLoader arg)
- {
- Subscription = await SubscriptionService.GetCurrent();
- }
-
- private async Task Cancel()
- {
- if (await AlertService.ConfirmMath())
- {
- await SubscriptionService.Cancel();
- await LazyLoader.Reload();
- }
- }
-
- private async Task OnSubmit()
- {
- await SubscriptionService.ApplyCode(Code);
- Code = "";
- await LazyLoader.Reload();
- }
-}
\ No newline at end of file
diff --git a/Moonlight/Shared/Views/Profile/Subscriptions/Close.razor b/Moonlight/Shared/Views/Profile/Subscriptions/Close.razor
new file mode 100644
index 00000000..458e1c74
--- /dev/null
+++ b/Moonlight/Shared/Views/Profile/Subscriptions/Close.razor
@@ -0,0 +1,5 @@
+@page "/profile/subscriptions/close"
+
+
\ No newline at end of file
diff --git a/Moonlight/Shared/Views/Profile/Subscriptions/Index.razor b/Moonlight/Shared/Views/Profile/Subscriptions/Index.razor
new file mode 100644
index 00000000..678f0230
--- /dev/null
+++ b/Moonlight/Shared/Views/Profile/Subscriptions/Index.razor
@@ -0,0 +1,170 @@
+@page "/profile/subscriptions"
+
+@using Moonlight.Shared.Components.Navigations
+@using Moonlight.App.Services
+@using Moonlight.App.Database.Entities
+@using Moonlight.App.Helpers
+@using Moonlight.App.Repositories
+@using Moonlight.App.Services.Interop
+@using Markdig
+
+@inject BillingService BillingService
+@inject Repository
SubscriptionRepository
+@inject AlertService AlertService
+@inject PopupService PopupService
+@inject SubscriptionService SubscriptionService
+@inject SmartTranslateService SmartTranslateService
+
+
+
+
+ @if (CurrentSubscription == null)
+ {
+
+
+
+
+
+ Chose your plan
+
+
+ Select the perfect plan for your next project
+
+
+
+ @foreach (var subscription in Subscriptions)
+ {
+