♻️ No idea, but errors all gone
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Shared.Cache;
|
||||
using DysonNetwork.Shared.Localization;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Shared.Services;
|
||||
using DysonNetwork.Sphere.Localization;
|
||||
@@ -14,8 +15,9 @@ namespace DysonNetwork.Sphere.Wallet;
|
||||
public class SubscriptionService(
|
||||
AppDatabase db,
|
||||
PaymentService payment,
|
||||
DysonNetwork.Shared.Services.IAccountService account,
|
||||
DysonNetwork.Shared.Services.INotificationService nty,
|
||||
IAccountService accounts,
|
||||
IAccountProfileService profiles,
|
||||
INotificationService nty,
|
||||
IStringLocalizer<NotificationResource> localizer,
|
||||
IConfiguration configuration,
|
||||
ICacheService cache,
|
||||
@@ -23,7 +25,7 @@ public class SubscriptionService(
|
||||
)
|
||||
{
|
||||
public async Task<Subscription> CreateSubscriptionAsync(
|
||||
Shared.Models.Account account,
|
||||
Account account,
|
||||
string identifier,
|
||||
string paymentMethod,
|
||||
PaymentDetails paymentDetails,
|
||||
@@ -57,9 +59,7 @@ public class SubscriptionService(
|
||||
|
||||
if (subscriptionInfo.RequiredLevel > 0)
|
||||
{
|
||||
var profile = await db.AccountProfiles
|
||||
.Where(p => p.AccountId == account.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
var profile = await profiles.GetAccountProfileByIdAsync(account.Id);
|
||||
if (profile is null) throw new InvalidOperationException("Account profile was not found.");
|
||||
if (profile.Level < subscriptionInfo.RequiredLevel)
|
||||
throw new InvalidOperationException(
|
||||
@@ -141,7 +141,7 @@ public class SubscriptionService(
|
||||
if (!string.IsNullOrEmpty(provider))
|
||||
account = await accounts.LookupAccountByConnection(order.AccountId, provider);
|
||||
else if (Guid.TryParse(order.AccountId, out var accountId))
|
||||
account = await db.Accounts.FirstOrDefaultAsync(a => a.Id == accountId);
|
||||
account = await accounts.GetAccountById(accountId);
|
||||
|
||||
if (account is null)
|
||||
throw new InvalidOperationException($"Account was not found with identifier {order.AccountId}");
|
||||
@@ -302,9 +302,7 @@ public class SubscriptionService(
|
||||
|
||||
if (subscription.Identifier.StartsWith(SubscriptionType.StellarProgram))
|
||||
{
|
||||
await db.AccountProfiles
|
||||
.Where(a => a.AccountId == subscription.AccountId)
|
||||
.ExecuteUpdateAsync(s => s.SetProperty(a => a.StellarMembership, subscription.ToReference()));
|
||||
await profiles.UpdateStellarMembershipAsync(subscription.AccountId, subscription.ToReference());
|
||||
}
|
||||
|
||||
await NotifySubscriptionBegun(subscription);
|
||||
@@ -348,10 +346,10 @@ public class SubscriptionService(
|
||||
|
||||
private async Task NotifySubscriptionBegun(Subscription subscription)
|
||||
{
|
||||
var account = await db.Accounts.FirstOrDefaultAsync(a => a.Id == subscription.AccountId);
|
||||
var account = await accounts.GetAccountById(subscription.AccountId);
|
||||
if (account is null) return;
|
||||
|
||||
AccountService.SetCultureInfo(account);
|
||||
CultureInfoService.SetCultureInfo(account);
|
||||
|
||||
var humanReadableName =
|
||||
SubscriptionTypeData.SubscriptionHumanReadable.TryGetValue(subscription.Identifier, out var humanReadable)
|
||||
|
||||
Reference in New Issue
Block a user