PlotDirector/PlotLine/Services/StoryElementReferenceWorkspace.cs

20 lines
867 B
C#

using PlotLine.Data;
using PlotLine.Models;
using PlotLine.ViewModels;
namespace PlotLine.Services;
public sealed record StoryElementReferenceWorkspace(StoryElementReferenceList References, StorageUsage? Storage,
CharacterDetailViewModel? CharacterGallery = null, int GalleryPages = 1)
{
public static async Task<StorageUsage?> ReadStorageAsync(StoryElementReferenceList references,
int userId, IProjectCollaborationRepository collaboration, ISubscriptionService subscriptions)
{
// Account-level totals belong to the account owner, even on a shared project.
var owner = await collaboration.GetOwnerUserIdAsync(references.Access.ProjectID);
if (owner != userId) return null;
try { return await subscriptions.GetStorageUsageAsync(owner.Value); }
catch (SubscriptionLimitException) { return null; }
}
}