PlotDirector/PlotLine/ViewComponents/StoryElementReferencesViewComponent.cs
2026-12-05 17:22:38 +00:00

17 lines
595 B
C#

using Microsoft.AspNetCore.Mvc;
using PlotLine.Data;
using PlotLine.Services;
namespace PlotLine.ViewComponents;
public sealed class StoryElementReferencesViewComponent(
ICurrentUserService currentUser, StoryElementReferenceRepository references) : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(StoryElementType entityType, int entityId)
{
if (currentUser.UserId is not int userId) return Content("");
var model = await references.ListAsync(userId, new(entityType, entityId));
return model is null ? Content("") : View(model);
}
}