Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

5 changes: 2 additions & 3 deletions Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Application\Hexagonal.Application.Impl\Hexagonal.Application.Impl.csproj" />
<ProjectReference Include="..\..\Application\Hexagonal.Application.Interface\Hexagonal.Application.Interface.csproj" />
<ProjectReference Include="..\..\Framework\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj" />
<ProjectReference Include="..\..\Business\Hexagonal.Business.Impl\Hexagonal.Business.Impl.csproj" />
<ProjectReference Include="..\..\Modules\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj" />
</ItemGroup>

</Project>
9 changes: 5 additions & 4 deletions Apps/Hexagonal.App.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Hexagonal.Application.Interface.Item;
using Hexagonal.Business.Impl;
using Hexagonal.Business.Interface.Item;
using Hexagonal.Persistence.InMemory;

namespace Hexagonal.App.Console
Expand All @@ -8,15 +9,15 @@ class Program
static void Main(string[] args)
{
// Wire up the dependency on the application layer
var app = new Application.Impl.Application(new InMemoryStore());
var app = new Application(new InMemoryStore());

System.Console.WriteLine("Creating and retreiving an item");

// Create the item
var resp = app.Dispatch<CreateItem, ItemDTO>(new CreateItem("Hello World"));
var resp = app.Dispatch<CreateItem, BusinessItem>(new CreateItem("Hello World"));

// Get the item back
var item = app.Dispatch<ItemQuery, ItemResultsDTO>(new ItemQuery(resp.Id));
var item = app.Dispatch<ItemQuery, BusinessItemResult>(new ItemQuery(resp.Id));

System.Console.WriteLine($"Created and retrieved item ({item.Results[0].Id}) with data \"{item.Results[0].Data}\"");
}
Expand Down
11 changes: 6 additions & 5 deletions Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -11,10 +11,11 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Application\Hexagonal.Application.Impl\Hexagonal.Application.Impl.csproj" />
<ProjectReference Include="..\..\Application\Hexagonal.Application.Interface\Hexagonal.Application.Interface.csproj" />
<ProjectReference Include="..\..\Framework\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj" />
<ProjectReference Include="..\..\Framework\Hexagonal.Web\Hexagonal.Web.csproj" />
<ProjectReference Include="..\..\Business\Hexagonal.Business.Impl\Hexagonal.Business.Impl.csproj" />
<ProjectReference Include="..\..\Business\Hexagonal.Business.Interface\Hexagonal.Business.Interface.csproj" />
<ProjectReference Include="..\..\Business\ModuleInterfaces\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj" />
<ProjectReference Include="..\..\Modules\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj" />
<ProjectReference Include="..\..\Modules\Hexagonal.Web\Hexagonal.Web.csproj" />
</ItemGroup>


Expand Down
4 changes: 2 additions & 2 deletions Apps/Hexagonal.App.Web/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Hexagonal.Application.Interface;
using Hexagonal.Business.Interface;
using Hexagonal.Persistence.InMemory;
using Hexagonal.Persistence.Interface;
using Hexagonal.Web.Controllers;
Expand All @@ -24,7 +24,7 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSingleton<IHandleItemState, InMemoryStore>();
services.AddSingleton<IApplication, Application.Impl.Application>();
services.AddSingleton<IApplication, Business.Impl.Application>();

var assembly = typeof(ItemController).Assembly;
services.AddMvc().AddApplicationPart(assembly).AddControllersAsServices();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Hexagonal.Application.Impl.Item;
using Hexagonal.Application.Interface;
using Hexagonal.Application.Interface.Item;
using Hexagonal.Business.Impl.Item;
using Hexagonal.Business.Interface;
using Hexagonal.Business.Interface.Item;
using Hexagonal.Persistence.Interface;
using System;

