├── CleanArchitectureDemo.Application
├── CleanArchitectureDemo.Application.csproj
├── Common
│ ├── Exceptions
│ │ ├── ApplicationException.cs
│ │ ├── BadRequestException.cs
│ │ └── NotFoundException.cs
│ └── Mappings
│ │ ├── IMapFrom.cs
│ │ └── MappingProfile.cs
├── DTOs
│ └── Email
│ │ └── EmailRequestDto.cs
├── Extensions
│ ├── IServiceCollectionExtensions.cs
│ └── QueryableExtensions.cs
├── Features
│ └── Players
│ │ ├── Commands
│ │ ├── CreatePlayer
│ │ │ ├── CreatePlayerCommand.cs
│ │ │ └── PlayerCreatedEvent.cs
│ │ ├── DeletePlayer
│ │ │ ├── DeletePlayerCommand.cs
│ │ │ └── PlayerDeletedEvent.cs
│ │ └── UpdatePlayer
│ │ │ ├── PlayerUpdatedEvent.cs
│ │ │ └── UpdatePlayerCommand.cs
│ │ └── Queries
│ │ ├── GetAllPlayers
│ │ ├── GetAllPlayersDto.cs
│ │ └── GetAllPlayersQuery.cs
│ │ ├── GetPlayerById
│ │ ├── GetPlayerByIdDto.cs
│ │ └── GetPlayerByIdQuery.cs
│ │ ├── GetPlayersByClub
│ │ ├── GetPlayersByClubDto.cs
│ │ └── GetPlayersByClubQuery.cs
│ │ └── GetPlayersWithPagination
│ │ ├── GetPlayersWithPaginationDto.cs
│ │ ├── GetPlayersWithPaginationQuery.cs
│ │ └── GetPlayersWithPaginationValidator.cs
└── Interfaces
│ ├── IDateTimeService.cs
│ ├── IEmailService.cs
│ └── Repositories
│ ├── IClubRepository.cs
│ ├── ICountryRepository.cs
│ ├── IGenericRepository.cs
│ ├── IPlayerRepository.cs
│ ├── IStadiumRepository.cs
│ └── IUnitOfWork.cs
├── CleanArchitectureDemo.Domain
├── CleanArchitectureDemo.Domain.csproj
├── Common
│ ├── BaseAuditableEntity.cs
│ ├── BaseEntity.cs
│ ├── BaseEvent.cs
│ ├── DomainEventDispatcher.cs
│ ├── Interfaces
│ │ ├── IAuditableEntity.cs
│ │ ├── IDomainEventDispatcher.cs
│ │ └── IEntity.cs
│ └── ValueObject.cs
└── Entities
│ ├── Club.cs
│ ├── Country.cs
│ ├── Player.cs
│ └── Stadium.cs
├── CleanArchitectureDemo.Infrastructure
├── CleanArchitectureDemo.Infrastructure.csproj
├── Extensions
│ └── IServiceCollectionExtensions.cs
└── Services
│ ├── DateTimeService.cs
│ └── EmailService.cs
├── CleanArchitectureDemo.Persistence
├── CleanArchitectureDemo.Persistence.csproj
├── Contexts
│ └── ApplicationDbContext.cs
├── Extensions
│ └── IServiceCollectionExtensions.cs
└── Repositories
│ ├── ClubRepository.cs
│ ├── CountryRepository.cs
│ ├── GenericRepository.cs
│ ├── PlayerRepository.cs
│ ├── StadiumRepository.cs
│ └── UnitOfWork.cs
├── CleanArchitectureDemo.Shared
├── CleanArchitectureDemo.Shared.csproj
├── Interfaces
│ └── IResult.cs
├── PaginatedResult.cs
└── Result.cs
├── CleanArchitectureDemo.WebAPI
├── CleanArchitectureDemo.WebAPI.csproj
├── Controllers
│ ├── ApiControllerBase.cs
│ └── PlayersController.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
├── appsettings.Development.json
└── appsettings.json
├── CleanArchitectureDemo.sln
└── README.md
/CleanArchitectureDemo.Application/CleanArchitectureDemo.Application.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | disable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/CleanArchitectureDemo.Application/Common/Exceptions/ApplicationException.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace CleanArchitectureDemo.Application.Common.Exceptions
4 | {
5 | public class ApplicationException : Exception
6 | {
7 | public ApplicationException()
8 | : base()
9 | {
10 | }
11 |
12 | public ApplicationException(string message)
13 | : base(message)
14 | {
15 | }
16 |
17 | public ApplicationException(string message, Exception innerException)
18 | : base(message, innerException)
19 | {
20 | }
21 |
22 | public ApplicationException(string message, params object[] args)
23 | : base(string.Format(CultureInfo.CurrentCulture, message, args))
24 | {
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/CleanArchitectureDemo.Application/Common/Exceptions/BadRequestException.cs:
--------------------------------------------------------------------------------
1 | namespace CleanArchitectureDemo.Application.Common.Exceptions
2 | {
3 | public class BadRequestException : Exception
4 | {
5 | public string[] Errors { get; set; }
6 |
7 | public BadRequestException()
8 | : base()
9 | {
10 | }
11 |
12 | public BadRequestException(string message)
13 | : base(message)
14 | {
15 | }
16 |
17 | public BadRequestException(string message, Exception innerException)
18 | : base(message, innerException)
19 | {
20 | }
21 |
22 | public BadRequestException(string[] errors) : base("Multiple errors occurred. See error details.")
23 | {
24 | Errors = errors;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/CleanArchitectureDemo.Application/Common/Exceptions/NotFoundException.cs:
--------------------------------------------------------------------------------
1 | namespace CleanArchitectureDemo.Application.Common.Exceptions
2 | {
3 | public class NotFoundException : Exception
4 | {
5 | public NotFoundException()
6 | : base()
7 | {
8 | }
9 |
10 | public NotFoundException(string message)
11 | : base(message)
12 | {
13 | }
14 |
15 | public NotFoundException(string message, Exception innerException)
16 | : base(message, innerException)
17 | {
18 | }
19 |
20 | public NotFoundException(string name, object key)
21 | : base($"Entity \"{name}\" ({key}) was not found.")
22 | {
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CleanArchitectureDemo.Application/Common/Mappings/IMapFrom.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace CleanArchitectureDemo.Application.Common.Mappings
4 | {
5 | public interface IMapFrom
6 | {
7 | void Mapping(Profile profile) => profile.CreateMap(typeof(T), GetType());
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/CleanArchitectureDemo.Application/Common/Mappings/MappingProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | using System.Reflection;
4 |
5 | namespace CleanArchitectureDemo.Application.Common.Mappings
6 | {
7 | public class MappingProfile : Profile
8 | {
9 | public MappingProfile()
10 | {
11 | ApplyMappingsFromAssembly(Assembly.GetExecutingAssembly());
12 | }
13 |
14 | private void ApplyMappingsFromAssembly(Assembly assembly)
15 | {
16 | var mapFromType = typeof(IMapFrom<>);
17 |
18 | var mappingMethodName = nameof(IMapFrom