? OrganizationUnits { get; private set; }
+
+ protected override async Task OnInitializedAsync()
+ {
+ OrganizationUnits = await OrganizationUnitsRepository.GetAllAsync().ConfigureAwait(false);
+ }
+
+ protected void Edit(OrganizationUnit organizationUnit)
+ {
+ DialogIsOpen = true;
+ OuToEdit = organizationUnit;
+ }
+
+ protected async Task OkClick()
+ {
+ if (OuToEdit is null) return;
+ await OrganizationUnitsRepository.UpdateAsync(OuToEdit).ConfigureAwait(false);
+ DialogIsOpen = false;
+ }
+
+ protected async Task Delete(OrganizationUnit organizationUnit)
+ {
+ await OrganizationUnitsRepository.DeleteAsync(organizationUnit).ConfigureAwait(false);
+ }
+ }
+}
\ No newline at end of file
diff --git a/UserService/Pages/SecurityGroups.razor b/UserService/Pages/SecurityGroups.razor
index 4b3ac83..fdbfba0 100644
--- a/UserService/Pages/SecurityGroups.razor
+++ b/UserService/Pages/SecurityGroups.razor
@@ -1,13 +1,11 @@
@page "/securitygroups"
@using UserService.DatabaseLayer.DataModels
@using UserService.DatabaseLayer.Repository
-@inject ISecurityGroupsRepository SecurityGroupsRepository
-@inject IOrganizationUnitsRepository OrganizationUnits
-
+@inherits SecurityGroupsBase
Table of all security groups
-@if (_securityGroups == null)
+@if (SecurityGroups is null)
{
Loading...
@@ -15,7 +13,7 @@
}
else
{
-
+
| Common Name |
Description |
@@ -37,17 +35,17 @@ else
EditSecurityGroup(new SecurityGroup()))">Create new group
}
-
- @if (_securityGroupToEdit != null)
+
+ @if (SecurityGroupToEdit != null)
{
- @(_securityGroupToEdit.Id == 0 ? "New" : "Edit") @_securityGroupToEdit.CommonName (@_securityGroupToEdit.Id)
+ @(SecurityGroupToEdit.Id == 0 ? "New" : "Edit") @SecurityGroupToEdit.CommonName (@SecurityGroupToEdit.Id)
-
+
-
-
+
+
-
+
}
else
@@ -55,41 +53,7 @@ else
No securityGroup selected
}
- No Thanks
+ No Thanks
OK
-
-
-
-@code {
- bool _dialogIsOpen;
- SecurityGroup _securityGroupToEdit;
-
- private IReadOnlyList _securityGroups;
- private IReadOnlyList _organizationUnits;
-
- protected override async Task OnInitializedAsync()
- {
- _securityGroups = await SecurityGroupsRepository.GetAllAsync();
- _organizationUnits = await OrganizationUnits.GetAllAsync().ConfigureAwait(false);
- }
-
- private void EditSecurityGroup(SecurityGroup securityGroup)
- {
- _dialogIsOpen = true;
- _securityGroupToEdit = (SecurityGroup)securityGroup.Clone();
- }
-
- async Task OkClick()
- {
- await SecurityGroupsRepository.UpdateAsync(_securityGroupToEdit).ConfigureAwait(false);
- await OnInitializedAsync().ConfigureAwait(false);
- _dialogIsOpen = false;
- }
-
- private async Task DeleteSecurityGroup(SecurityGroup securityGroup)
- {
- await SecurityGroupsRepository.DeleteAsync(securityGroup).ConfigureAwait(false);
- await OnInitializedAsync().ConfigureAwait(false);
- }
-}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/UserService/Pages/SecurityGroups.razor.cs b/UserService/Pages/SecurityGroups.razor.cs
new file mode 100644
index 0000000..b1269ba
--- /dev/null
+++ b/UserService/Pages/SecurityGroups.razor.cs
@@ -0,0 +1,47 @@
+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? SecurityGroups;
+ protected IReadOnlyList? 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/UserService/Pages/Users.razor b/UserService/Pages/Users.razor
index 09d15e9..6bc2fd3 100644
--- a/UserService/Pages/Users.razor
+++ b/UserService/Pages/Users.razor
@@ -43,16 +43,16 @@ else
{
@(UserToEdit.Id == 0 ? "New" : "Edit") @UserToEdit.CommonName (@UserToEdit.Id)
-
-
+
+
-
-
+
+
-
-
+
+
-
+
}
else
diff --git a/UserService/Pages/Users.razor.cs b/UserService/Pages/Users.razor.cs
index e7b9666..8aac50e 100644
--- a/UserService/Pages/Users.razor.cs
+++ b/UserService/Pages/Users.razor.cs
@@ -33,14 +33,12 @@ namespace UserService.Pages
{
if (UserToEdit is null) return;
await UsersRepository.UpdateAsync(UserToEdit).ConfigureAwait(false);
- await OnInitializedAsync().ConfigureAwait(false);
DialogIsOpen = false;
}
protected async Task DeleteUser(User user)
{
await UsersRepository.DeleteAsync(user).ConfigureAwait(false);
- await OnInitializedAsync().ConfigureAwait(false);
}
}
}
\ No newline at end of file
diff --git a/UserService/Shared/NavMenu.razor b/UserService/Shared/NavMenu.razor
index 86cbcad..d1a68c0 100644
--- a/UserService/Shared/NavMenu.razor
+++ b/UserService/Shared/NavMenu.razor
@@ -23,6 +23,11 @@
Security groups
+
+
+ Organization units
+
+
Directory
@@ -40,4 +45,5 @@
{
_collapseNavMenu = !_collapseNavMenu;
}
-}
+
+}
\ No newline at end of file