PlotDirector/PlotLine/ViewComponents/EntitlementBannerViewComponent.cs

21 lines
593 B
C#

using Microsoft.AspNetCore.Mvc;
using PlotLine.Services;
namespace PlotLine.ViewComponents;
public sealed class EntitlementBannerViewComponent(
ICurrentUserService currentUser,
ISubscriptionService subscriptions) : ViewComponent
{
public async Task<IViewComponentResult> InvokeAsync()
{
if (currentUser.UserId is not int userId)
{
return Content(string.Empty);
}
var entitlement = await subscriptions.GetEffectiveEntitlementAsync(userId);
return entitlement.IsReadOnly ? View(entitlement) : Content(string.Empty);
}
}