namespace Hexagonal.Application.Impl
namespace Hexagonal.Business.Impl
{
public class Application : IApplication
{
private IHandleItemState _stateManager;
private readonly IHandleItemState _stateManager;

public Application(IHandleItemState stateManager) =>
_stateManager = stateManager;
Expand All @@ -18,7 +18,6 @@ public TResp Dispatch<TReq, TResp>(TReq request)
where TResp : IApplicationResponse
where TReq : IApplicationRequest
{

// Map all the domain handlers
// Normally we'd use infrastructure / framework to do this like Mediatr
return request switch
Expand Down
13 changes: 13 additions & 0 deletions Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Hexagonal.Core.Handlers\Hexagonal.Core.Handlers.csproj" />
<ProjectReference Include="..\Hexagonal.Business.Interface\Hexagonal.Business.Interface.csproj" />
<ProjectReference Include="..\ModuleInterfaces\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Hexagonal.Application.Interface.Item;
using Hexagonal.Business.Handlers;
using Hexagonal.Business.Interface.Item;
using Hexagonal.Core.Handlers;
using Hexagonal.Persistence.Interface;

namespace Hexagonal.Application.Impl.Item
namespace Hexagonal.Business.Impl.Item
{
public static class ItemCommands
{
public static ItemDTO Execute(CreateItem ci, IHandleItemState stateManager)
public static BusinessItem Execute(CreateItem ci, IHandleItemState stateManager)
{
// Example of validation
if (string.IsNullOrWhiteSpace(ci.Data)) return null;
Expand All @@ -21,7 +21,7 @@ public static ItemDTO Execute(CreateItem ci, IHandleItemState stateManager)
ModifiedAt = item.ModifiedAt
});

return new ItemDTO
return new BusinessItem
{
Id = persistedItem.Id,
Data = persistedItem.Data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using Hexagonal.Application.Interface.Item;
using Hexagonal.Business.Interface.Item;
using Hexagonal.Persistence.Interface;

namespace Hexagonal.Application.Impl.Item
namespace Hexagonal.Business.Impl.Item
{
public static class ItemQueries
{
internal static ItemResultsDTO Query(ItemQuery query, IHandleItemState stateManager)
internal static BusinessItemResult Query(ItemQuery query, IHandleItemState stateManager)
{
var item = stateManager.GetItem(query.Id);
if (item == null) return null;

return new ItemResultsDTO
return new BusinessItemResult
{
Results = new[] {
new ItemDTO { Id = item.Id, Data = item.Data}
new BusinessItem { Id = item.Id, Data = item.Data}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Hexagonal.Application.Interface
namespace Hexagonal.Business.Interface
{
public interface IApplication
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Hexagonal.Application.Interface.Item
namespace Hexagonal.Business.Interface.Item
{
public class ItemCreated : IApplicationResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Hexagonal.Application.Interface.Item
namespace Hexagonal.Business.Interface.Item
{
public interface IItemQueries
{
ItemResultsDTO Query(ItemQuery query);
BusinessItemResult Query(ItemQuery query);
}

public class ItemQuery : IApplicationQuery
Expand All @@ -12,12 +12,12 @@ public class ItemQuery : IApplicationQuery
public ItemQuery(int id) => Id = id;
}

public class ItemResultsDTO : IApplicationResponse
public class BusinessItemResult : IApplicationResponse
{
public ItemDTO[] Results { get; set; }
public BusinessItem[] Results { get; set; }
}

public class ItemDTO : IApplicationResponse
public class BusinessItem : IApplicationResponse
{
public int Id { get; set; }
public string Data { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Hexagonal.Business.Interface\Hexagonal.Business.Interface.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Hexagonal.Business.Interface.Item;
using Microsoft.AspNetCore.Mvc;

namespace Hexagonal.Web.Controllers
{
public interface IItemController
{
IActionResult CreateItem(CreateItem req);
IActionResult GetItem(int id);
}
}
13 changes: 13 additions & 0 deletions Business/ModuleInterfaces/Hexagonal.Web.Interface/ItemDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Hexagonal.Web.Controllers
{
public class ItemDTOResult
{
public ItemDTO[] Results { get; set; }
}

public class ItemDTO
{
public int Id { get; set; }
public string Data { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Hexagonal.Business.Core\Hexagonal.Business.Core.csproj" />
<ProjectReference Include="..\Hexagonal.Core\Hexagonal.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Hexagonal.Business.Core;
using System;
using System;
using Hexagonal.Core;

namespace Hexagonal.Business.Handlers
namespace Hexagonal.Core.Handlers
{
public static class ItemCommandHandlers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;

namespace Hexagonal.Business.Core
namespace Hexagonal.Core
{
public class Item
{
public int Id { get; set; }
public string Data { get; set; }
public DateTime ModifiedAt { get; set; }
public DateTime ModifiedAt { get; set; }
}
}
31 changes: 0 additions & 31 deletions Framework/Hexagonal.Web/Controllers/ItemController.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Framework/Hexagonal.Web/Hexagonal.Web.csproj

This file was deleted.

Loading