From 796a98dd89f0a7430c38d107c7d0e1f15bd79648 Mon Sep 17 00:00:00 2001 From: Adams Date: Mon, 7 Apr 2025 11:47:28 +0200 Subject: [PATCH] Add project files. --- AdamGais.Module.AnmeldeTool.sln | 46 ++++++ .../AdamGais.Module.AnmeldeTool.Client.csproj | 53 +++++++ Client/AssemblyInfo.cs | 4 + Client/Interop.cs | 15 ++ .../Anmeldetool.razor | 10 ++ .../AdamGais.Module.AnmeldeTool/Edit.razor | 112 +++++++++++++ .../AdamGais.Module.AnmeldeTool/Index.razor | 48 ++++++ .../AdamGais.Module.AnmeldeTool/ModuleInfo.cs | 19 +++ .../Settings.razor | 47 ++++++ Client/Properties/Resources.Designer.cs | 63 ++++++++ Client/Properties/Resources.resx | 101 ++++++++++++ .../Edit - Copy.resx | 141 +++++++++++++++++ .../AdamGais.Module.AnmeldeTool/Edit.resx | 141 +++++++++++++++++ .../AdamGais.Module.AnmeldeTool/Index.resx | 147 ++++++++++++++++++ .../AdamGais.Module.AnmeldeTool/Settings.resx | 126 +++++++++++++++ Client/Services/AnmeldeToolService.cs | 42 +++++ Client/Startup/ClientStartup.cs | 14 ++ Client/_Imports.razor | 24 +++ ...AdamGais.Module.AnmeldeTool.Package.csproj | 29 ++++ Package/AdamGais.Module.AnmeldeTool.nuspec | 32 ++++ Package/debug.cmd | 11 ++ Package/debug.sh | 12 ++ Package/icon.png | Bin 0 -> 7800 bytes Package/release.cmd | 7 + Package/release.sh | 5 + .../AdamGais.Module.AnmeldeTool.Server.csproj | 36 +++++ Server/Controllers/AnmeldeToolController.cs | 114 ++++++++++++++ Server/Manager/AnmeldeToolManager.cs | 87 +++++++++++ .../Migrations/01000000_InitializeModule.cs | 30 ++++ .../AnmeldeToolEntityBuilder.cs | 36 +++++ Server/Repository/AnmeldeToolContext.cs | 26 ++++ Server/Repository/AnmeldeToolRepository.cs | 65 ++++++++ Server/Repository/IAnmeldeToolRepository.cs | 15 ++ Server/Services/AnmeldeToolService.cs | 101 ++++++++++++ Server/Startup/ServerStartup.cs | 28 ++++ .../AdamGais.Module.AnmeldeTool/Module.css | 1 + .../AdamGais.Module.AnmeldeTool/Module.js | 5 + Server/wwwroot/_content/Placeholder.txt | 11 ++ .../AdamGais.Module.AnmeldeTool.Shared.csproj | 22 +++ Shared/Interfaces/IAnmeldeToolService.cs | 18 +++ Shared/Models/AnmeldeTool.cs | 21 +++ template.json | 6 + 42 files changed, 1871 insertions(+) create mode 100644 AdamGais.Module.AnmeldeTool.sln create mode 100644 Client/AdamGais.Module.AnmeldeTool.Client.csproj create mode 100644 Client/AssemblyInfo.cs create mode 100644 Client/Interop.cs create mode 100644 Client/Modules/AdamGais.Module.AnmeldeTool/Anmeldetool.razor create mode 100644 Client/Modules/AdamGais.Module.AnmeldeTool/Edit.razor create mode 100644 Client/Modules/AdamGais.Module.AnmeldeTool/Index.razor create mode 100644 Client/Modules/AdamGais.Module.AnmeldeTool/ModuleInfo.cs create mode 100644 Client/Modules/AdamGais.Module.AnmeldeTool/Settings.razor create mode 100644 Client/Properties/Resources.Designer.cs create mode 100644 Client/Properties/Resources.resx create mode 100644 Client/Resources/AdamGais.Module.AnmeldeTool/Edit - Copy.resx create mode 100644 Client/Resources/AdamGais.Module.AnmeldeTool/Edit.resx create mode 100644 Client/Resources/AdamGais.Module.AnmeldeTool/Index.resx create mode 100644 Client/Resources/AdamGais.Module.AnmeldeTool/Settings.resx create mode 100644 Client/Services/AnmeldeToolService.cs create mode 100644 Client/Startup/ClientStartup.cs create mode 100644 Client/_Imports.razor create mode 100644 Package/AdamGais.Module.AnmeldeTool.Package.csproj create mode 100644 Package/AdamGais.Module.AnmeldeTool.nuspec create mode 100644 Package/debug.cmd create mode 100644 Package/debug.sh create mode 100644 Package/icon.png create mode 100644 Package/release.cmd create mode 100644 Package/release.sh create mode 100644 Server/AdamGais.Module.AnmeldeTool.Server.csproj create mode 100644 Server/Controllers/AnmeldeToolController.cs create mode 100644 Server/Manager/AnmeldeToolManager.cs create mode 100644 Server/Migrations/01000000_InitializeModule.cs create mode 100644 Server/Migrations/EntityBuilders/AnmeldeToolEntityBuilder.cs create mode 100644 Server/Repository/AnmeldeToolContext.cs create mode 100644 Server/Repository/AnmeldeToolRepository.cs create mode 100644 Server/Repository/IAnmeldeToolRepository.cs create mode 100644 Server/Services/AnmeldeToolService.cs create mode 100644 Server/Startup/ServerStartup.cs create mode 100644 Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.css create mode 100644 Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.js create mode 100644 Server/wwwroot/_content/Placeholder.txt create mode 100644 Shared/AdamGais.Module.AnmeldeTool.Shared.csproj create mode 100644 Shared/Interfaces/IAnmeldeToolService.cs create mode 100644 Shared/Models/AnmeldeTool.cs create mode 100644 template.json diff --git a/AdamGais.Module.AnmeldeTool.sln b/AdamGais.Module.AnmeldeTool.sln new file mode 100644 index 0000000..bb60e93 --- /dev/null +++ b/AdamGais.Module.AnmeldeTool.sln @@ -0,0 +1,46 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Server", "..\oqtane.framework-dev\Oqtane.Server\Oqtane.Server.csproj", "{3AB6FCC9-EFEB-4C0E-A2CF-8103914C5196}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamGais.Module.AnmeldeTool.Client", "Client\AdamGais.Module.AnmeldeTool.Client.csproj", "{AA8E58A1-CD09-4208-BF66-A8BB341FD669}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamGais.Module.AnmeldeTool.Server", "Server\AdamGais.Module.AnmeldeTool.Server.csproj", "{04B05448-788F-433D-92C0-FED35122D45A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamGais.Module.AnmeldeTool.Shared", "Shared\AdamGais.Module.AnmeldeTool.Shared.csproj", "{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdamGais.Module.AnmeldeTool.Package", "Package\AdamGais.Module.AnmeldeTool.Package.csproj", "{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3AB6FCC9-EFEB-4C0E-A2CF-8103914C5196}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AB6FCC9-EFEB-4C0E-A2CF-8103914C5196}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Release|Any CPU.Build.0 = Release|Any CPU + {04B05448-788F-433D-92C0-FED35122D45A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04B05448-788F-433D-92C0-FED35122D45A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04B05448-788F-433D-92C0-FED35122D45A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04B05448-788F-433D-92C0-FED35122D45A}.Release|Any CPU.Build.0 = Release|Any CPU + {18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Release|Any CPU.Build.0 = Release|Any CPU + {C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1D016F15-46FE-4726-8DFD-2E4FD4DC7668} + EndGlobalSection +EndGlobal diff --git a/Client/AdamGais.Module.AnmeldeTool.Client.csproj b/Client/AdamGais.Module.AnmeldeTool.Client.csproj new file mode 100644 index 0000000..cf9533d --- /dev/null +++ b/Client/AdamGais.Module.AnmeldeTool.Client.csproj @@ -0,0 +1,53 @@ + + + + net9.0 + 1.0.0 + AdamGais + AdamGais + AnmeldeTool + AdamGais.Module.AnmeldeTool + AdamGais + AdamGais.Module.AnmeldeTool.Client.Oqtane + true + + + + + + + + + + + + + + + + ..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\net9.0\Oqtane.Client.dll + ..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + false + false + + + diff --git a/Client/AssemblyInfo.cs b/Client/AssemblyInfo.cs new file mode 100644 index 0000000..844cd36 --- /dev/null +++ b/Client/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Resources; +using Microsoft.Extensions.Localization; + +[assembly: RootNamespace("AdamGais.Module.AnmeldeTool.Client")] diff --git a/Client/Interop.cs b/Client/Interop.cs new file mode 100644 index 0000000..3ace4fa --- /dev/null +++ b/Client/Interop.cs @@ -0,0 +1,15 @@ +using Microsoft.JSInterop; +using System.Threading.Tasks; + +namespace AdamGais.Module.AnmeldeTool +{ + public class Interop + { + private readonly IJSRuntime _jsRuntime; + + public Interop(IJSRuntime jsRuntime) + { + _jsRuntime = jsRuntime; + } + } +} diff --git a/Client/Modules/AdamGais.Module.AnmeldeTool/Anmeldetool.razor b/Client/Modules/AdamGais.Module.AnmeldeTool/Anmeldetool.razor new file mode 100644 index 0000000..82adedf --- /dev/null +++ b/Client/Modules/AdamGais.Module.AnmeldeTool/Anmeldetool.razor @@ -0,0 +1,10 @@ +@namespace AdamGais.Module.AnmeldeTool +@inherits ModuleBase +@inject NavigationManager NavigationManager +@inject IStringLocalizer Localizer + +

ANMELDETOOL.razor!!!

+ +@code { + +} diff --git a/Client/Modules/AdamGais.Module.AnmeldeTool/Edit.razor b/Client/Modules/AdamGais.Module.AnmeldeTool/Edit.razor new file mode 100644 index 0000000..489a2dc --- /dev/null +++ b/Client/Modules/AdamGais.Module.AnmeldeTool/Edit.razor @@ -0,0 +1,112 @@ +@using Oqtane.Modules.Controls +@using AdamGais.Module.AnmeldeTool.Services +@using AdamGais.Module.AnmeldeTool.Models + +@namespace AdamGais.Module.AnmeldeTool +@inherits ModuleBase +@inject IAnmeldeToolService AnmeldeToolService +@inject NavigationManager NavigationManager +@inject IStringLocalizer Localizer + +
+
+
+ +
+ +
+
+
+ + @Localizer["Cancel"] +

+ @if (PageState.Action == "Edit") + { + + } +
+ +@code { + public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; + + public override string Actions => "Add,Edit"; + + public override string Title => "Manage AnmeldeTool"; + + public override List Resources => new List() + { + new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } + }; + + private ElementReference form; + private bool validated = false; + + private int _id; + private string _name; + private string _createdby; + private DateTime _createdon; + private string _modifiedby; + private DateTime _modifiedon; + + protected override async Task OnInitializedAsync() + { + try + { + if (PageState.Action == "Edit") + { + _id = Int32.Parse(PageState.QueryString["id"]); + AnmeldeTool AnmeldeTool = await AnmeldeToolService.GetAnmeldeToolAsync(_id, ModuleState.ModuleId); + if (AnmeldeTool != null) + { + _name = AnmeldeTool.Name; + _createdby = AnmeldeTool.CreatedBy; + _createdon = AnmeldeTool.CreatedOn; + _modifiedby = AnmeldeTool.ModifiedBy; + _modifiedon = AnmeldeTool.ModifiedOn; + } + } + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Loading AnmeldeTool {AnmeldeToolId} {Error}", _id, ex.Message); + AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error); + } + } + + private async Task Save() + { + try + { + validated = true; + var interop = new Oqtane.UI.Interop(JSRuntime); + if (await interop.FormValid(form)) + { + if (PageState.Action == "Add") + { + AnmeldeTool AnmeldeTool = new AnmeldeTool(); + AnmeldeTool.ModuleId = ModuleState.ModuleId; + AnmeldeTool.Name = _name; + AnmeldeTool = await AnmeldeToolService.AddAnmeldeToolAsync(AnmeldeTool); + await logger.LogInformation("AnmeldeTool Added {AnmeldeTool}", AnmeldeTool); + } + else + { + AnmeldeTool AnmeldeTool = await AnmeldeToolService.GetAnmeldeToolAsync(_id, ModuleState.ModuleId); + AnmeldeTool.Name = _name; + await AnmeldeToolService.UpdateAnmeldeToolAsync(AnmeldeTool); + await logger.LogInformation("AnmeldeTool Updated {AnmeldeTool}", AnmeldeTool); + } + NavigationManager.NavigateTo(NavigateUrl()); + } + else + { + AddModuleMessage(Localizer["Message.SaveValidation"], MessageType.Warning); + } + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Saving AnmeldeTool {Error}", ex.Message); + AddModuleMessage(Localizer["Message.SaveError"], MessageType.Error); + } + } +} diff --git a/Client/Modules/AdamGais.Module.AnmeldeTool/Index.razor b/Client/Modules/AdamGais.Module.AnmeldeTool/Index.razor new file mode 100644 index 0000000..327b3b7 --- /dev/null +++ b/Client/Modules/AdamGais.Module.AnmeldeTool/Index.razor @@ -0,0 +1,48 @@ +@using AdamGais.Module.AnmeldeTool.Services +@using AdamGais.Module.AnmeldeTool.Models + +@namespace AdamGais.Module.AnmeldeTool +@inherits ModuleBase +@inject IAnmeldeToolService AnmeldeToolService +@inject NavigationManager NavigationManager +@inject IStringLocalizer Localizer + + + + + + + +

