Skip to content

Commit

Permalink
#2 : Change architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver254 committed Nov 12, 2022
1 parent 754d849 commit c01fa39
Show file tree
Hide file tree
Showing 50 changed files with 1,499 additions and 60 deletions.
50 changes: 24 additions & 26 deletions CocherBusiness.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,45 @@ VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A95E9106-2C39-4897-9487-9B0A2CDE5B04}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{BE9CBDD2-8F8C-41A5-9CE2-B8857A812835}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CocherBusiness.SharedKernel", "src\CocherBusiness.SharedKernel\CocherBusiness.SharedKernel.csproj", "{1CB94AB4-4C94-40BD-B020-AC200CE4A270}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project", "Project", "{AD8CD362-8995-45AB-9CC4-9DC9B28CEDA1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CocherBusiness.Application", "src\CocherBusiness.Application\CocherBusiness.Application.csproj", "{AED4F296-9B01-4B74-9DCF-B2C11632716B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{FF91D87B-E616-46EE-997A-729511A5A3FA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CocherBusiness.Infrastructure", "src\CocherBusiness.Infrastructure\CocherBusiness.Infrastructure.csproj", "{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CocherBusiness.SharedKernel", "src\Common\SharedKernel\CocherBusiness.SharedKernel.csproj", "{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CocherBusiness.Project.Application", "src\Services\Project\Project.Application\CocherBusiness.Project.Application.csproj", "{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CocherBusiness.Project.Infrastructure", "src\Services\Project\Project.Infrastructure\CocherBusiness.Project.Infrastructure.csproj", "{9A59D128-BAE9-4498-912A-F89B0EF1DB8A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CocherBusiness.Web", "src\CocherBusiness.Web\CocherBusiness.Web.csproj", "{215C7A61-AF84-43BA-BA3D-AF5F537B81AF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3}.Release|Any CPU.Build.0 = Release|Any CPU
{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{9A59D128-BAE9-4498-912A-F89B0EF1DB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A59D128-BAE9-4498-912A-F89B0EF1DB8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A59D128-BAE9-4498-912A-F89B0EF1DB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A59D128-BAE9-4498-912A-F89B0EF1DB8A}.Release|Any CPU.Build.0 = Release|Any CPU
{1CB94AB4-4C94-40BD-B020-AC200CE4A270}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CB94AB4-4C94-40BD-B020-AC200CE4A270}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CB94AB4-4C94-40BD-B020-AC200CE4A270}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CB94AB4-4C94-40BD-B020-AC200CE4A270}.Release|Any CPU.Build.0 = Release|Any CPU
{AED4F296-9B01-4B74-9DCF-B2C11632716B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AED4F296-9B01-4B74-9DCF-B2C11632716B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AED4F296-9B01-4B74-9DCF-B2C11632716B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AED4F296-9B01-4B74-9DCF-B2C11632716B}.Release|Any CPU.Build.0 = Release|Any CPU
{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D}.Release|Any CPU.Build.0 = Release|Any CPU
{215C7A61-AF84-43BA-BA3D-AF5F537B81AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{215C7A61-AF84-43BA-BA3D-AF5F537B81AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{215C7A61-AF84-43BA-BA3D-AF5F537B81AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{215C7A61-AF84-43BA-BA3D-AF5F537B81AF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BE9CBDD2-8F8C-41A5-9CE2-B8857A812835} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
{AD8CD362-8995-45AB-9CC4-9DC9B28CEDA1} = {BE9CBDD2-8F8C-41A5-9CE2-B8857A812835}
{FF91D87B-E616-46EE-997A-729511A5A3FA} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
{AB6D5F91-473D-4F68-B802-BD1AE7AE96C3} = {FF91D87B-E616-46EE-997A-729511A5A3FA}
{F5E75C00-30C5-4688-A2C6-E52E6F25CA0D} = {AD8CD362-8995-45AB-9CC4-9DC9B28CEDA1}
{9A59D128-BAE9-4498-912A-F89B0EF1DB8A} = {AD8CD362-8995-45AB-9CC4-9DC9B28CEDA1}
{1CB94AB4-4C94-40BD-B020-AC200CE4A270} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
{AED4F296-9B01-4B74-9DCF-B2C11632716B} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
{8E67AC14-55F9-45D9-9C6E-BBD9BC9EA62D} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
{215C7A61-AF84-43BA-BA3D-AF5F537B81AF} = {A95E9106-2C39-4897-9487-9B0A2CDE5B04}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DBCA898E-33CA-4364-94B8-54A369FDD475}
Expand Down
18 changes: 18 additions & 0 deletions src/CocherBusiness.Application/CocherBusiness.Application.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Monbsoft.CocherBusiness.Application</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" Version="4.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CocherBusiness.SharedKernel\CocherBusiness.SharedKernel.csproj" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions src/CocherBusiness.Application/Domain/Product.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Ardalis.GuardClauses;
using Monbsoft.CocherBusiness.SharedKernel;
using Monbsoft.CocherBusiness.SharedKernel.Interfaces;

namespace Monbsoft.CocherBusiness.Application.Domain;

public class Product : EntityBase, IAggregateRoot
{
public Product(string name)
{
Name = Guard.Against.NullOrEmpty(name, nameof(name));
}

public string Name { get; private set; }
}
17 changes: 17 additions & 0 deletions src/CocherBusiness.Application/Domain/Project.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Ardalis.GuardClauses;
using Monbsoft.CocherBusiness.SharedKernel;
using Monbsoft.CocherBusiness.SharedKernel.Interfaces;

namespace Monbsoft.CocherBusiness.Application.Domain;

public class Project : EntityBase, IAggregateRoot
{
public Project(string name, string? description)
{
Name = Guard.Against.NullOrEmpty(name, nameof(name));
Description = description;
}

public string Name { get; private set; }
public string? Description { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Monbsoft.CocherBusiness.Project.Application</RootNamespace>
<RootNamespace>Monbsoft.CocherBusiness.Infrastructure</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Common\SharedKernel\CocherBusiness.SharedKernel.csproj" />
<ProjectReference Include="..\CocherBusiness.Application\CocherBusiness.Application.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System.Text;
using System.Threading.Tasks;

namespace Monbsoft.CocherBusiness.Project.Application.Domain;

public class Project
namespace Monbsoft.CocherBusiness.Infrastructure.Data
{
internal class ProjectContext
{
}
}
6 changes: 6 additions & 0 deletions src/CocherBusiness.SharedKernel/EntityBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Monbsoft.CocherBusiness.SharedKernel;

public abstract class EntityBase
{
public Guid Id { get; set; }
}
25 changes: 25 additions & 0 deletions src/CocherBusiness.Web/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{
<RedirectToLogin />
}
else
{
<p role="alert">You are not authorized to access this resource.</p>
}
</NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
24 changes: 24 additions & 0 deletions src/CocherBusiness.Web/CocherBusiness.Web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.11" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.11" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CocherBusiness.Infrastructure\CocherBusiness.Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/CocherBusiness.Web/Pages/Authentication.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

@code{
[Parameter] public string? Action { get; set; }
}
18 changes: 18 additions & 0 deletions src/CocherBusiness.Web/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
57 changes: 57 additions & 0 deletions src/CocherBusiness.Web/Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@page "/fetchdata"
@inject HttpClient Http

<PageTitle>Weather forecast</PageTitle>

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>

@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}

@code {
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}

public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public string? Summary { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
13 changes: 13 additions & 0 deletions src/CocherBusiness.Web/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@page "/"

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

<div class="alert alert-warning" role="alert">
Before authentication will function correctly, you must configure your provider details in <code>Program.cs</code>
</div>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />
18 changes: 18 additions & 0 deletions src/CocherBusiness.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using CocherBusiness.Web;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddOidcAuthentication(options =>
{
// Configure your authentication provider options here.
// For more information, see https://aka.ms/blazor-standalone-auth
builder.Configuration.Bind("Local", options.ProviderOptions);
});

await builder.Build().RunAsync();
14 changes: 14 additions & 0 deletions src/CocherBusiness.Web/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"CocherBusiness.Web": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7167;http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
23 changes: 23 additions & 0 deletions src/CocherBusiness.Web/Shared/LoginDisplay.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

<AuthorizeView>
<Authorized>
Hello, @context.User.Identity?.Name!
<button class="nav-link btn btn-link" @onclick="BeginSignOut">Log out</button>
</Authorized>
<NotAuthorized>
<a href="authentication/login">Log in</a>
</NotAuthorized>
</AuthorizeView>

@code{
private async Task BeginSignOut(MouseEventArgs args)
{
await SignOutManager.SetSignOutState();
Navigation.NavigateTo("authentication/logout");
}
}
18 changes: 18 additions & 0 deletions src/CocherBusiness.Web/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4 auth">
<LoginDisplay />
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>

<article class="content px-4">
@Body
</article>
</main>
</div>
Loading

0 comments on commit c01fa39

Please sign in to comment.