using Microsoft.AspNetCore.Mvc; using PlotLine.Data; using PlotLine.Services; using PlotLine.ViewModels; namespace PlotLine.ViewComponents; public sealed class StoryElementReferencesViewComponent( ICurrentUserService currentUser, StoryElementReferenceRepository references, IProjectCollaborationRepository collaboration, ISubscriptionService subscriptions) : ViewComponent { public async Task InvokeAsync(StoryElementType entityType, int entityId, CharacterDetailViewModel? characterGallery = null, int galleryPages = 1) { if (currentUser.UserId is not int userId) return Content(""); var model = await references.ListAsync(userId, new(entityType, entityId)); return model is null ? Content("") : View(new StoryElementReferenceWorkspace(model, await StoryElementReferenceWorkspace.ReadStorageAsync(model, userId, collaboration, subscriptions), characterGallery, galleryPages)); } }