Refactor project structure to clean architecture model.

This commit is contained in:
Denis-Cosmin Nutiu 2021-06-21 17:46:44 +03:00
parent 169fed57a9
commit cd72710d24
32 changed files with 104 additions and 49 deletions

View file

@ -1,7 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Retroactiune.DataAnnotations
namespace Retroactiune.Core.DataAnnotations
{
public class DatetimeNotInThePast : ValidationAttribute
{

View file

@ -1,4 +1,4 @@
namespace Retroactiune.Models
namespace Retroactiune.Core.Entities
{
public class Feedback
{

View file

@ -3,7 +3,7 @@ using System.Text.Json.Serialization;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace Retroactiune.Models
namespace Retroactiune.Core.Entities
{
/// <summary>
/// FeedbackReceiver is the entity that receives feedback from the users.

View file

@ -3,11 +3,11 @@ using System.Text.Json.Serialization;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace Retroactiune.Models
namespace Retroactiune.Core.Entities
{
/// <summary>
/// Token represents a token.
/// Token is used to authorize a <see cref="Feedback"/> for the <see cref="FeedbackReceiver"/>.
/// Token is used to authorize a <see cref="FeedbackReceiver"/> for the <see cref="Feedback"/>.
/// </summary>
public class Token
{

View file

@ -1,4 +1,4 @@
namespace Retroactiune.Database
namespace Retroactiune.Core.Interfaces
{
/// <summary>
/// Interface for repressing the application's database settings.

View file

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Retroactiune.Models;
using Retroactiune.Core.Entities;
namespace Retroactiune.Services
namespace Retroactiune.Core.Interfaces
{
public interface IFeedbackReceiverService
{

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Retroactiune.Services
namespace Retroactiune.Core.Interfaces
{
public interface ITokensService
{

View file

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.12.3" />
</ItemGroup>
</Project>

View file

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MongoDB.Driver;
using Retroactiune.Database;
using Retroactiune.Models;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
namespace Retroactiune.Services
namespace Retroactiune.Core.Services
{
/// <summary>
/// Service that simplifies access to the database for managing FeedbackReceiver items.

View file

@ -1,6 +1,6 @@
using System;
namespace Retroactiune.Services
namespace Retroactiune.Core.Services
{
public class GenericServiceException : Exception
{

View file

@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
using Retroactiune.Database;
using Retroactiune.Models;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
namespace Retroactiune.Services
namespace Retroactiune.Core.Services
{
public class TokensService : ITokensService
{

View file

@ -1,4 +1,6 @@
namespace Retroactiune.Database
using Retroactiune.Core.Interfaces;
namespace Retroactiune.Infrastructure
{
/// <summary>
/// DatabaseSettingsOptions acts as a model for the database settings, it is used in conjunction with the built in

View file

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Retroactiune.Core\Retroactiune.Core.csproj" />
</ItemGroup>
</Project>

View file

@ -14,10 +14,10 @@ using Microsoft.Extensions.Options;
using MongoDB.Bson;
using MongoDB.Driver;
using Newtonsoft.Json;
using Retroactiune.Database;
using Retroactiune.Core.Entities;
using Retroactiune.DataTransferObjects;
using Retroactiune.Infrastructure;
using Retroactiune.IntegrationTests.Retroactiune.WebAPI.Fixtures;
using Retroactiune.Models;
using Xunit;
using JsonSerializer = System.Text.Json.JsonSerializer;

View file

@ -12,9 +12,9 @@ using Microsoft.Extensions.Options;
using MongoDB.Bson;
using MongoDB.Driver;
using Newtonsoft.Json;
using Retroactiune.Database;
using Retroactiune.Core.Entities;
using Retroactiune.Infrastructure;
using Retroactiune.IntegrationTests.Retroactiune.WebAPI.Fixtures;
using Retroactiune.Models;
using Xunit;
namespace Retroactiune.IntegrationTests.Retroactiune.WebAPI.Controllers

View file

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Retroactiune.Database;
using Retroactiune.Models;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.Infrastructure;
namespace Retroactiune.IntegrationTests.Retroactiune.WebAPI.Fixtures
{

View file

@ -1,8 +1,8 @@
using System;
using Retroactiune.DataAnnotations;
using Retroactiune.Core.DataAnnotations;
using Xunit;
namespace Retroactiune.Tests.Retroactiune.WebAPI.DataAnnotations
namespace Retroactiune.Tests.Retroactiune.Core.DataAnnotations
{
public class TestDatetimeNotInThePast
{

View file

@ -5,12 +5,12 @@ using System.Threading.Tasks;
using AutoFixture.Xunit2;
using MongoDB.Driver;
using Moq;
using Retroactiune.Database;
using Retroactiune.Models;
using Retroactiune.Services;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Xunit;
namespace Retroactiune.Tests.Retroactiune.WebAPI.Services
namespace Retroactiune.Tests.Retroactiune.Core.Services
{
public class TestFeedbackReceiverService
{

View file

@ -3,12 +3,12 @@ using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using Moq;
using Retroactiune.Database;
using Retroactiune.Models;
using Retroactiune.Services;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Xunit;
namespace Retroactiune.Tests.Retroactiune.WebAPI.Services
namespace Retroactiune.Tests.Retroactiune.Core.Services
{
public class TestTokensService
{

View file

@ -20,7 +20,12 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Retroactiune.Core\Retroactiune.Core.csproj" />
<ProjectReference Include="..\Retroactiune.WebAPI\Retroactiune.WebAPI.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Retroactiune.Core" />
</ItemGroup>
</Project>

View file

@ -5,9 +5,9 @@ using AutoFixture.Xunit2;
using Microsoft.AspNetCore.Mvc;
using Moq;
using Retroactiune.Controllers;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.DataTransferObjects;
using Retroactiune.Models;
using Retroactiune.Services;
using Xunit;
namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers

View file

@ -4,9 +4,10 @@ using AutoFixture.Xunit2;
using Microsoft.AspNetCore.Mvc;
using Moq;
using Retroactiune.Controllers;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Retroactiune.DataTransferObjects;
using Retroactiune.Models;
using Retroactiune.Services;
using Xunit;
namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers

View file

@ -7,9 +7,10 @@ using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Retroactiune.Core.Entities;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Retroactiune.DataTransferObjects;
using Retroactiune.Models;
using Retroactiune.Services;
namespace Retroactiune.Controllers
{

View file

@ -4,8 +4,9 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Retroactiune.DataTransferObjects;
using Retroactiune.Services;
namespace Retroactiune.Controllers
{
@ -13,7 +14,10 @@ namespace Retroactiune.Controllers
[Route("api/v1/[controller]")]
public class TokensController : ControllerBase
{
// TODO: list tokens (unused, used)
// TODO: Implement ListTokens.
// Filters for: FeedbackReceiver IDS
// for: start < CreatedTime < end
// for start < TimeUsed end
private readonly IFeedbackReceiverService _feedbackReceiverService;
private readonly ITokensService _tokensService;

View file

@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Retroactiune.Models;
using Retroactiune.Core.Entities;
namespace Retroactiune.DataTransferObjects
{

View file

@ -1,4 +1,4 @@
using Retroactiune.Models;
using Retroactiune.Core.Entities;
namespace Retroactiune.DataTransferObjects
{

View file

@ -1,6 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using Retroactiune.DataAnnotations;
using Retroactiune.Core.DataAnnotations;
namespace Retroactiune.DataTransferObjects
{

View file

@ -1,6 +1,6 @@
using AutoMapper;
using Retroactiune.Core.Entities;
using Retroactiune.DataTransferObjects;
using Retroactiune.Models;
namespace Retroactiune
{

View file

@ -14,5 +14,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Retroactiune.Core\Retroactiune.Core.csproj" />
<ProjectReference Include="..\Retroactiune.Infrastructure\Retroactiune.Infrastructure.csproj" />
</ItemGroup>
</Project>

View file

@ -9,8 +9,9 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Retroactiune.Database;
using Retroactiune.Services;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Retroactiune.Infrastructure;
namespace Retroactiune
{

View file

@ -4,8 +4,9 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Retroactiune.Database;
using Retroactiune.Services;
using Retroactiune.Core.Interfaces;
using Retroactiune.Core.Services;
using Retroactiune.Infrastructure;
namespace Retroactiune
{

View file

@ -6,6 +6,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.UnitTests", "R
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.IntegrationTests", "Retroactiune.IntegrationTests\Retroactiune.IntegrationTests.csproj", "{0A585C42-6DA1-4CB8-95AC-C0E4BE49C14C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.Core", "Retroactiune.Core\Retroactiune.Core.csproj", "{8AAE50F4-5020-4F8F-94D9-C6DF7EA34AAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.Infrastructure", "Retroactiune.Infrastructure\Retroactiune.Infrastructure.csproj", "{F5F226DC-92BC-4825-9480-0DB6C88E51A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -24,5 +28,13 @@ Global
{0A585C42-6DA1-4CB8-95AC-C0E4BE49C14C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A585C42-6DA1-4CB8-95AC-C0E4BE49C14C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A585C42-6DA1-4CB8-95AC-C0E4BE49C14C}.Release|Any CPU.Build.0 = Release|Any CPU
{8AAE50F4-5020-4F8F-94D9-C6DF7EA34AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AAE50F4-5020-4F8F-94D9-C6DF7EA34AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AAE50F4-5020-4F8F-94D9-C6DF7EA34AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AAE50F4-5020-4F8F-94D9-C6DF7EA34AAC}.Release|Any CPU.Build.0 = Release|Any CPU
{F5F226DC-92BC-4825-9480-0DB6C88E51A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5F226DC-92BC-4825-9480-0DB6C88E51A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5F226DC-92BC-4825-9480-0DB6C88E51A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5F226DC-92BC-4825-9480-0DB6C88E51A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal