diff --git a/Application/Hexagonal.Application.Impl/Hexagonal.Application.Impl.csproj b/Application/Hexagonal.Application.Impl/Hexagonal.Application.Impl.csproj deleted file mode 100644 index 7bb1a33..0000000 --- a/Application/Hexagonal.Application.Impl/Hexagonal.Application.Impl.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - netcoreapp3.1 - - - - - - - - - diff --git a/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj b/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj index f76d3c4..cbaa85c 100644 --- a/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj +++ b/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj @@ -6,9 +6,8 @@ - - - + + diff --git a/Apps/Hexagonal.App.Console/Program.cs b/Apps/Hexagonal.App.Console/Program.cs index e86c259..adcefa5 100644 --- a/Apps/Hexagonal.App.Console/Program.cs +++ b/Apps/Hexagonal.App.Console/Program.cs @@ -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 @@ -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(new CreateItem("Hello World")); + var resp = app.Dispatch(new CreateItem("Hello World")); // Get the item back - var item = app.Dispatch(new ItemQuery(resp.Id)); + var item = app.Dispatch(new ItemQuery(resp.Id)); System.Console.WriteLine($"Created and retrieved item ({item.Results[0].Id}) with data \"{item.Results[0].Data}\""); } diff --git a/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj b/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj index 9b5736f..b86c637 100644 --- a/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj +++ b/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -11,10 +11,11 @@ - - - - + + + + + diff --git a/Apps/Hexagonal.App.Web/Startup.cs b/Apps/Hexagonal.App.Web/Startup.cs index 7a9f6ca..4b039d3 100644 --- a/Apps/Hexagonal.App.Web/Startup.cs +++ b/Apps/Hexagonal.App.Web/Startup.cs @@ -1,4 +1,4 @@ -using Hexagonal.Application.Interface; +using Hexagonal.Business.Interface; using Hexagonal.Persistence.InMemory; using Hexagonal.Persistence.Interface; using Hexagonal.Web.Controllers; @@ -24,7 +24,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); var assembly = typeof(ItemController).Assembly; services.AddMvc().AddApplicationPart(assembly).AddControllersAsServices(); diff --git a/Application/Hexagonal.Application.Impl/Application.cs b/Business/Hexagonal.Business.Impl/Application.cs similarity index 79% rename from Application/Hexagonal.Application.Impl/Application.cs rename to Business/Hexagonal.Business.Impl/Application.cs index 5026f98..e4f737c 100644 --- a/Application/Hexagonal.Application.Impl/Application.cs +++ b/Business/Hexagonal.Business.Impl/Application.cs @@ -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; @@ -18,7 +18,6 @@ public TResp Dispatch(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 diff --git a/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj b/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj new file mode 100644 index 0000000..eeb9dd1 --- /dev/null +++ b/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + + + + + + + + + diff --git a/Application/Hexagonal.Application.Impl/Item/ItemCommands.cs b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs similarity index 75% rename from Application/Hexagonal.Application.Impl/Item/ItemCommands.cs rename to Business/Hexagonal.Business.Impl/Item/ItemCommands.cs index 1c79403..82ce9f0 100644 --- a/Application/Hexagonal.Application.Impl/Item/ItemCommands.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs @@ -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; @@ -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 diff --git a/Application/Hexagonal.Application.Impl/Item/ItemQueries.cs b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs similarity index 50% rename from Application/Hexagonal.Application.Impl/Item/ItemQueries.cs rename to Business/Hexagonal.Business.Impl/Item/ItemQueries.cs index 874d327..f2b9dd5 100644 --- a/Application/Hexagonal.Application.Impl/Item/ItemQueries.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs @@ -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} } }; } diff --git a/Application/Hexagonal.Application.Interface/Hexagonal.Application.Interface.csproj b/Business/Hexagonal.Business.Interface/Hexagonal.Business.Interface.csproj similarity index 100% rename from Application/Hexagonal.Application.Interface/Hexagonal.Application.Interface.csproj rename to Business/Hexagonal.Business.Interface/Hexagonal.Business.Interface.csproj diff --git a/Application/Hexagonal.Application.Interface/IApplication.cs b/Business/Hexagonal.Business.Interface/IApplication.cs similarity index 79% rename from Application/Hexagonal.Application.Interface/IApplication.cs rename to Business/Hexagonal.Business.Interface/IApplication.cs index d1b6306..f7790c5 100644 --- a/Application/Hexagonal.Application.Interface/IApplication.cs +++ b/Business/Hexagonal.Business.Interface/IApplication.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Hexagonal.Application.Interface +namespace Hexagonal.Business.Interface { public interface IApplication { diff --git a/Application/Hexagonal.Application.Interface/Item/IItemCommands.cs b/Business/Hexagonal.Business.Interface/Item/IItemCommands.cs similarity index 88% rename from Application/Hexagonal.Application.Interface/Item/IItemCommands.cs rename to Business/Hexagonal.Business.Interface/Item/IItemCommands.cs index c926b96..125718e 100644 --- a/Application/Hexagonal.Application.Interface/Item/IItemCommands.cs +++ b/Business/Hexagonal.Business.Interface/Item/IItemCommands.cs @@ -1,4 +1,4 @@ -namespace Hexagonal.Application.Interface.Item +namespace Hexagonal.Business.Interface.Item { public class ItemCreated : IApplicationResponse { diff --git a/Application/Hexagonal.Application.Interface/Item/IItemQueries.cs b/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs similarity index 52% rename from Application/Hexagonal.Application.Interface/Item/IItemQueries.cs rename to Business/Hexagonal.Business.Interface/Item/IItemQueries.cs index c7f5d2b..7dce67c 100644 --- a/Application/Hexagonal.Application.Interface/Item/IItemQueries.cs +++ b/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs @@ -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 @@ -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; } diff --git a/Framework/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj rename to Business/ModuleInterfaces/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj diff --git a/Framework/Hexagonal.Persistence.Interface/IHandleItemState.cs b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/IHandleItemState.cs similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/IHandleItemState.cs rename to Business/ModuleInterfaces/Hexagonal.Persistence.Interface/IHandleItemState.cs diff --git a/Framework/Hexagonal.Persistence.Interface/PersistedItem.cs b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/PersistedItem.cs similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/PersistedItem.cs rename to Business/ModuleInterfaces/Hexagonal.Persistence.Interface/PersistedItem.cs diff --git a/Business/ModuleInterfaces/Hexagonal.Web.Interface/Hexagonal.Web.Interface.csproj b/Business/ModuleInterfaces/Hexagonal.Web.Interface/Hexagonal.Web.Interface.csproj new file mode 100644 index 0000000..2a441b0 --- /dev/null +++ b/Business/ModuleInterfaces/Hexagonal.Web.Interface/Hexagonal.Web.Interface.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.1 + + + + + + + + + + + diff --git a/Business/ModuleInterfaces/Hexagonal.Web.Interface/IItemController.cs b/Business/ModuleInterfaces/Hexagonal.Web.Interface/IItemController.cs new file mode 100644 index 0000000..8109eda --- /dev/null +++ b/Business/ModuleInterfaces/Hexagonal.Web.Interface/IItemController.cs @@ -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); + } +} \ No newline at end of file diff --git a/Business/ModuleInterfaces/Hexagonal.Web.Interface/ItemDTO.cs b/Business/ModuleInterfaces/Hexagonal.Web.Interface/ItemDTO.cs new file mode 100644 index 0000000..79de434 --- /dev/null +++ b/Business/ModuleInterfaces/Hexagonal.Web.Interface/ItemDTO.cs @@ -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; } + } +} \ No newline at end of file diff --git a/Business/Hexagonal.Business.Handlers/Hexagonal.Business.Handlers.csproj b/Core/Hexagonal.Core.Handlers/Hexagonal.Core.Handlers.csproj similarity index 64% rename from Business/Hexagonal.Business.Handlers/Hexagonal.Business.Handlers.csproj rename to Core/Hexagonal.Core.Handlers/Hexagonal.Core.Handlers.csproj index a345274..4f980a9 100644 --- a/Business/Hexagonal.Business.Handlers/Hexagonal.Business.Handlers.csproj +++ b/Core/Hexagonal.Core.Handlers/Hexagonal.Core.Handlers.csproj @@ -5,7 +5,7 @@ - + diff --git a/Business/Hexagonal.Business.Handlers/ItemCommandHandlers.cs b/Core/Hexagonal.Core.Handlers/ItemCommandHandlers.cs similarity index 73% rename from Business/Hexagonal.Business.Handlers/ItemCommandHandlers.cs rename to Core/Hexagonal.Core.Handlers/ItemCommandHandlers.cs index 1a303c9..b8850f6 100644 --- a/Business/Hexagonal.Business.Handlers/ItemCommandHandlers.cs +++ b/Core/Hexagonal.Core.Handlers/ItemCommandHandlers.cs @@ -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 { diff --git a/Business/Hexagonal.Business.Core/Hexagonal.Business.Core.csproj b/Core/Hexagonal.Core/Hexagonal.Core.csproj similarity index 100% rename from Business/Hexagonal.Business.Core/Hexagonal.Business.Core.csproj rename to Core/Hexagonal.Core/Hexagonal.Core.csproj diff --git a/Business/Hexagonal.Business.Core/Item.cs b/Core/Hexagonal.Core/Item.cs similarity index 61% rename from Business/Hexagonal.Business.Core/Item.cs rename to Core/Hexagonal.Core/Item.cs index b572b8b..87e7a8d 100644 --- a/Business/Hexagonal.Business.Core/Item.cs +++ b/Core/Hexagonal.Core/Item.cs @@ -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; } } } diff --git a/Framework/Hexagonal.Web/Controllers/ItemController.cs b/Framework/Hexagonal.Web/Controllers/ItemController.cs deleted file mode 100644 index 418098a..0000000 --- a/Framework/Hexagonal.Web/Controllers/ItemController.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Hexagonal.Application.Interface; -using Hexagonal.Application.Interface.Item; -using Microsoft.AspNetCore.Mvc; - -namespace Hexagonal.Web.Controllers -{ - [ApiController] - [Route("[controller]")] - public class ItemController : ControllerBase - { - private readonly IApplication _app; - - public ItemController(IApplication app) => _app = app; - - - [HttpGet] - [Route("{id}")] - public IActionResult GetItem(int id) - { - var resp = _app.Dispatch(new ItemQuery(id)); - return resp == null ? NotFound() : (IActionResult)Ok(resp); - } - - [HttpPost] - public IActionResult CreateItem(CreateItem req) - { - var resp = _app.Dispatch(req); - return resp == null ? Conflict() : (IActionResult)Ok(resp); - } - } -} diff --git a/Framework/Hexagonal.Web/Hexagonal.Web.csproj b/Framework/Hexagonal.Web/Hexagonal.Web.csproj deleted file mode 100644 index a54e303..0000000 --- a/Framework/Hexagonal.Web/Hexagonal.Web.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netcoreapp3.1 - - - - - - - - - - - diff --git a/Hexagonal.sln b/Hexagonal.sln index c3a20d0..3dba0bb 100644 --- a/Hexagonal.sln +++ b/Hexagonal.sln @@ -3,35 +3,39 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cmd", "Cmd", "{7E055570-92A0-48E6-9571-893FEB440AD3}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{7E055570-92A0-48E6-9571-893FEB440AD3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.App.Console", "Apps\Hexagonal.App.Console\Hexagonal.App.Console.csproj", "{CA9FB7CF-69ED-420A-B7F1-5ED376CD0BF4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{77B52602-26AC-4FA2-A65F-1147493E01DC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{77B52602-26AC-4FA2-A65F-1147493E01DC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web", "Web", "{702FFDEA-1685-47A4-8F5D-4BB604B89088}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{AD24F3C1-CB43-4FFD-9C95-05678952206F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.Interface", "Framework\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj", "{ACA84DCE-3BF5-4141-80DA-440675B2B98B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{7AABB368-F1CA-49AD-B160-D31AB6BEADF3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.InMemory", "Framework\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj", "{63E48604-C789-40FC-9E81-BB8A078A198D}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{9308FD80-B800-42EA-AA70-E16A7A1D5742}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{7AABB368-F1CA-49AD-B160-D31AB6BEADF3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Business.Interface", "Business\Hexagonal.Business.Interface\Hexagonal.Business.Interface.csproj", "{699D6A4F-43F2-4BB0-A532-8B90CCA3B692}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{9308FD80-B800-42EA-AA70-E16A7A1D5742}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Business.Impl", "Business\Hexagonal.Business.Impl\Hexagonal.Business.Impl.csproj", "{249A602E-9458-4B25-8D84-6AE9F7E01359}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Application.Interface", "Application\Hexagonal.Application.Interface\Hexagonal.Application.Interface.csproj", "{699D6A4F-43F2-4BB0-A532-8B90CCA3B692}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.App.Web", "Apps\Hexagonal.App.Web\Hexagonal.App.Web.csproj", "{0815C30B-38CA-457F-B707-BC3435C0C29B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Application.Impl", "Application\Hexagonal.Application.Impl\Hexagonal.Application.Impl.csproj", "{249A602E-9458-4B25-8D84-6AE9F7E01359}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Core", "Core\Hexagonal.Core\Hexagonal.Core.csproj", "{603AF8CB-F2AF-4BC7-92A5-D8A9F6F8E05C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.App.Web", "Apps\Hexagonal.App.Web\Hexagonal.App.Web.csproj", "{0815C30B-38CA-457F-B707-BC3435C0C29B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Core.Handlers", "Core\Hexagonal.Core.Handlers\Hexagonal.Core.Handlers.csproj", "{05E332B7-95EC-4202-9E5E-AA21B34D497F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ModuleInterfaces", "ModuleInterfaces", "{52EBCEBD-C933-4F3D-9352-1B42D8B11EC3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.Interface", "Business\ModuleInterfaces\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj", "{4DC32D72-F99B-425B-8AFC-572155EE83EC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Business.Core", "Business\Hexagonal.Business.Core\Hexagonal.Business.Core.csproj", "{603AF8CB-F2AF-4BC7-92A5-D8A9F6F8E05C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Web.Interface", "Business\ModuleInterfaces\Hexagonal.Web.Interface\Hexagonal.Web.Interface.csproj", "{649CEDF9-5578-486B-B8DB-5DDDA5950898}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Business.Handlers", "Business\Hexagonal.Business.Handlers\Hexagonal.Business.Handlers.csproj", "{05E332B7-95EC-4202-9E5E-AA21B34D497F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.InMemory", "Modules\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj", "{3A14CC49-D465-4B76-AF3F-B633AF7EE43A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Web", "Framework\Hexagonal.Web\Hexagonal.Web.csproj", "{44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Web", "Modules\Hexagonal.Web\Hexagonal.Web.csproj", "{E6C7182A-CD00-483E-A391-8F04132BD43F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -43,14 +47,6 @@ Global {CA9FB7CF-69ED-420A-B7F1-5ED376CD0BF4}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA9FB7CF-69ED-420A-B7F1-5ED376CD0BF4}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA9FB7CF-69ED-420A-B7F1-5ED376CD0BF4}.Release|Any CPU.Build.0 = Release|Any CPU - {ACA84DCE-3BF5-4141-80DA-440675B2B98B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ACA84DCE-3BF5-4141-80DA-440675B2B98B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ACA84DCE-3BF5-4141-80DA-440675B2B98B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ACA84DCE-3BF5-4141-80DA-440675B2B98B}.Release|Any CPU.Build.0 = Release|Any CPU - {63E48604-C789-40FC-9E81-BB8A078A198D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63E48604-C789-40FC-9E81-BB8A078A198D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63E48604-C789-40FC-9E81-BB8A078A198D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63E48604-C789-40FC-9E81-BB8A078A198D}.Release|Any CPU.Build.0 = Release|Any CPU {699D6A4F-43F2-4BB0-A532-8B90CCA3B692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {699D6A4F-43F2-4BB0-A532-8B90CCA3B692}.Debug|Any CPU.Build.0 = Debug|Any CPU {699D6A4F-43F2-4BB0-A532-8B90CCA3B692}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,10 +67,22 @@ Global {05E332B7-95EC-4202-9E5E-AA21B34D497F}.Debug|Any CPU.Build.0 = Debug|Any CPU {05E332B7-95EC-4202-9E5E-AA21B34D497F}.Release|Any CPU.ActiveCfg = Release|Any CPU {05E332B7-95EC-4202-9E5E-AA21B34D497F}.Release|Any CPU.Build.0 = Release|Any CPU - {44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}.Release|Any CPU.Build.0 = Release|Any CPU + {4DC32D72-F99B-425B-8AFC-572155EE83EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DC32D72-F99B-425B-8AFC-572155EE83EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DC32D72-F99B-425B-8AFC-572155EE83EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DC32D72-F99B-425B-8AFC-572155EE83EC}.Release|Any CPU.Build.0 = Release|Any CPU + {649CEDF9-5578-486B-B8DB-5DDDA5950898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {649CEDF9-5578-486B-B8DB-5DDDA5950898}.Debug|Any CPU.Build.0 = Debug|Any CPU + {649CEDF9-5578-486B-B8DB-5DDDA5950898}.Release|Any CPU.ActiveCfg = Release|Any CPU + {649CEDF9-5578-486B-B8DB-5DDDA5950898}.Release|Any CPU.Build.0 = Release|Any CPU + {3A14CC49-D465-4B76-AF3F-B633AF7EE43A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A14CC49-D465-4B76-AF3F-B633AF7EE43A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A14CC49-D465-4B76-AF3F-B633AF7EE43A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A14CC49-D465-4B76-AF3F-B633AF7EE43A}.Release|Any CPU.Build.0 = Release|Any CPU + {E6C7182A-CD00-483E-A391-8F04132BD43F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6C7182A-CD00-483E-A391-8F04132BD43F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6C7182A-CD00-483E-A391-8F04132BD43F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6C7182A-CD00-483E-A391-8F04132BD43F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -83,14 +91,16 @@ Global {CA9FB7CF-69ED-420A-B7F1-5ED376CD0BF4} = {7E055570-92A0-48E6-9571-893FEB440AD3} {702FFDEA-1685-47A4-8F5D-4BB604B89088} = {77B52602-26AC-4FA2-A65F-1147493E01DC} {AD24F3C1-CB43-4FFD-9C95-05678952206F} = {77B52602-26AC-4FA2-A65F-1147493E01DC} - {ACA84DCE-3BF5-4141-80DA-440675B2B98B} = {AD24F3C1-CB43-4FFD-9C95-05678952206F} - {63E48604-C789-40FC-9E81-BB8A078A198D} = {AD24F3C1-CB43-4FFD-9C95-05678952206F} {699D6A4F-43F2-4BB0-A532-8B90CCA3B692} = {7AABB368-F1CA-49AD-B160-D31AB6BEADF3} {249A602E-9458-4B25-8D84-6AE9F7E01359} = {7AABB368-F1CA-49AD-B160-D31AB6BEADF3} {0815C30B-38CA-457F-B707-BC3435C0C29B} = {7E055570-92A0-48E6-9571-893FEB440AD3} {603AF8CB-F2AF-4BC7-92A5-D8A9F6F8E05C} = {9308FD80-B800-42EA-AA70-E16A7A1D5742} {05E332B7-95EC-4202-9E5E-AA21B34D497F} = {9308FD80-B800-42EA-AA70-E16A7A1D5742} - {44058B61-F841-4DD0-A2E4-60BA6FDF1CF9} = {702FFDEA-1685-47A4-8F5D-4BB604B89088} + {52EBCEBD-C933-4F3D-9352-1B42D8B11EC3} = {7AABB368-F1CA-49AD-B160-D31AB6BEADF3} + {4DC32D72-F99B-425B-8AFC-572155EE83EC} = {52EBCEBD-C933-4F3D-9352-1B42D8B11EC3} + {649CEDF9-5578-486B-B8DB-5DDDA5950898} = {52EBCEBD-C933-4F3D-9352-1B42D8B11EC3} + {3A14CC49-D465-4B76-AF3F-B633AF7EE43A} = {AD24F3C1-CB43-4FFD-9C95-05678952206F} + {E6C7182A-CD00-483E-A391-8F04132BD43F} = {702FFDEA-1685-47A4-8F5D-4BB604B89088} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3735A3C1-7026-47E8-BDE7-E7D76C4C0EC4} diff --git a/Framework/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj b/Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj similarity index 54% rename from Framework/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj rename to Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj index d3b8e67..0bc43f9 100644 --- a/Framework/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj +++ b/Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj @@ -5,7 +5,7 @@ - + diff --git a/Framework/Hexagonal.Persistence.InMemory/InMemoryStore.cs b/Modules/Hexagonal.Persistence.InMemory/InMemoryStore.cs similarity index 100% rename from Framework/Hexagonal.Persistence.InMemory/InMemoryStore.cs rename to Modules/Hexagonal.Persistence.InMemory/InMemoryStore.cs diff --git a/Modules/Hexagonal.Web/Controllers/ItemController.cs b/Modules/Hexagonal.Web/Controllers/ItemController.cs new file mode 100644 index 0000000..b586e8e --- /dev/null +++ b/Modules/Hexagonal.Web/Controllers/ItemController.cs @@ -0,0 +1,46 @@ +using Hexagonal.Business.Interface; +using Hexagonal.Business.Interface.Item; +using Microsoft.AspNetCore.Mvc; +using System.Linq; + +namespace Hexagonal.Web.Controllers +{ + [ApiController] + [Route("[controller]")] + public class ItemController : ControllerBase, IItemController + { + private readonly IApplication _app; + + public ItemController(IApplication app) => _app = app; + + + [HttpGet] + [Route("{id}")] + public IActionResult GetItem(int id) + { + var resp = _app.Dispatch(new ItemQuery(id)); + return resp == null + ? NotFound() + : (IActionResult)Ok( + new ItemDTOResult + { + Results = resp.Results.Select(r => new ItemDTO + { + Id = r.Id, + Data = r.Data + }).ToArray() + }); + } + + [HttpPost] + public IActionResult CreateItem(CreateItem req) + { + var resp = _app.Dispatch(req); + return resp == null ? Conflict() : (IActionResult)Ok(new ItemDTO + { + Id = resp.Id, + Data = resp.Data + }); + } + } +} diff --git a/Modules/Hexagonal.Web/Hexagonal.Web.csproj b/Modules/Hexagonal.Web/Hexagonal.Web.csproj new file mode 100644 index 0000000..208e73e --- /dev/null +++ b/Modules/Hexagonal.Web/Hexagonal.Web.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp3.1 + + + + + + + + + + + +