47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using UserService.DatabaseLayer.DataModels;
|
|
using UserService.DatabaseLayer.Repository;
|
|
|
|
namespace UserService.Pages
|
|
{
|
|
public class SecurityGroupsBase : ComponentBase
|
|
{
|
|
[Inject] private ISecurityGroupsRepository? SecurityGroupsRepository { get; set; }
|
|
[Inject] private IOrganizationUnitsRepository? OrganizationUnitsRepository { get; set; }
|
|
|
|
protected bool DialogIsOpen;
|
|
protected SecurityGroup? SecurityGroupToEdit;
|
|
|
|
protected IReadOnlyList<SecurityGroup>? SecurityGroups;
|
|
protected IReadOnlyList<OrganizationUnit>? OrganizationUnits;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
SecurityGroups = await SecurityGroupsRepository.GetAllAsync().ConfigureAwait(false);
|
|
OrganizationUnits = await OrganizationUnitsRepository.GetAllAsync().ConfigureAwait(false);
|
|
}
|
|
|
|
protected void EditSecurityGroup(SecurityGroup securityGroup)
|
|
{
|
|
SecurityGroupToEdit = securityGroup;
|
|
DialogIsOpen = true;
|
|
}
|
|
|
|
protected async Task OkClick()
|
|
{
|
|
if (!(SecurityGroupToEdit is null))
|
|
{
|
|
await SecurityGroupsRepository.UpdateAsync(SecurityGroupToEdit).ConfigureAwait(false);
|
|
}
|
|
|
|
DialogIsOpen = false;
|
|
}
|
|
|
|
protected async Task DeleteSecurityGroup(SecurityGroup securityGroup)
|
|
{
|
|
await SecurityGroupsRepository.DeleteAsync(securityGroup).ConfigureAwait(false);
|
|
}
|
|
}
|
|
} |