From 21b04533cc8c748ba5c1cc000ae922450b74d81a Mon Sep 17 00:00:00 2001 From: Allan Loh Date: Tue, 1 Sep 2020 09:25:40 +0800 Subject: [PATCH 1/2] Renaming for clarity --- .../Hexagonal.Application.Impl.csproj | 13 ----------- .../Hexagonal.App.Console.csproj | 7 +++--- Apps/Hexagonal.App.Console/Program.cs | 5 +++-- .../Hexagonal.App.Web.csproj | 11 +++++----- Apps/Hexagonal.App.Web/Startup.cs | 4 ++-- .../Hexagonal.Business.Impl}/Application.cs | 10 ++++----- .../Hexagonal.Business.Impl.csproj | 14 ++++++++++++ .../Item/ItemCommands.cs | 6 ++--- .../Item/ItemQueries.cs | 4 ++-- .../Hexagonal.Business.Interface.csproj | 0 .../IApplication.cs | 6 +---- .../Item/IItemCommands.cs | 2 +- .../Item/IItemQueries.cs | 2 +- .../Hexagonal.Core.Handlers.csproj | 2 +- .../ItemCommandHandlers.cs | 6 ++--- .../Hexagonal.Core/Hexagonal.Core.csproj | 0 .../Hexagonal.Core}/Item.cs | 4 ++-- Hexagonal.sln | 22 +++++++++---------- .../Hexagonal.Persistence.InMemory.csproj | 0 .../InMemoryStore.cs | 0 .../Hexagonal.Persistence.Interface.csproj | 0 .../IHandleItemState.cs | 0 .../PersistedItem.cs | 0 .../Controllers/ItemController.cs | 4 ++-- .../Hexagonal.Web/Hexagonal.Web.csproj | 7 +++--- 25 files changed, 65 insertions(+), 64 deletions(-) delete mode 100644 Application/Hexagonal.Application.Impl/Hexagonal.Application.Impl.csproj rename {Application/Hexagonal.Application.Impl => Business/Hexagonal.Business.Impl}/Application.cs (79%) create mode 100644 Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj rename {Application/Hexagonal.Application.Impl => Business/Hexagonal.Business.Impl}/Item/ItemCommands.cs (87%) rename {Application/Hexagonal.Application.Impl => Business/Hexagonal.Business.Impl}/Item/ItemQueries.cs (84%) rename Application/Hexagonal.Application.Interface/Hexagonal.Application.Interface.csproj => Business/Hexagonal.Business.Interface/Hexagonal.Business.Interface.csproj (100%) rename {Application/Hexagonal.Application.Interface => Business/Hexagonal.Business.Interface}/IApplication.cs (79%) rename {Application/Hexagonal.Application.Interface => Business/Hexagonal.Business.Interface}/Item/IItemCommands.cs (88%) rename {Application/Hexagonal.Application.Interface => Business/Hexagonal.Business.Interface}/Item/IItemQueries.cs (90%) rename Business/Hexagonal.Business.Handlers/Hexagonal.Business.Handlers.csproj => Core/Hexagonal.Core.Handlers/Hexagonal.Core.Handlers.csproj (64%) rename {Business/Hexagonal.Business.Handlers => Core/Hexagonal.Core.Handlers}/ItemCommandHandlers.cs (73%) rename Business/Hexagonal.Business.Core/Hexagonal.Business.Core.csproj => Core/Hexagonal.Core/Hexagonal.Core.csproj (100%) rename {Business/Hexagonal.Business.Core => Core/Hexagonal.Core}/Item.cs (61%) rename {Framework => Shell}/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj (100%) rename {Framework => Shell}/Hexagonal.Persistence.InMemory/InMemoryStore.cs (100%) rename {Framework => Shell}/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj (100%) rename {Framework => Shell}/Hexagonal.Persistence.Interface/IHandleItemState.cs (100%) rename {Framework => Shell}/Hexagonal.Persistence.Interface/PersistedItem.cs (100%) rename {Framework => Shell}/Hexagonal.Web/Controllers/ItemController.cs (90%) rename {Framework => Shell}/Hexagonal.Web/Hexagonal.Web.csproj (52%) 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..9a394ef 100644 --- a/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj +++ b/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj @@ -6,9 +6,10 @@ - - - + + + + diff --git a/Apps/Hexagonal.App.Console/Program.cs b/Apps/Hexagonal.App.Console/Program.cs index e86c259..4ebef69 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,7 +9,7 @@ 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"); diff --git a/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj b/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj index 9b5736f..99c5360 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..48ca02e 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; 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..0b74b26 --- /dev/null +++ b/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp3.1 + + + + + + + + + + diff --git a/Application/Hexagonal.Application.Impl/Item/ItemCommands.cs b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs similarity index 87% rename from Application/Hexagonal.Application.Impl/Item/ItemCommands.cs rename to Business/Hexagonal.Business.Impl/Item/ItemCommands.cs index 1c79403..7fae123 100644 --- a/Application/Hexagonal.Application.Impl/Item/ItemCommands.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs @@ -1,8 +1,8 @@ -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 { diff --git a/Application/Hexagonal.Application.Impl/Item/ItemQueries.cs b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs similarity index 84% rename from Application/Hexagonal.Application.Impl/Item/ItemQueries.cs rename to Business/Hexagonal.Business.Impl/Item/ItemQueries.cs index 874d327..eaff714 100644 --- a/Application/Hexagonal.Application.Impl/Item/ItemQueries.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs @@ -1,7 +1,7 @@ -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 { 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 90% rename from Application/Hexagonal.Application.Interface/Item/IItemQueries.cs rename to Business/Hexagonal.Business.Interface/Item/IItemQueries.cs index c7f5d2b..6b074f1 100644 --- a/Application/Hexagonal.Application.Interface/Item/IItemQueries.cs +++ b/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs @@ -1,4 +1,4 @@ -namespace Hexagonal.Application.Interface.Item +namespace Hexagonal.Business.Interface.Item { public interface IItemQueries { 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/Hexagonal.sln b/Hexagonal.sln index c3a20d0..91367bb 100644 --- a/Hexagonal.sln +++ b/Hexagonal.sln @@ -3,35 +3,35 @@ 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}") = "Shell", "Shell", "{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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.Interface", "Shell\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj", "{ACA84DCE-3BF5-4141-80DA-440675B2B98B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.InMemory", "Framework\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj", "{63E48604-C789-40FC-9E81-BB8A078A198D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.InMemory", "Shell\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj", "{63E48604-C789-40FC-9E81-BB8A078A198D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{7AABB368-F1CA-49AD-B160-D31AB6BEADF3}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{7AABB368-F1CA-49AD-B160-D31AB6BEADF3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{9308FD80-B800-42EA-AA70-E16A7A1D5742}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{9308FD80-B800-42EA-AA70-E16A7A1D5742}" 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.Business.Interface", "Business\Hexagonal.Business.Interface\Hexagonal.Business.Interface.csproj", "{699D6A4F-43F2-4BB0-A532-8B90CCA3B692}" 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.Business.Impl", "Business\Hexagonal.Business.Impl\Hexagonal.Business.Impl.csproj", "{249A602E-9458-4B25-8D84-6AE9F7E01359}" EndProject 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.Business.Core", "Business\Hexagonal.Business.Core\Hexagonal.Business.Core.csproj", "{603AF8CB-F2AF-4BC7-92A5-D8A9F6F8E05C}" +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.Business.Handlers", "Business\Hexagonal.Business.Handlers\Hexagonal.Business.Handlers.csproj", "{05E332B7-95EC-4202-9E5E-AA21B34D497F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Core.Handlers", "Core\Hexagonal.Core.Handlers\Hexagonal.Core.Handlers.csproj", "{05E332B7-95EC-4202-9E5E-AA21B34D497F}" 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", "Shell\Hexagonal.Web\Hexagonal.Web.csproj", "{44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Framework/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj b/Shell/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj similarity index 100% rename from Framework/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj rename to Shell/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj diff --git a/Framework/Hexagonal.Persistence.InMemory/InMemoryStore.cs b/Shell/Hexagonal.Persistence.InMemory/InMemoryStore.cs similarity index 100% rename from Framework/Hexagonal.Persistence.InMemory/InMemoryStore.cs rename to Shell/Hexagonal.Persistence.InMemory/InMemoryStore.cs diff --git a/Framework/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj b/Shell/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj rename to Shell/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj diff --git a/Framework/Hexagonal.Persistence.Interface/IHandleItemState.cs b/Shell/Hexagonal.Persistence.Interface/IHandleItemState.cs similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/IHandleItemState.cs rename to Shell/Hexagonal.Persistence.Interface/IHandleItemState.cs diff --git a/Framework/Hexagonal.Persistence.Interface/PersistedItem.cs b/Shell/Hexagonal.Persistence.Interface/PersistedItem.cs similarity index 100% rename from Framework/Hexagonal.Persistence.Interface/PersistedItem.cs rename to Shell/Hexagonal.Persistence.Interface/PersistedItem.cs diff --git a/Framework/Hexagonal.Web/Controllers/ItemController.cs b/Shell/Hexagonal.Web/Controllers/ItemController.cs similarity index 90% rename from Framework/Hexagonal.Web/Controllers/ItemController.cs rename to Shell/Hexagonal.Web/Controllers/ItemController.cs index 418098a..fa7d6ed 100644 --- a/Framework/Hexagonal.Web/Controllers/ItemController.cs +++ b/Shell/Hexagonal.Web/Controllers/ItemController.cs @@ -1,5 +1,5 @@ -using Hexagonal.Application.Interface; -using Hexagonal.Application.Interface.Item; +using Hexagonal.Business.Interface; +using Hexagonal.Business.Interface.Item; using Microsoft.AspNetCore.Mvc; namespace Hexagonal.Web.Controllers diff --git a/Framework/Hexagonal.Web/Hexagonal.Web.csproj b/Shell/Hexagonal.Web/Hexagonal.Web.csproj similarity index 52% rename from Framework/Hexagonal.Web/Hexagonal.Web.csproj rename to Shell/Hexagonal.Web/Hexagonal.Web.csproj index a54e303..a443b41 100644 --- a/Framework/Hexagonal.Web/Hexagonal.Web.csproj +++ b/Shell/Hexagonal.Web/Hexagonal.Web.csproj @@ -5,11 +5,12 @@ - + - + - + + From be13aaa82035924a753685bb9ab2423c4a2a4b3e Mon Sep 17 00:00:00 2001 From: Allan Loh Date: Tue, 1 Sep 2020 17:44:31 +0800 Subject: [PATCH 2/2] Rename and move interfaces to business --- .../Hexagonal.App.Console.csproj | 4 +- Apps/Hexagonal.App.Console/Program.cs | 4 +- .../Hexagonal.App.Web.csproj | 6 +-- .../Hexagonal.Business.Impl/Application.cs | 1 - .../Hexagonal.Business.Impl.csproj | 5 +- .../Item/ItemCommands.cs | 4 +- .../Item/ItemQueries.cs | 6 +-- .../Item/IItemQueries.cs | 8 +-- .../Hexagonal.Persistence.Interface.csproj | 0 .../IHandleItemState.cs | 0 .../PersistedItem.cs | 0 .../Hexagonal.Web.Interface.csproj | 15 ++++++ .../IItemController.cs | 11 ++++ .../Hexagonal.Web.Interface/ItemDTO.cs | 13 +++++ Hexagonal.sln | 52 +++++++++++-------- .../Hexagonal.Persistence.InMemory.csproj | 2 +- .../InMemoryStore.cs | 0 .../Controllers/ItemController.cs | 46 ++++++++++++++++ .../Hexagonal.Web/Hexagonal.Web.csproj | 4 +- .../Controllers/ItemController.cs | 31 ----------- 20 files changed, 136 insertions(+), 76 deletions(-) rename {Shell => Business/ModuleInterfaces}/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj (100%) rename {Shell => Business/ModuleInterfaces}/Hexagonal.Persistence.Interface/IHandleItemState.cs (100%) rename {Shell => Business/ModuleInterfaces}/Hexagonal.Persistence.Interface/PersistedItem.cs (100%) create mode 100644 Business/ModuleInterfaces/Hexagonal.Web.Interface/Hexagonal.Web.Interface.csproj create mode 100644 Business/ModuleInterfaces/Hexagonal.Web.Interface/IItemController.cs create mode 100644 Business/ModuleInterfaces/Hexagonal.Web.Interface/ItemDTO.cs rename {Shell => Modules}/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj (54%) rename {Shell => Modules}/Hexagonal.Persistence.InMemory/InMemoryStore.cs (100%) create mode 100644 Modules/Hexagonal.Web/Controllers/ItemController.cs rename {Shell => Modules}/Hexagonal.Web/Hexagonal.Web.csproj (75%) delete mode 100644 Shell/Hexagonal.Web/Controllers/ItemController.cs diff --git a/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj b/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj index 9a394ef..cbaa85c 100644 --- a/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj +++ b/Apps/Hexagonal.App.Console/Hexagonal.App.Console.csproj @@ -7,9 +7,7 @@ - - - + diff --git a/Apps/Hexagonal.App.Console/Program.cs b/Apps/Hexagonal.App.Console/Program.cs index 4ebef69..adcefa5 100644 --- a/Apps/Hexagonal.App.Console/Program.cs +++ b/Apps/Hexagonal.App.Console/Program.cs @@ -14,10 +14,10 @@ static void Main(string[] args) 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 99c5360..b86c637 100644 --- a/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj +++ b/Apps/Hexagonal.App.Web/Hexagonal.App.Web.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/Business/Hexagonal.Business.Impl/Application.cs b/Business/Hexagonal.Business.Impl/Application.cs index 48ca02e..e4f737c 100644 --- a/Business/Hexagonal.Business.Impl/Application.cs +++ b/Business/Hexagonal.Business.Impl/Application.cs @@ -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 index 0b74b26..eeb9dd1 100644 --- a/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj +++ b/Business/Hexagonal.Business.Impl/Hexagonal.Business.Impl.csproj @@ -5,10 +5,9 @@ - - - + + diff --git a/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs index 7fae123..82ce9f0 100644 --- a/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemCommands.cs @@ -6,7 +6,7 @@ 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/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs index eaff714..f2b9dd5 100644 --- a/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs +++ b/Business/Hexagonal.Business.Impl/Item/ItemQueries.cs @@ -5,15 +5,15 @@ 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/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs b/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs index 6b074f1..7dce67c 100644 --- a/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs +++ b/Business/Hexagonal.Business.Interface/Item/IItemQueries.cs @@ -2,7 +2,7 @@ { 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/Shell/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj similarity index 100% rename from Shell/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj rename to Business/ModuleInterfaces/Hexagonal.Persistence.Interface/Hexagonal.Persistence.Interface.csproj diff --git a/Shell/Hexagonal.Persistence.Interface/IHandleItemState.cs b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/IHandleItemState.cs similarity index 100% rename from Shell/Hexagonal.Persistence.Interface/IHandleItemState.cs rename to Business/ModuleInterfaces/Hexagonal.Persistence.Interface/IHandleItemState.cs diff --git a/Shell/Hexagonal.Persistence.Interface/PersistedItem.cs b/Business/ModuleInterfaces/Hexagonal.Persistence.Interface/PersistedItem.cs similarity index 100% rename from Shell/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/Hexagonal.sln b/Hexagonal.sln index 91367bb..3dba0bb 100644 --- a/Hexagonal.sln +++ b/Hexagonal.sln @@ -7,16 +7,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{7E055570-9 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}") = "Shell", "Shell", "{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", "Shell\Hexagonal.Persistence.Interface\Hexagonal.Persistence.Interface.csproj", "{ACA84DCE-3BF5-4141-80DA-440675B2B98B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Persistence.InMemory", "Shell\Hexagonal.Persistence.InMemory\Hexagonal.Persistence.InMemory.csproj", "{63E48604-C789-40FC-9E81-BB8A078A198D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Business", "Business", "{7AABB368-F1CA-49AD-B160-D31AB6BEADF3}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{9308FD80-B800-42EA-AA70-E16A7A1D5742}" @@ -31,7 +27,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Core", "Core\Hexa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Core.Handlers", "Core\Hexagonal.Core.Handlers\Hexagonal.Core.Handlers.csproj", "{05E332B7-95EC-4202-9E5E-AA21B34D497F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hexagonal.Web", "Shell\Hexagonal.Web\Hexagonal.Web.csproj", "{44058B61-F841-4DD0-A2E4-60BA6FDF1CF9}" +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.Web.Interface", "Business\ModuleInterfaces\Hexagonal.Web.Interface\Hexagonal.Web.Interface.csproj", "{649CEDF9-5578-486B-B8DB-5DDDA5950898}" +EndProject +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", "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/Shell/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj b/Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj similarity index 54% rename from Shell/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj rename to Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj index d3b8e67..0bc43f9 100644 --- a/Shell/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj +++ b/Modules/Hexagonal.Persistence.InMemory/Hexagonal.Persistence.InMemory.csproj @@ -5,7 +5,7 @@ - + diff --git a/Shell/Hexagonal.Persistence.InMemory/InMemoryStore.cs b/Modules/Hexagonal.Persistence.InMemory/InMemoryStore.cs similarity index 100% rename from Shell/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/Shell/Hexagonal.Web/Hexagonal.Web.csproj b/Modules/Hexagonal.Web/Hexagonal.Web.csproj similarity index 75% rename from Shell/Hexagonal.Web/Hexagonal.Web.csproj rename to Modules/Hexagonal.Web/Hexagonal.Web.csproj index a443b41..208e73e 100644 --- a/Shell/Hexagonal.Web/Hexagonal.Web.csproj +++ b/Modules/Hexagonal.Web/Hexagonal.Web.csproj @@ -7,10 +7,10 @@ - + - + diff --git a/Shell/Hexagonal.Web/Controllers/ItemController.cs b/Shell/Hexagonal.Web/Controllers/ItemController.cs deleted file mode 100644 index fa7d6ed..0000000 --- a/Shell/Hexagonal.Web/Controllers/ItemController.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Hexagonal.Business.Interface; -using Hexagonal.Business.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); - } - } -}