17 lines
595 B
C#
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);
|
|
}
|
|
}
|