From 2ad4532bfe2d96fac9a17939466b8e4b2396d473 Mon Sep 17 00:00:00 2001 From: Nadir Badnjevic Date: Mon, 15 Jan 2024 20:50:13 +0100 Subject: [PATCH] refactor: fix dependecy issue on Feature and refactor domain layer --- src/Application/Common/Interfaces/ICsvFileBuilder.cs | 2 +- src/Application/{Entities => Domain/Todos}/TodoItem.cs | 10 +++++++++- src/Application/{Entities => Domain/Todos}/TodoList.cs | 4 ++-- src/Application/{ => Domain}/ValueObjects/Colour.cs | 2 +- src/Application/Features/TodoItems/CreateTodoItem.cs | 2 +- src/Application/Features/TodoItems/DeleteTodoItem.cs | 2 +- .../EventHandlers/TodoItemCompletedEventHandler.cs | 2 +- .../Features/TodoItems/GetTodoItemsWithPagination.cs | 2 +- src/Application/Features/TodoItems/UpdateTodoItem.cs | 2 +- .../Features/TodoItems/UpdateTodoItemDetail.cs | 2 +- src/Application/Features/TodoLists/CreateTodoList.cs | 2 +- src/Application/Features/TodoLists/DeleteTodoList.cs | 2 +- src/Application/Features/TodoLists/ExportTodos.cs | 10 +--------- src/Application/Features/TodoLists/GetTodos.cs | 2 +- src/Application/Features/TodoLists/UpdateTodoList.cs | 2 +- src/Application/Infrastructure/Files/CsvFileBuilder.cs | 2 +- .../Infrastructure/Files/Maps/TodoItemRecordMap.cs | 2 +- .../Infrastructure/Persistence/ApplicationDbContext.cs | 2 +- .../Persistence/ApplicationDbContextSeed.cs | 4 ++-- .../Configurations/TodoItemConfiguration.cs | 2 +- .../Configurations/TodoListConfiguration.cs | 2 +- .../Common/Mappings/MappingTests.cs | 4 ++-- .../Application.UnitTests/ValueObjects/ColourTests.cs | 2 +- 23 files changed, 34 insertions(+), 34 deletions(-) rename src/Application/{Entities => Domain/Todos}/TodoItem.cs (76%) rename src/Application/{Entities => Domain/Todos}/TodoList.cs (68%) rename src/Application/{ => Domain}/ValueObjects/Colour.cs (91%) diff --git a/src/Application/Common/Interfaces/ICsvFileBuilder.cs b/src/Application/Common/Interfaces/ICsvFileBuilder.cs index e9749b7..60fb863 100644 --- a/src/Application/Common/Interfaces/ICsvFileBuilder.cs +++ b/src/Application/Common/Interfaces/ICsvFileBuilder.cs @@ -1,4 +1,4 @@ -using VerticalSliceArchitecture.Application.Features.TodoLists; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Common.Interfaces; diff --git a/src/Application/Entities/TodoItem.cs b/src/Application/Domain/Todos/TodoItem.cs similarity index 76% rename from src/Application/Entities/TodoItem.cs rename to src/Application/Domain/Todos/TodoItem.cs index 9a0646f..915cfbb 100644 --- a/src/Application/Entities/TodoItem.cs +++ b/src/Application/Domain/Todos/TodoItem.cs @@ -1,6 +1,7 @@ using VerticalSliceArchitecture.Application.Common; +using VerticalSliceArchitecture.Application.Common.Mappings; -namespace VerticalSliceArchitecture.Application.Entities; +namespace VerticalSliceArchitecture.Application.Domain.Todos; public class TodoItem : AuditableEntity, IHasDomainEvent { @@ -53,3 +54,10 @@ public enum PriorityLevel Medium = 2, High = 3 } + +public class TodoItemRecord : IMapFrom +{ + public string? Title { get; set; } + + public bool Done { get; set; } +} diff --git a/src/Application/Entities/TodoList.cs b/src/Application/Domain/Todos/TodoList.cs similarity index 68% rename from src/Application/Entities/TodoList.cs rename to src/Application/Domain/Todos/TodoList.cs index 4f04bc0..dfad45c 100644 --- a/src/Application/Entities/TodoList.cs +++ b/src/Application/Domain/Todos/TodoList.cs @@ -1,7 +1,7 @@ using VerticalSliceArchitecture.Application.Common; -using VerticalSliceArchitecture.Application.ValueObjects; +using VerticalSliceArchitecture.Application.Domain.ValueObjects; -namespace VerticalSliceArchitecture.Application.Entities; +namespace VerticalSliceArchitecture.Application.Domain.Todos; public class TodoList : AuditableEntity { diff --git a/src/Application/ValueObjects/Colour.cs b/src/Application/Domain/ValueObjects/Colour.cs similarity index 91% rename from src/Application/ValueObjects/Colour.cs rename to src/Application/Domain/ValueObjects/Colour.cs index 37748fc..d550bfc 100644 --- a/src/Application/ValueObjects/Colour.cs +++ b/src/Application/Domain/ValueObjects/Colour.cs @@ -1,7 +1,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -namespace VerticalSliceArchitecture.Application.ValueObjects; +namespace VerticalSliceArchitecture.Application.Domain.ValueObjects; public class Colour : ValueObject { diff --git a/src/Application/Features/TodoItems/CreateTodoItem.cs b/src/Application/Features/TodoItems/CreateTodoItem.cs index 7dffee4..d42905a 100644 --- a/src/Application/Features/TodoItems/CreateTodoItem.cs +++ b/src/Application/Features/TodoItems/CreateTodoItem.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc; using VerticalSliceArchitecture.Application.Common; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoItems; diff --git a/src/Application/Features/TodoItems/DeleteTodoItem.cs b/src/Application/Features/TodoItems/DeleteTodoItem.cs index 19b08f4..b50881d 100644 --- a/src/Application/Features/TodoItems/DeleteTodoItem.cs +++ b/src/Application/Features/TodoItems/DeleteTodoItem.cs @@ -4,7 +4,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoItems; diff --git a/src/Application/Features/TodoItems/EventHandlers/TodoItemCompletedEventHandler.cs b/src/Application/Features/TodoItems/EventHandlers/TodoItemCompletedEventHandler.cs index 1d8934a..9443ae7 100644 --- a/src/Application/Features/TodoItems/EventHandlers/TodoItemCompletedEventHandler.cs +++ b/src/Application/Features/TodoItems/EventHandlers/TodoItemCompletedEventHandler.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using VerticalSliceArchitecture.Application.Common.Models; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Features.TodoItems.EventHandlers; diff --git a/src/Application/Features/TodoItems/GetTodoItemsWithPagination.cs b/src/Application/Features/TodoItems/GetTodoItemsWithPagination.cs index dbc3b2f..d7e7f83 100644 --- a/src/Application/Features/TodoItems/GetTodoItemsWithPagination.cs +++ b/src/Application/Features/TodoItems/GetTodoItemsWithPagination.cs @@ -10,7 +10,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Mappings; using VerticalSliceArchitecture.Application.Common.Models; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoItems; diff --git a/src/Application/Features/TodoItems/UpdateTodoItem.cs b/src/Application/Features/TodoItems/UpdateTodoItem.cs index 8436f73..35c9137 100644 --- a/src/Application/Features/TodoItems/UpdateTodoItem.cs +++ b/src/Application/Features/TodoItems/UpdateTodoItem.cs @@ -6,7 +6,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoItems; diff --git a/src/Application/Features/TodoItems/UpdateTodoItemDetail.cs b/src/Application/Features/TodoItems/UpdateTodoItemDetail.cs index a70e6b9..de9c077 100644 --- a/src/Application/Features/TodoItems/UpdateTodoItemDetail.cs +++ b/src/Application/Features/TodoItems/UpdateTodoItemDetail.cs @@ -4,7 +4,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoItems; diff --git a/src/Application/Features/TodoLists/CreateTodoList.cs b/src/Application/Features/TodoLists/CreateTodoList.cs index 0454370..45007c5 100644 --- a/src/Application/Features/TodoLists/CreateTodoList.cs +++ b/src/Application/Features/TodoLists/CreateTodoList.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; using VerticalSliceArchitecture.Application.Common; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoLists; diff --git a/src/Application/Features/TodoLists/DeleteTodoList.cs b/src/Application/Features/TodoLists/DeleteTodoList.cs index 4166fab..be22e2b 100644 --- a/src/Application/Features/TodoLists/DeleteTodoList.cs +++ b/src/Application/Features/TodoLists/DeleteTodoList.cs @@ -5,7 +5,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoLists; diff --git a/src/Application/Features/TodoLists/ExportTodos.cs b/src/Application/Features/TodoLists/ExportTodos.cs index 19c76cb..06ff53e 100644 --- a/src/Application/Features/TodoLists/ExportTodos.cs +++ b/src/Application/Features/TodoLists/ExportTodos.cs @@ -8,8 +8,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Interfaces; -using VerticalSliceArchitecture.Application.Common.Mappings; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoLists; @@ -74,10 +73,3 @@ public async Task Handle(ExportTodosQuery request, CancellationTo return vm; } } - -public class TodoItemRecord : IMapFrom -{ - public string? Title { get; set; } - - public bool Done { get; set; } -} diff --git a/src/Application/Features/TodoLists/GetTodos.cs b/src/Application/Features/TodoLists/GetTodos.cs index d765a4d..91d7ea8 100644 --- a/src/Application/Features/TodoLists/GetTodos.cs +++ b/src/Application/Features/TodoLists/GetTodos.cs @@ -8,7 +8,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Mappings; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoLists; diff --git a/src/Application/Features/TodoLists/UpdateTodoList.cs b/src/Application/Features/TodoLists/UpdateTodoList.cs index 32cd226..cc3ab1e 100644 --- a/src/Application/Features/TodoLists/UpdateTodoList.cs +++ b/src/Application/Features/TodoLists/UpdateTodoList.cs @@ -7,7 +7,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Persistence; namespace VerticalSliceArchitecture.Application.Features.TodoLists; diff --git a/src/Application/Infrastructure/Files/CsvFileBuilder.cs b/src/Application/Infrastructure/Files/CsvFileBuilder.cs index fb49aa9..68492a8 100644 --- a/src/Application/Infrastructure/Files/CsvFileBuilder.cs +++ b/src/Application/Infrastructure/Files/CsvFileBuilder.cs @@ -3,7 +3,7 @@ using CsvHelper; using VerticalSliceArchitecture.Application.Common.Interfaces; -using VerticalSliceArchitecture.Application.Features.TodoLists; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Infrastructure.Files.Maps; namespace VerticalSliceArchitecture.Application.Infrastructure.Files; diff --git a/src/Application/Infrastructure/Files/Maps/TodoItemRecordMap.cs b/src/Application/Infrastructure/Files/Maps/TodoItemRecordMap.cs index e7217f6..4f005d7 100644 --- a/src/Application/Infrastructure/Files/Maps/TodoItemRecordMap.cs +++ b/src/Application/Infrastructure/Files/Maps/TodoItemRecordMap.cs @@ -2,7 +2,7 @@ using CsvHelper.Configuration; -using VerticalSliceArchitecture.Application.Features.TodoLists; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Infrastructure.Files.Maps; diff --git a/src/Application/Infrastructure/Persistence/ApplicationDbContext.cs b/src/Application/Infrastructure/Persistence/ApplicationDbContext.cs index a4e58e1..8935ce9 100644 --- a/src/Application/Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/Application/Infrastructure/Persistence/ApplicationDbContext.cs @@ -5,7 +5,7 @@ using VerticalSliceArchitecture.Application.Common; using VerticalSliceArchitecture.Application.Common.Interfaces; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Infrastructure.Persistence; diff --git a/src/Application/Infrastructure/Persistence/ApplicationDbContextSeed.cs b/src/Application/Infrastructure/Persistence/ApplicationDbContextSeed.cs index b6d6663..3c80b50 100644 --- a/src/Application/Infrastructure/Persistence/ApplicationDbContextSeed.cs +++ b/src/Application/Infrastructure/Persistence/ApplicationDbContextSeed.cs @@ -1,5 +1,5 @@ -using VerticalSliceArchitecture.Application.Entities; -using VerticalSliceArchitecture.Application.ValueObjects; +using VerticalSliceArchitecture.Application.Domain.Todos; +using VerticalSliceArchitecture.Application.Domain.ValueObjects; namespace VerticalSliceArchitecture.Application.Infrastructure.Persistence; diff --git a/src/Application/Infrastructure/Persistence/Configurations/TodoItemConfiguration.cs b/src/Application/Infrastructure/Persistence/Configurations/TodoItemConfiguration.cs index db2378a..7c4d8c6 100644 --- a/src/Application/Infrastructure/Persistence/Configurations/TodoItemConfiguration.cs +++ b/src/Application/Infrastructure/Persistence/Configurations/TodoItemConfiguration.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Infrastructure.Persistence.Configurations; diff --git a/src/Application/Infrastructure/Persistence/Configurations/TodoListConfiguration.cs b/src/Application/Infrastructure/Persistence/Configurations/TodoListConfiguration.cs index 56d9cf3..f1bde0b 100644 --- a/src/Application/Infrastructure/Persistence/Configurations/TodoListConfiguration.cs +++ b/src/Application/Infrastructure/Persistence/Configurations/TodoListConfiguration.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; namespace VerticalSliceArchitecture.Application.Infrastructure.Persistence.Configurations; diff --git a/tests/Application.UnitTests/Common/Mappings/MappingTests.cs b/tests/Application.UnitTests/Common/Mappings/MappingTests.cs index 622841a..6fff75f 100644 --- a/tests/Application.UnitTests/Common/Mappings/MappingTests.cs +++ b/tests/Application.UnitTests/Common/Mappings/MappingTests.cs @@ -2,7 +2,7 @@ using AutoMapper; using VerticalSliceArchitecture.Application.Common.Mappings; using NUnit.Framework; -using VerticalSliceArchitecture.Application.Entities; +using VerticalSliceArchitecture.Application.Domain.Todos; using VerticalSliceArchitecture.Application.Features.TodoLists; namespace VerticalSliceArchitecture.Application.UnitTests.Common.Mappings; @@ -14,7 +14,7 @@ public class MappingTests public MappingTests() { - _configuration = new MapperConfiguration(config => + _configuration = new MapperConfiguration(config => config.AddProfile()); _mapper = _configuration.CreateMapper(); diff --git a/tests/Application.UnitTests/ValueObjects/ColourTests.cs b/tests/Application.UnitTests/ValueObjects/ColourTests.cs index 3be33fe..c6b1407 100644 --- a/tests/Application.UnitTests/ValueObjects/ColourTests.cs +++ b/tests/Application.UnitTests/ValueObjects/ColourTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using VerticalSliceArchitecture.Application.Common.Exceptions; -using VerticalSliceArchitecture.Application.ValueObjects; +using VerticalSliceArchitecture.Application.Domain.ValueObjects; namespace VerticalSliceArchitecture.Application.UnitTests.ValueObjects;