Anmeldung zum Event

+ +

Willst du am Event teilnehmen?

+ +
+ + +
+ + @if (!string.IsNullOrEmpty(Status)) + { +

Status: @Status

+ } + + @code { + private string Status; + + private void Zusage() + { + Status = "Du hast zugesagt. Wir freuen uns auf dich!"; + } + + private void Absage() + { + Status = "Du hast abgesagt. Schade, vielleicht nächstes Mal!"; + } + } + + + Anmeldung + \ No newline at end of file diff --git a/Client/Modules/AdamGais.Module.AnmeldeTool/ModuleInfo.cs b/Client/Modules/AdamGais.Module.AnmeldeTool/ModuleInfo.cs new file mode 100644 index 0000000..7b5b222 --- /dev/null +++ b/Client/Modules/AdamGais.Module.AnmeldeTool/ModuleInfo.cs @@ -0,0 +1,19 @@ +using Oqtane.Models; +using Oqtane.Modules; + +namespace AdamGais.Module.AnmeldeTool +{ + public class ModuleInfo : IModule + { + public ModuleDefinition ModuleDefinition => new ModuleDefinition + { + Name = "AnmeldeTool", + Description = "AnmeldeTool", + Version = "1.0.0", + ServerManagerType = "AdamGais.Module.AnmeldeTool.Manager.AnmeldeToolManager, AdamGais.Module.AnmeldeTool.Server.Oqtane", + ReleaseVersions = "1.0.0", + Dependencies = "AdamGais.Module.AnmeldeTool.Shared.Oqtane", + PackageName = "AdamGais.Module.AnmeldeTool" + }; + } +} diff --git a/Client/Modules/AdamGais.Module.AnmeldeTool/Settings.razor b/Client/Modules/AdamGais.Module.AnmeldeTool/Settings.razor new file mode 100644 index 0000000..e9f8aa7 --- /dev/null +++ b/Client/Modules/AdamGais.Module.AnmeldeTool/Settings.razor @@ -0,0 +1,47 @@ +@namespace AdamGais.Module.AnmeldeTool +@inherits ModuleBase +@inject ISettingService SettingService +@inject IStringLocalizer Localizer + +
+
+ +
+ +
+
+
+ +@code { + private string resourceType = "AdamGais.Module.AnmeldeTool.Settings, AdamGais.Module.AnmeldeTool.Client.Oqtane"; // for localization + public override string Title => "AnmeldeTool Settings"; + + string _value; + + protected override async Task OnInitializedAsync() + { + try + { + Dictionary settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId); + _value = SettingService.GetSetting(settings, "SettingName", ""); + } + catch (Exception ex) + { + AddModuleMessage(ex.Message, MessageType.Error); + } + } + + public async Task UpdateSettings() + { + try + { + Dictionary settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId); + SettingService.SetSetting(settings, "SettingName", _value); + await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId); + } + catch (Exception ex) + { + AddModuleMessage(ex.Message, MessageType.Error); + } + } +} diff --git a/Client/Properties/Resources.Designer.cs b/Client/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c164961 --- /dev/null +++ b/Client/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AdamGais.Module.AnmeldeTool.Client.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdamGais.Module.AnmeldeTool.Client.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Client/Properties/Resources.resx b/Client/Properties/Resources.resx new file mode 100644 index 0000000..4fdb1b6 --- /dev/null +++ b/Client/Properties/Resources.resx @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Client/Resources/AdamGais.Module.AnmeldeTool/Edit - Copy.resx b/Client/Resources/AdamGais.Module.AnmeldeTool/Edit - Copy.resx new file mode 100644 index 0000000..6de8e1d --- /dev/null +++ b/Client/Resources/AdamGais.Module.AnmeldeTool/Edit - Copy.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Name: + + + Enter the name + + + Save + + + Cancel + + + Error Loading AnmeldeTool + + + Please Provide All Required Information + + + Error Saving AnmeldeTool + + \ No newline at end of file diff --git a/Client/Resources/AdamGais.Module.AnmeldeTool/Edit.resx b/Client/Resources/AdamGais.Module.AnmeldeTool/Edit.resx new file mode 100644 index 0000000..6de8e1d --- /dev/null +++ b/Client/Resources/AdamGais.Module.AnmeldeTool/Edit.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Name: + + + Enter the name + + + Save + + + Cancel + + + Error Loading AnmeldeTool + + + Please Provide All Required Information + + + Error Saving AnmeldeTool + + \ No newline at end of file diff --git a/Client/Resources/AdamGais.Module.AnmeldeTool/Index.resx b/Client/Resources/AdamGais.Module.AnmeldeTool/Index.resx new file mode 100644 index 0000000..b70adaa --- /dev/null +++ b/Client/Resources/AdamGais.Module.AnmeldeTool/Index.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Name + + + Add AnmeldeTool + + + Edit + + + Delete + + + Delete AnmeldeTool + + + Are You Sure You Wish To Delete This AnmeldeTool? + + + No AnmeldeTools To Display + + + Error Loading AnmeldeTool + + + Error Deleting AnmeldeTool + + \ No newline at end of file diff --git a/Client/Resources/AdamGais.Module.AnmeldeTool/Settings.resx b/Client/Resources/AdamGais.Module.AnmeldeTool/Settings.resx new file mode 100644 index 0000000..83dc88f --- /dev/null +++ b/Client/Resources/AdamGais.Module.AnmeldeTool/Settings.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Name: + + + Enter a value + + \ No newline at end of file diff --git a/Client/Services/AnmeldeToolService.cs b/Client/Services/AnmeldeToolService.cs new file mode 100644 index 0000000..a9aaadf --- /dev/null +++ b/Client/Services/AnmeldeToolService.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Oqtane.Services; +using Oqtane.Shared; + +namespace AdamGais.Module.AnmeldeTool.Services +{ + public class AnmeldeToolService : ServiceBase, IAnmeldeToolService + { + public AnmeldeToolService(HttpClient http, SiteState siteState) : base(http, siteState) { } + + private string Apiurl => CreateApiUrl("AnmeldeTool"); + + public async Task> GetAnmeldeToolsAsync(int ModuleId) + { + List AnmeldeTools = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty().ToList()); + return AnmeldeTools.OrderBy(item => item.Name).ToList(); + } + + public async Task GetAnmeldeToolAsync(int AnmeldeToolId, int ModuleId) + { + return await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{AnmeldeToolId}/{ModuleId}", EntityNames.Module, ModuleId)); + } + + public async Task AddAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool) + { + return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, AnmeldeTool.ModuleId), AnmeldeTool); + } + + public async Task UpdateAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool) + { + return await PutJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{AnmeldeTool.AnmeldeToolId}", EntityNames.Module, AnmeldeTool.ModuleId), AnmeldeTool); + } + + public async Task DeleteAnmeldeToolAsync(int AnmeldeToolId, int ModuleId) + { + await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{AnmeldeToolId}/{ModuleId}", EntityNames.Module, ModuleId)); + } + } +} diff --git a/Client/Startup/ClientStartup.cs b/Client/Startup/ClientStartup.cs new file mode 100644 index 0000000..b92b0e5 --- /dev/null +++ b/Client/Startup/ClientStartup.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.DependencyInjection; +using Oqtane.Services; +using AdamGais.Module.AnmeldeTool.Services; + +namespace AdamGais.Module.AnmeldeTool.Startup +{ + public class ClientStartup : IClientStartup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddScoped(); + } + } +} diff --git a/Client/_Imports.razor b/Client/_Imports.razor new file mode 100644 index 0000000..2f6fb1b --- /dev/null +++ b/Client/_Imports.razor @@ -0,0 +1,24 @@ +@using System +@using System.Linq +@using System.Collections.Generic +@using System.Net.Http +@using System.Net.Http.Json + +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.Extensions.Localization +@using Microsoft.JSInterop + +@using Oqtane.Models +@using Oqtane.Modules +@using Oqtane.Modules.Controls +@using Oqtane.Providers +@using Oqtane.Security +@using Oqtane.Services +@using Oqtane.Shared +@using Oqtane.Themes +@using Oqtane.Themes.Controls +@using Oqtane.UI +@using Oqtane.Enums +@using Oqtane.Interfaces \ No newline at end of file diff --git a/Package/AdamGais.Module.AnmeldeTool.Package.csproj b/Package/AdamGais.Module.AnmeldeTool.Package.csproj new file mode 100644 index 0000000..4b5a2bb --- /dev/null +++ b/Package/AdamGais.Module.AnmeldeTool.Package.csproj @@ -0,0 +1,29 @@ + + + + net9.0 + false + false + + + + + True + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Package/AdamGais.Module.AnmeldeTool.nuspec b/Package/AdamGais.Module.AnmeldeTool.nuspec new file mode 100644 index 0000000..2f4d588 --- /dev/null +++ b/Package/AdamGais.Module.AnmeldeTool.nuspec @@ -0,0 +1,32 @@ + + + + $projectname$ + 1.0.0 + AdamGais + AdamGais + AnmeldeTool + AnmeldeTool + AdamGais + false + MIT + https://github.com/oqtane/oqtane.framework + icon.png + oqtane module + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Package/debug.cmd b/Package/debug.cmd new file mode 100644 index 0000000..4a87708 --- /dev/null +++ b/Package/debug.cmd @@ -0,0 +1,11 @@ +@echo off +set TargetFramework=%1 +set ProjectName=%2 + +XCOPY "..\Client\bin\Debug\%TargetFramework%\%ProjectName%.Client.Oqtane.dll" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Client\bin\Debug\%TargetFramework%\%ProjectName%.Client.Oqtane.pdb" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Server\bin\Debug\%TargetFramework%\%ProjectName%.Server.Oqtane.dll" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Server\bin\Debug\%TargetFramework%\%ProjectName%.Server.Oqtane.pdb" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Shared\bin\Debug\%TargetFramework%\%ProjectName%.Shared.Oqtane.dll" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Shared\bin\Debug\%TargetFramework%\%ProjectName%.Shared.Oqtane.pdb" "..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\%TargetFramework%\" /Y +XCOPY "..\Server\wwwroot\*" "..\..\oqtane.framework-dev\Oqtane.Server\wwwroot\" /Y /S /I \ No newline at end of file diff --git a/Package/debug.sh b/Package/debug.sh new file mode 100644 index 0000000..9bb748f --- /dev/null +++ b/Package/debug.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +TargetFramework=$1 +ProjectName=$2 + +cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.dll" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.pdb" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.dll" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.pdb" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.dll" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.pdb" "../../oqtane.framework-dev/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -rf "../Server/wwwroot/"* "../../oqtane.framework-dev/Oqtane.Server/wwwroot/" \ No newline at end of file diff --git a/Package/icon.png b/Package/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7422cf2f313e352d93b08d4e87fec74e52117713 GIT binary patch literal 7800 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 M>>IU0xA6S`1HzXf%>V!Z literal 0 HcmV?d00001 diff --git a/Package/release.cmd b/Package/release.cmd new file mode 100644 index 0000000..a14a149 --- /dev/null +++ b/Package/release.cmd @@ -0,0 +1,7 @@ +@echo off +set TargetFramework=%1 +set ProjectName=%2 + +del "*.nupkg" +"..\..\oqtane.framework-dev\oqtane.package\nuget.exe" pack %ProjectName%.nuspec -Properties targetframework=%TargetFramework%;projectname=%ProjectName% +XCOPY "*.nupkg" "..\..\oqtane.framework-dev\Oqtane.Server\Packages\" /Y \ No newline at end of file diff --git a/Package/release.sh b/Package/release.sh new file mode 100644 index 0000000..f948175 --- /dev/null +++ b/Package/release.sh @@ -0,0 +1,5 @@ +TargetFramework=$1 +ProjectName=$2 + +"..\..\oqtane.framework-dev\oqtane.package\nuget.exe" pack %ProjectName%.nuspec -Properties targetframework=%TargetFramework%;projectname=%ProjectName% +cp -f "*.nupkg" "..\..\oqtane.framework-dev\Oqtane.Server\Packages\" \ No newline at end of file diff --git a/Server/AdamGais.Module.AnmeldeTool.Server.csproj b/Server/AdamGais.Module.AnmeldeTool.Server.csproj new file mode 100644 index 0000000..8334a3c --- /dev/null +++ b/Server/AdamGais.Module.AnmeldeTool.Server.csproj @@ -0,0 +1,36 @@ + + + + net9.0 + true + 1.0.0 + AdamGais.Module.AnmeldeTool + AdamGais + AdamGais + AnmeldeTool + AdamGais + AdamGais.Module.AnmeldeTool.Server.Oqtane + true + + + + + + + + + + + + + + + + + + + + ..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\net9.0\Oqtane.Server.dll + ..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll + + diff --git a/Server/Controllers/AnmeldeToolController.cs b/Server/Controllers/AnmeldeToolController.cs new file mode 100644 index 0000000..e6eab62 --- /dev/null +++ b/Server/Controllers/AnmeldeToolController.cs @@ -0,0 +1,114 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; +using Oqtane.Shared; +using Oqtane.Enums; +using Oqtane.Infrastructure; +using AdamGais.Module.AnmeldeTool.Services; +using Oqtane.Controllers; +using System.Net; +using System.Threading.Tasks; + +namespace AdamGais.Module.AnmeldeTool.Controllers +{ + [Route(ControllerRoutes.ApiRoute)] + public class AnmeldeToolController : ModuleControllerBase + { + private readonly IAnmeldeToolService _AnmeldeToolService; + + public AnmeldeToolController(IAnmeldeToolService AnmeldeToolService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor) + { + _AnmeldeToolService = AnmeldeToolService; + } + + // GET: api/?moduleid=x + [HttpGet] + [Authorize(Policy = PolicyNames.ViewModule)] + public async Task> Get(string moduleid) + { + int ModuleId; + if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId)) + { + return await _AnmeldeToolService.GetAnmeldeToolsAsync(ModuleId); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Get Attempt {ModuleId}", moduleid); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + return null; + } + } + + // GET api//5 + [HttpGet("{id}/{moduleid}")] + [Authorize(Policy = PolicyNames.ViewModule)] + public async Task Get(int id, int moduleid) + { + Models.AnmeldeTool AnmeldeTool = await _AnmeldeToolService.GetAnmeldeToolAsync(id, moduleid); + if (AnmeldeTool != null && IsAuthorizedEntityId(EntityNames.Module, AnmeldeTool.ModuleId)) + { + return AnmeldeTool; + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Get Attempt {AnmeldeToolId} {ModuleId}", id, moduleid); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + return null; + } + } + + // POST api/ + [HttpPost] + [Authorize(Policy = PolicyNames.EditModule)] + public async Task Post([FromBody] Models.AnmeldeTool AnmeldeTool) + { + if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, AnmeldeTool.ModuleId)) + { + AnmeldeTool = await _AnmeldeToolService.AddAnmeldeToolAsync(AnmeldeTool); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Post Attempt {AnmeldeTool}", AnmeldeTool); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + AnmeldeTool = null; + } + return AnmeldeTool; + } + + // PUT api//5 + [HttpPut("{id}")] + [Authorize(Policy = PolicyNames.EditModule)] + public async Task Put(int id, [FromBody] Models.AnmeldeTool AnmeldeTool) + { + if (ModelState.IsValid && AnmeldeTool.AnmeldeToolId == id && IsAuthorizedEntityId(EntityNames.Module, AnmeldeTool.ModuleId)) + { + AnmeldeTool = await _AnmeldeToolService.UpdateAnmeldeToolAsync(AnmeldeTool); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Put Attempt {AnmeldeTool}", AnmeldeTool); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + AnmeldeTool = null; + } + return AnmeldeTool; + } + + // DELETE api//5 + [HttpDelete("{id}/{moduleid}")] + [Authorize(Policy = PolicyNames.EditModule)] + public async Task Delete(int id, int moduleid) + { + Models.AnmeldeTool AnmeldeTool = await _AnmeldeToolService.GetAnmeldeToolAsync(id, moduleid); + if (AnmeldeTool != null && IsAuthorizedEntityId(EntityNames.Module, AnmeldeTool.ModuleId)) + { + await _AnmeldeToolService.DeleteAnmeldeToolAsync(id, AnmeldeTool.ModuleId); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Delete Attempt {AnmeldeToolId} {ModuleId}", id, moduleid); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + } + } + } +} diff --git a/Server/Manager/AnmeldeToolManager.cs b/Server/Manager/AnmeldeToolManager.cs new file mode 100644 index 0000000..eeaaf27 --- /dev/null +++ b/Server/Manager/AnmeldeToolManager.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Oqtane.Modules; +using Oqtane.Models; +using Oqtane.Infrastructure; +using Oqtane.Interfaces; +using Oqtane.Enums; +using Oqtane.Repository; +using AdamGais.Module.AnmeldeTool.Repository; +using System.Threading.Tasks; + +namespace AdamGais.Module.AnmeldeTool.Manager +{ + public class AnmeldeToolManager : MigratableModuleBase, IInstallable, IPortable, ISearchable + { + private readonly IAnmeldeToolRepository _AnmeldeToolRepository; + private readonly IDBContextDependencies _DBContextDependencies; + + public AnmeldeToolManager(IAnmeldeToolRepository AnmeldeToolRepository, IDBContextDependencies DBContextDependencies) + { + _AnmeldeToolRepository = AnmeldeToolRepository; + _DBContextDependencies = DBContextDependencies; + } + + public bool Install(Tenant tenant, string version) + { + return Migrate(new AnmeldeToolContext(_DBContextDependencies), tenant, MigrationType.Up); + } + + public bool Uninstall(Tenant tenant) + { + return Migrate(new AnmeldeToolContext(_DBContextDependencies), tenant, MigrationType.Down); + } + + public string ExportModule(Oqtane.Models.Module module) + { + string content = ""; + List AnmeldeTools = _AnmeldeToolRepository.GetAnmeldeTools(module.ModuleId).ToList(); + if (AnmeldeTools != null) + { + content = JsonSerializer.Serialize(AnmeldeTools); + } + return content; + } + + public void ImportModule(Oqtane.Models.Module module, string content, string version) + { + List AnmeldeTools = null; + if (!string.IsNullOrEmpty(content)) + { + AnmeldeTools = JsonSerializer.Deserialize>(content); + } + if (AnmeldeTools != null) + { + foreach(var AnmeldeTool in AnmeldeTools) + { + _AnmeldeToolRepository.AddAnmeldeTool(new Models.AnmeldeTool { ModuleId = module.ModuleId, Name = AnmeldeTool.Name }); + } + } + } + + public Task> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn) + { + var searchContentList = new List(); + + foreach (var AnmeldeTool in _AnmeldeToolRepository.GetAnmeldeTools(pageModule.ModuleId)) + { + if (AnmeldeTool.ModifiedOn >= lastIndexedOn) + { + searchContentList.Add(new SearchContent + { + EntityName = "AdamGaisAnmeldeTool", + EntityId = AnmeldeTool.AnmeldeToolId.ToString(), + Title = AnmeldeTool.Name, + Body = AnmeldeTool.Name, + ContentModifiedBy = AnmeldeTool.ModifiedBy, + ContentModifiedOn = AnmeldeTool.ModifiedOn + }); + } + } + + return Task.FromResult(searchContentList); + } + } +} diff --git a/Server/Migrations/01000000_InitializeModule.cs b/Server/Migrations/01000000_InitializeModule.cs new file mode 100644 index 0000000..586dedd --- /dev/null +++ b/Server/Migrations/01000000_InitializeModule.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Oqtane.Databases.Interfaces; +using Oqtane.Migrations; +using AdamGais.Module.AnmeldeTool.Migrations.EntityBuilders; +using AdamGais.Module.AnmeldeTool.Repository; + +namespace AdamGais.Module.AnmeldeTool.Migrations +{ + [DbContext(typeof(AnmeldeToolContext))] + [Migration("AdamGais.Module.AnmeldeTool.01.00.00.00")] + public class InitializeModule : MultiDatabaseMigration + { + public InitializeModule(IDatabase database) : base(database) + { + } + + protected override void Up(MigrationBuilder migrationBuilder) + { + var entityBuilder = new AnmeldeToolEntityBuilder(migrationBuilder, ActiveDatabase); + entityBuilder.Create(); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + var entityBuilder = new AnmeldeToolEntityBuilder(migrationBuilder, ActiveDatabase); + entityBuilder.Drop(); + } + } +} diff --git a/Server/Migrations/EntityBuilders/AnmeldeToolEntityBuilder.cs b/Server/Migrations/EntityBuilders/AnmeldeToolEntityBuilder.cs new file mode 100644 index 0000000..13954df --- /dev/null +++ b/Server/Migrations/EntityBuilders/AnmeldeToolEntityBuilder.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations.Operations; +using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; +using Oqtane.Databases.Interfaces; +using Oqtane.Migrations; +using Oqtane.Migrations.EntityBuilders; + +namespace AdamGais.Module.AnmeldeTool.Migrations.EntityBuilders +{ + public class AnmeldeToolEntityBuilder : AuditableBaseEntityBuilder + { + private const string _entityTableName = "AdamGaisAnmeldeTool"; + private readonly PrimaryKey _primaryKey = new("PK_AdamGaisAnmeldeTool", x => x.AnmeldeToolId); + private readonly ForeignKey _moduleForeignKey = new("FK_AdamGaisAnmeldeTool_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade); + + public AnmeldeToolEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database) + { + EntityTableName = _entityTableName; + PrimaryKey = _primaryKey; + ForeignKeys.Add(_moduleForeignKey); + } + + protected override AnmeldeToolEntityBuilder BuildTable(ColumnsBuilder table) + { + AnmeldeToolId = AddAutoIncrementColumn(table,"AnmeldeToolId"); + ModuleId = AddIntegerColumn(table,"ModuleId"); + Name = AddMaxStringColumn(table,"Name"); + AddAuditableColumns(table); + return this; + } + + public OperationBuilder AnmeldeToolId { get; set; } + public OperationBuilder ModuleId { get; set; } + public OperationBuilder Name { get; set; } + } +} diff --git a/Server/Repository/AnmeldeToolContext.cs b/Server/Repository/AnmeldeToolContext.cs new file mode 100644 index 0000000..602cfc7 --- /dev/null +++ b/Server/Repository/AnmeldeToolContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.AspNetCore.Http; +using Oqtane.Modules; +using Oqtane.Repository; +using Oqtane.Infrastructure; +using Oqtane.Repository.Databases.Interfaces; + +namespace AdamGais.Module.AnmeldeTool.Repository +{ + public class AnmeldeToolContext : DBContextBase, ITransientService, IMultiDatabase + { + public virtual DbSet AnmeldeTool { get; set; } + + public AnmeldeToolContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies) + { + // ContextBase handles multi-tenant database connections + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.Entity().ToTable(ActiveDatabase.RewriteName("AdamGaisAnmeldeTool")); + } + } +} diff --git a/Server/Repository/AnmeldeToolRepository.cs b/Server/Repository/AnmeldeToolRepository.cs new file mode 100644 index 0000000..e196286 --- /dev/null +++ b/Server/Repository/AnmeldeToolRepository.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore; +using System.Linq; +using System.Collections.Generic; +using Oqtane.Modules; + +namespace AdamGais.Module.AnmeldeTool.Repository +{ + public class AnmeldeToolRepository : IAnmeldeToolRepository, ITransientService + { + private readonly IDbContextFactory _factory; + + public AnmeldeToolRepository(IDbContextFactory factory) + { + _factory = factory; + } + + public IEnumerable GetAnmeldeTools(int ModuleId) + { + using var db = _factory.CreateDbContext(); + return db.AnmeldeTool.Where(item => item.ModuleId == ModuleId).ToList(); + } + + public Models.AnmeldeTool GetAnmeldeTool(int AnmeldeToolId) + { + return GetAnmeldeTool(AnmeldeToolId, true); + } + + public Models.AnmeldeTool GetAnmeldeTool(int AnmeldeToolId, bool tracking) + { + using var db = _factory.CreateDbContext(); + if (tracking) + { + return db.AnmeldeTool.Find(AnmeldeToolId); + } + else + { + return db.AnmeldeTool.AsNoTracking().FirstOrDefault(item => item.AnmeldeToolId == AnmeldeToolId); + } + } + + public Models.AnmeldeTool AddAnmeldeTool(Models.AnmeldeTool AnmeldeTool) + { + using var db = _factory.CreateDbContext(); + db.AnmeldeTool.Add(AnmeldeTool); + db.SaveChanges(); + return AnmeldeTool; + } + + public Models.AnmeldeTool UpdateAnmeldeTool(Models.AnmeldeTool AnmeldeTool) + { + using var db = _factory.CreateDbContext(); + db.Entry(AnmeldeTool).State = EntityState.Modified; + db.SaveChanges(); + return AnmeldeTool; + } + + public void DeleteAnmeldeTool(int AnmeldeToolId) + { + using var db = _factory.CreateDbContext(); + Models.AnmeldeTool AnmeldeTool = db.AnmeldeTool.Find(AnmeldeToolId); + db.AnmeldeTool.Remove(AnmeldeTool); + db.SaveChanges(); + } + } +} diff --git a/Server/Repository/IAnmeldeToolRepository.cs b/Server/Repository/IAnmeldeToolRepository.cs new file mode 100644 index 0000000..1e16f20 --- /dev/null +++ b/Server/Repository/IAnmeldeToolRepository.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace AdamGais.Module.AnmeldeTool.Repository +{ + public interface IAnmeldeToolRepository + { + IEnumerable GetAnmeldeTools(int ModuleId); + Models.AnmeldeTool GetAnmeldeTool(int AnmeldeToolId); + Models.AnmeldeTool GetAnmeldeTool(int AnmeldeToolId, bool tracking); + Models.AnmeldeTool AddAnmeldeTool(Models.AnmeldeTool AnmeldeTool); + Models.AnmeldeTool UpdateAnmeldeTool(Models.AnmeldeTool AnmeldeTool); + void DeleteAnmeldeTool(int AnmeldeToolId); + } +} diff --git a/Server/Services/AnmeldeToolService.cs b/Server/Services/AnmeldeToolService.cs new file mode 100644 index 0000000..6d0983e --- /dev/null +++ b/Server/Services/AnmeldeToolService.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Oqtane.Enums; +using Oqtane.Infrastructure; +using Oqtane.Models; +using Oqtane.Security; +using Oqtane.Shared; +using AdamGais.Module.AnmeldeTool.Repository; + +namespace AdamGais.Module.AnmeldeTool.Services +{ + public class ServerAnmeldeToolService : IAnmeldeToolService + { + private readonly IAnmeldeToolRepository _AnmeldeToolRepository; + private readonly IUserPermissions _userPermissions; + private readonly ILogManager _logger; + private readonly IHttpContextAccessor _accessor; + private readonly Alias _alias; + + public ServerAnmeldeToolService(IAnmeldeToolRepository AnmeldeToolRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor) + { + _AnmeldeToolRepository = AnmeldeToolRepository; + _userPermissions = userPermissions; + _logger = logger; + _accessor = accessor; + _alias = tenantManager.GetAlias(); + } + + public Task> GetAnmeldeToolsAsync(int ModuleId) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) + { + return Task.FromResult(_AnmeldeToolRepository.GetAnmeldeTools(ModuleId).ToList()); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Get Attempt {ModuleId}", ModuleId); + return null; + } + } + + public Task GetAnmeldeToolAsync(int AnmeldeToolId, int ModuleId) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) + { + return Task.FromResult(_AnmeldeToolRepository.GetAnmeldeTool(AnmeldeToolId)); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Get Attempt {AnmeldeToolId} {ModuleId}", AnmeldeToolId, ModuleId); + return null; + } + } + + public Task AddAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, AnmeldeTool.ModuleId, PermissionNames.Edit)) + { + AnmeldeTool = _AnmeldeToolRepository.AddAnmeldeTool(AnmeldeTool); + _logger.Log(LogLevel.Information, this, LogFunction.Create, "AnmeldeTool Added {AnmeldeTool}", AnmeldeTool); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Add Attempt {AnmeldeTool}", AnmeldeTool); + AnmeldeTool = null; + } + return Task.FromResult(AnmeldeTool); + } + + public Task UpdateAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, AnmeldeTool.ModuleId, PermissionNames.Edit)) + { + AnmeldeTool = _AnmeldeToolRepository.UpdateAnmeldeTool(AnmeldeTool); + _logger.Log(LogLevel.Information, this, LogFunction.Update, "AnmeldeTool Updated {AnmeldeTool}", AnmeldeTool); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Update Attempt {AnmeldeTool}", AnmeldeTool); + AnmeldeTool = null; + } + return Task.FromResult(AnmeldeTool); + } + + public Task DeleteAnmeldeToolAsync(int AnmeldeToolId, int ModuleId) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit)) + { + _AnmeldeToolRepository.DeleteAnmeldeTool(AnmeldeToolId); + _logger.Log(LogLevel.Information, this, LogFunction.Delete, "AnmeldeTool Deleted {AnmeldeToolId}", AnmeldeToolId); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AnmeldeTool Delete Attempt {AnmeldeToolId} {ModuleId}", AnmeldeToolId, ModuleId); + } + return Task.CompletedTask; + } + } +} diff --git a/Server/Startup/ServerStartup.cs b/Server/Startup/ServerStartup.cs new file mode 100644 index 0000000..3bc9e17 --- /dev/null +++ b/Server/Startup/ServerStartup.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Oqtane.Infrastructure; +using AdamGais.Module.AnmeldeTool.Repository; +using AdamGais.Module.AnmeldeTool.Services; + +namespace AdamGais.Module.AnmeldeTool.Startup +{ + public class ServerStartup : IServerStartup + { + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + // not implemented + } + + public void ConfigureMvc(IMvcBuilder mvcBuilder) + { + // not implemented + } + + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddDbContextFactory(opt => { }, ServiceLifetime.Transient); + } + } +} diff --git a/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.css b/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.css new file mode 100644 index 0000000..0856a26 --- /dev/null +++ b/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.css @@ -0,0 +1 @@ +/* Module Custom Styles */ \ No newline at end of file diff --git a/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.js b/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.js new file mode 100644 index 0000000..346094b --- /dev/null +++ b/Server/wwwroot/Modules/AdamGais.Module.AnmeldeTool/Module.js @@ -0,0 +1,5 @@ +/* Module Script */ +var AdamGais = AdamGais || {}; + +AdamGais.AnmeldeTool = { +}; \ No newline at end of file diff --git a/Server/wwwroot/_content/Placeholder.txt b/Server/wwwroot/_content/Placeholder.txt new file mode 100644 index 0000000..5a324d7 --- /dev/null +++ b/Server/wwwroot/_content/Placeholder.txt @@ -0,0 +1,11 @@ +The _content folder should only contain static resources from shared razor component libraries (RCLs). Static resources can be extracted from shared RCL Nuget packages by executing a Publish task on the module's Server project to a local folder and copying the files from the _content folder which is created. Each shared RCL would have its own appropriately named subfolder within the module's _content folder. + +ie. + +/_content + /Radzen.Blazor + /css + /fonts + /syncfusion.blazor + /scripts + /styles diff --git a/Shared/AdamGais.Module.AnmeldeTool.Shared.csproj b/Shared/AdamGais.Module.AnmeldeTool.Shared.csproj new file mode 100644 index 0000000..f6b646c --- /dev/null +++ b/Shared/AdamGais.Module.AnmeldeTool.Shared.csproj @@ -0,0 +1,22 @@ + + + + net9.0 + 1.0.0 + AdamGais.Module.AnmeldeTool + AdamGais + AdamGais + AnmeldeTool + AdamGais + AdamGais.Module.AnmeldeTool.Shared.Oqtane + + + + + + + + ..\..\oqtane.framework-dev\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll + + + diff --git a/Shared/Interfaces/IAnmeldeToolService.cs b/Shared/Interfaces/IAnmeldeToolService.cs new file mode 100644 index 0000000..d8d13eb --- /dev/null +++ b/Shared/Interfaces/IAnmeldeToolService.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace AdamGais.Module.AnmeldeTool.Services +{ + public interface IAnmeldeToolService + { + Task> GetAnmeldeToolsAsync(int ModuleId); + + Task GetAnmeldeToolAsync(int AnmeldeToolId, int ModuleId); + + Task AddAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool); + + Task UpdateAnmeldeToolAsync(Models.AnmeldeTool AnmeldeTool); + + Task DeleteAnmeldeToolAsync(int AnmeldeToolId, int ModuleId); + } +} diff --git a/Shared/Models/AnmeldeTool.cs b/Shared/Models/AnmeldeTool.cs new file mode 100644 index 0000000..dcd078d --- /dev/null +++ b/Shared/Models/AnmeldeTool.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Oqtane.Models; + +namespace AdamGais.Module.AnmeldeTool.Models +{ + [Table("AdamGaisAnmeldeTool")] + public class AnmeldeTool : IAuditable + { + [Key] + public int AnmeldeToolId { get; set; } + public int ModuleId { get; set; } + public string Name { get; set; } + + public string CreatedBy { get; set; } + public DateTime CreatedOn { get; set; } + public string ModifiedBy { get; set; } + public DateTime ModifiedOn { get; set; } + } +} diff --git a/template.json b/template.json new file mode 100644 index 0000000..f216af6 --- /dev/null +++ b/template.json @@ -0,0 +1,6 @@ +{ + "Title": "Default Module Template", + "Type": "External", + "Version": "5.2.0", + "Namespace": "AdamGais.Module.AnmeldeTool" +}