Rename services to Client/Server and update refs
Rename the client service class/file from [Module]Service to Client[Module]Service and the server service to Server[Module]Service. Update Edit.razor and Index.razor to inject Client[Module]Service and adjust all calls accordingly. Update DI registration in ClientStartup to register Client[Module]Service. Also remove the System.Net.Http.Json package reference from the client .csproj. File renames and reference updates keep class names and registrations consistent between client and server templates.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@namespace [Owner].Module.[Module]
|
@namespace [Owner].Module.[Module]
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject I[Module]Service [Module]Service
|
@inject I[Module]Service Client[Module]Service
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
if (PageState.Action == "Edit")
|
if (PageState.Action == "Edit")
|
||||||
{
|
{
|
||||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
|
[Module] [Module] = await Client[Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
|
||||||
if ([Module] != null)
|
if ([Module] != null)
|
||||||
{
|
{
|
||||||
_name = [Module].Name;
|
_name = [Module].Name;
|
||||||
@@ -86,14 +86,14 @@
|
|||||||
[Module] [Module] = new [Module]();
|
[Module] [Module] = new [Module]();
|
||||||
[Module].ModuleId = ModuleState.ModuleId;
|
[Module].ModuleId = ModuleState.ModuleId;
|
||||||
[Module].Name = _name;
|
[Module].Name = _name;
|
||||||
[Module] = await [Module]Service.Add[Module]Async([Module]);
|
[Module] = await Client[Module]Service.Add[Module]Async([Module]);
|
||||||
await logger.LogInformation("[Module] Added {[Module]}", [Module]);
|
await logger.LogInformation("[Module] Added {[Module]}", [Module]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
|
[Module] [Module] = await Client[Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
|
||||||
[Module].Name = _name;
|
[Module].Name = _name;
|
||||||
await [Module]Service.Update[Module]Async([Module]);
|
await Client[Module]Service.Update[Module]Async([Module]);
|
||||||
await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
|
await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
|
||||||
}
|
}
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
@namespace [Owner].Module.[Module]
|
@namespace [Owner].Module.[Module]
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject I[Module]Service [Module]Service
|
@inject I[Module]Service Client[Module]Service
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ else
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
_[Module]s = await Client[Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -65,9 +65,9 @@ else
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await [Module]Service.Delete[Module]Async([Module].[Module]Id, ModuleState.ModuleId);
|
await Client[Module]Service.Delete[Module]Async([Module].[Module]Id, ModuleState.ModuleId);
|
||||||
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
|
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
|
||||||
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
_[Module]s = await Client[Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ using Oqtane.Shared;
|
|||||||
namespace [Owner].Module.[Module].Services
|
namespace [Owner].Module.[Module].Services
|
||||||
{
|
{
|
||||||
|
|
||||||
public class [Module]Service : ServiceBase, I[Module]Service
|
public class Client[Module]Service : ServiceBase, I[Module]Service
|
||||||
{
|
{
|
||||||
public [Module]Service(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
public Client[Module]Service(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
||||||
|
|
||||||
private string Apiurl => CreateApiUrl("[Module]");
|
private string Apiurl => CreateApiUrl("[Module]");
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ namespace [Owner].Module.[Module].Startup
|
|||||||
{
|
{
|
||||||
if (!services.Any(s => s.ServiceType == typeof(I[Module]Service)))
|
if (!services.Any(s => s.ServiceType == typeof(I[Module]Service)))
|
||||||
{
|
{
|
||||||
services.AddScoped<I[Module]Service, [Module]Service>();
|
services.AddScoped<I[Module]Service, Client[Module]Service>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
|
||||||
<PackageReference Include="System.Net.Http.Json" Version="10.0.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user