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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 438 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions CleanArchitecture.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CleanArchitecture", "CleanArchitecture", "{A4BCB43D-8D6A-4978-A2F7-D7D7EB520575}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{10EE58A6-F3CC-4648-9413-3AE2C4BBE0B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArchitecture.Domain", "CleanArchitecture\Core\CleanArchitecture.Domain\CleanArchitecture.Domain.csproj", "{E8827D07-D9B4-44EF-95D8-170BB231B549}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArchitecture.Aplication", "CleanArchitecture\Core\CleanArchitecture.Aplication\CleanArchitecture.Aplication.csproj", "{766F5657-CC7E-497B-8FBF-9BAD0D39762D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{2EDDD49C-B01C-4005-BD6C-972F57D0C264}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArchitecture.Persistence", "CleanArchitecture\Infrastructure\CleanArchitecture.Persistence\CleanArchitecture.Persistence.csproj", "{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{CB63D658-3245-440D-9860-E735BDE9BEF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArchitecture.API", "CleanArchitecture\Presentation\CleanArchitecture.API\CleanArchitecture.API.csproj", "{69ECBB8F-80BB-4862-9357-51A35C2D363E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{3584D67B-E7B8-4D97-8167-3398D05923FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArchitecture.Tests", "CleanArchitecture\Test\CleanArchitecture.Tests\CleanArchitecture.Tests.csproj", "{9AF52972-03E5-4F6F-A084-D88CE42C47DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8827D07-D9B4-44EF-95D8-170BB231B549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8827D07-D9B4-44EF-95D8-170BB231B549}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8827D07-D9B4-44EF-95D8-170BB231B549}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8827D07-D9B4-44EF-95D8-170BB231B549}.Release|Any CPU.Build.0 = Release|Any CPU
{766F5657-CC7E-497B-8FBF-9BAD0D39762D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{766F5657-CC7E-497B-8FBF-9BAD0D39762D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{766F5657-CC7E-497B-8FBF-9BAD0D39762D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{766F5657-CC7E-497B-8FBF-9BAD0D39762D}.Release|Any CPU.Build.0 = Release|Any CPU
{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31}.Release|Any CPU.Build.0 = Release|Any CPU
{69ECBB8F-80BB-4862-9357-51A35C2D363E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69ECBB8F-80BB-4862-9357-51A35C2D363E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69ECBB8F-80BB-4862-9357-51A35C2D363E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69ECBB8F-80BB-4862-9357-51A35C2D363E}.Release|Any CPU.Build.0 = Release|Any CPU
{9AF52972-03E5-4F6F-A084-D88CE42C47DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AF52972-03E5-4F6F-A084-D88CE42C47DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AF52972-03E5-4F6F-A084-D88CE42C47DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AF52972-03E5-4F6F-A084-D88CE42C47DE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{10EE58A6-F3CC-4648-9413-3AE2C4BBE0B6} = {A4BCB43D-8D6A-4978-A2F7-D7D7EB520575}
{E8827D07-D9B4-44EF-95D8-170BB231B549} = {10EE58A6-F3CC-4648-9413-3AE2C4BBE0B6}
{766F5657-CC7E-497B-8FBF-9BAD0D39762D} = {10EE58A6-F3CC-4648-9413-3AE2C4BBE0B6}
{2EDDD49C-B01C-4005-BD6C-972F57D0C264} = {A4BCB43D-8D6A-4978-A2F7-D7D7EB520575}
{38D17CA3-EC03-4F3C-8CB5-FF7CBD348A31} = {2EDDD49C-B01C-4005-BD6C-972F57D0C264}
{CB63D658-3245-440D-9860-E735BDE9BEF9} = {A4BCB43D-8D6A-4978-A2F7-D7D7EB520575}
{69ECBB8F-80BB-4862-9357-51A35C2D363E} = {CB63D658-3245-440D-9860-E735BDE9BEF9}
{3584D67B-E7B8-4D97-8167-3398D05923FD} = {A4BCB43D-8D6A-4978-A2F7-D7D7EB520575}
{9AF52972-03E5-4F6F-A084-D88CE42C47DE} = {3584D67B-E7B8-4D97-8167-3398D05923FD}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace CleanArchitecture.Domain.Entities;
public abstract class BaseEntity {
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateUpdated { get; set; }
public DateTimeOffset? DateDeleted { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace CleanArchitecture.Domain.Entities;

public sealed class User : BaseEntity
{
public string? Email { get; set; }
public string? Name { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CleanArchitecture.Domain.Entities;

namespace CleanArchitecture.Domain.Interfaces;

public interface IBaseRepository<T> where T : BaseEntity
{
void Create(T entity);
void Update(T entity);
void Delete(T entity);
Task<T> Get(Guid id, CancellationToken cancellationToken);
Task<List<T>> GetAll(CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CleanArchitecture.Domain.Interfaces;

public interface IUnitOfWork
{
Task Commit(CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CleanArchitecture.Domain.Entities;

namespace CleanArchitecture.Domain.Interfaces;

public interface IUserRepository : IBaseRepository<User>
{
Task<User> GetByEmail(string email, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.14" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;

namespace CleanArchitecture.API.Controllers;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
25 changes: 25 additions & 0 deletions CleanArchitecture/Presentation/CleanArchitecture.API/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:11167",
"sslPort": 44392
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7067;http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CleanArchitecture.API;

public class WeatherForecast
{
public DateOnly Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions CleanArchitecture/Test/CleanArchitecture.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CleanArchitecture.Tests;

public class UnitTest1
{
[Fact]
public void Test1()
{

}
}
1 change: 1 addition & 0 deletions CleanArchitecture/Test/CleanArchitecture.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;