From 7a8cd13c2dc2c230c5be7ca2b645a9539c4e393a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Sun, 26 Jul 2020 22:05:32 +0200 Subject: [PATCH] Testing devexpress --- .../Repository/Repository.cs | 10 +--- UserService.Test/Startup.DevExpress.cs | 27 ++++++++++ UserService.db | Bin 40960 -> 40960 bytes UserService/Pages/Counter.razor | 49 +++++++++++++++--- UserService/Pages/_Host.cshtml | 47 +++++++++-------- UserService/Program.cs | 8 --- UserService/Startup.DevExpress.cs | 27 ++++++++++ UserService/UserService.csproj | 3 +- UserService/_Imports.razor | 3 +- 9 files changed, 126 insertions(+), 48 deletions(-) create mode 100644 UserService.Test/Startup.DevExpress.cs create mode 100644 UserService/Startup.DevExpress.cs diff --git a/UserService.DatabaseLayer/Repository/Repository.cs b/UserService.DatabaseLayer/Repository/Repository.cs index 346cea0..fbde753 100644 --- a/UserService.DatabaseLayer/Repository/Repository.cs +++ b/UserService.DatabaseLayer/Repository/Repository.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using System.Runtime.CompilerServices; using System.Threading; @@ -33,15 +32,8 @@ namespace UserService.DatabaseLayer.Repository public class NodesRepository : INodesRepository { - private readonly IUsersRepository _users; - private readonly ISecurityGroupsRepository _securityGroups; - private readonly IOrganizationUnitsRepository _organizationUnits; - - public NodesRepository(IUsersRepository users, ISecurityGroupsRepository securityGroups, IOrganizationUnitsRepository organizationUnits) + public NodesRepository() { - _users = users; - _securityGroups = securityGroups; - _organizationUnits = organizationUnits; } public static async IAsyncEnumerable GetNodesAsync([EnumeratorCancellation] CancellationToken token = default) diff --git a/UserService.Test/Startup.DevExpress.cs b/UserService.Test/Startup.DevExpress.cs new file mode 100644 index 0000000..dc1ede5 --- /dev/null +++ b/UserService.Test/Startup.DevExpress.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// Generated by the DevExpress.Blazor package. +// To prevent this operation, add the DxExtendStartupHost property to the project and set this property to False. +// +// UserService.Test.csproj: +// +// +// +// netcoreapp3.1 +// False +// +//------------------------------------------------------------------------------ +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting; + +[assembly: HostingStartup(typeof(UserService.Test.DevExpressHostingStartup))] + +namespace UserService.Test { + public partial class DevExpressHostingStartup : IHostingStartup { + void IHostingStartup.Configure(IWebHostBuilder builder) { + builder.ConfigureServices((serviceCollection) => { + serviceCollection.AddDevExpressBlazor(); + }); + } + } +} diff --git a/UserService.db b/UserService.db index e7d1466056b24ebcc496b6475b82b5a899bdc834..d2cb7d36795a5c6f762381f817e9617793982af9 100644 GIT binary patch delta 161 zcmZoTz|?SnX#p z@c-uj#(!=zPr(6x7G`D!&dHbRjl?+luRtU|^1tDK&i{!2F8>YwD?l4}K@@Gi(XSx@ E09JD|KL7v# delta 99 zcmZoTz|?SnX#xA^P$L;2S7Yw};?U%gpSU@G6{wRV1jj2xT)_;V<5 zaPVJZ;Q!74Z8KlN0se^rY?Ck58;Nl6-vA5pf8>9||D693|6TqYK&=P(H{a;j5C8y} C%p?y0 diff --git a/UserService/Pages/Counter.razor b/UserService/Pages/Counter.razor index 974a852..e90f305 100644 --- a/UserService/Pages/Counter.razor +++ b/UserService/Pages/Counter.razor @@ -1,6 +1,7 @@ @page "/counter" @using UserService.DatabaseLayer.DataModels @using UserService.DatabaseLayer.Repository +@using System.Collections @inject IOrganizationUnitsRepository OuRepository

Tree

@@ -13,18 +14,52 @@ } else { - - @foreach (var unit in _organizationUnits) - { - - } - + + + + + + + + + + + } @code { private IReadOnlyList _organizationUnits; + private OrganizationUnit _selectedOu; protected override async Task OnInitializedAsync() { - _organizationUnits = await OuRepository.GetAllAsync().ConfigureAwait(false); + _organizationUnits = (await OuRepository.GetAllAsync().ConfigureAwait(false)).Where(x=> x.Parent is null).ToList(); } + + private void OnSelectionChanged(TreeViewNodeEventArgs args) + { + _selectedOu = args.NodeInfo.DataItem as OrganizationUnit; + } + + private IEnumerable GetNodeChildren(object dataItem) + { + if (dataItem is OrganizationUnit organizationUnit) + { + foreach (var organizationUnitChild in organizationUnit.Children) + { + yield return organizationUnitChild; + } + } + } + } \ No newline at end of file diff --git a/UserService/Pages/_Host.cshtml b/UserService/Pages/_Host.cshtml index daa62cf..69260ac 100644 --- a/UserService/Pages/_Host.cshtml +++ b/UserService/Pages/_Host.cshtml @@ -8,31 +8,34 @@ - - + + UserService - - - + + + - + + - - - + + + -
- - An error has occurred. This application may no longer respond until reloaded. - - - An unhandled exception has occurred. See browser dev tools for details. - - Reload - 🗙 -
- - +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + - + \ No newline at end of file diff --git a/UserService/Program.cs b/UserService/Program.cs index 7038d68..c911c91 100644 --- a/UserService/Program.cs +++ b/UserService/Program.cs @@ -1,13 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace UserService { diff --git a/UserService/Startup.DevExpress.cs b/UserService/Startup.DevExpress.cs new file mode 100644 index 0000000..be84994 --- /dev/null +++ b/UserService/Startup.DevExpress.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// Generated by the DevExpress.Blazor package. +// To prevent this operation, add the DxExtendStartupHost property to the project and set this property to False. +// +// UserService.csproj: +// +// +// +// netcoreapp3.1 +// False +// +//------------------------------------------------------------------------------ +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting; + +[assembly: HostingStartup(typeof(UserService.DevExpressHostingStartup))] + +namespace UserService { + public partial class DevExpressHostingStartup : IHostingStartup { + void IHostingStartup.Configure(IWebHostBuilder builder) { + builder.ConfigureServices((serviceCollection) => { + serviceCollection.AddDevExpressBlazor(); + }); + } + } +} diff --git a/UserService/UserService.csproj b/UserService/UserService.csproj index 5633dec..6788a02 100644 --- a/UserService/UserService.csproj +++ b/UserService/UserService.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -6,6 +6,7 @@ + diff --git a/UserService/_Imports.razor b/UserService/_Imports.razor index 2e8ba2a..1fcb4a1 100644 --- a/UserService/_Imports.razor +++ b/UserService/_Imports.razor @@ -7,4 +7,5 @@ @using Microsoft.JSInterop @using UserService @using UserService.Shared -@using MatBlazor \ No newline at end of file +@using MatBlazor +@using DevExpress.Blazor \ No newline at end of file