Files
yavsc/src/Yavsc/ViewComponents/CirclesControlViewComponent.cs
Paul Schneider 3f1bfc1c3c
All checks were successful
Dotnet build and test / log-the-inputs (push) Successful in 5s
Dotnet build and test / build (push) Successful in 1m58s
fixies the refact of blog spot index
2025-06-29 19:53:56 +01:00

52 lines
1.5 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace Yavsc.ViewComponents
{
using Models;
using ViewModels.Controls;
using ViewModels.Relationship;
using Yavsc.Abstract.Identity.Security;
public class CirclesControlViewComponent : ViewComponent
{
private readonly ApplicationDbContext dbContext;
public CirclesControlViewComponent(ApplicationDbContext dbContext)
{
this.dbContext = dbContext;
}
public IViewComponentResult Invoke (ICircleAuthorized target)
{
if (target!=null)
{
var oid = target.AuthorId;
ViewBag.ACL = dbContext.Circle.Where(
c=>c.OwnerId == oid)
.Select(
c => new SelectListItem
{
Text = c.Name,
Value = c.Id.ToString(),
Selected = target.AuthorizeCircle(c.Id)
} 
);
ViewBag.Access = dbContext.Circle.Where(
c=>c.OwnerId == oid)
.Select( c=>
new AjaxCheckBoxInfo
{
Text = c.Name,
Checked = target.AuthorizeCircle(c.Id),
Value = c.Id.ToString()
});
}
return View(new CirclesViewModel(target));
}
}
}