Reset pour intégrer les bonnes practices
This commit is contained in:
parent
8be1a8db92
commit
b60c57e19c
6
LiberIncantamentum.API/LiberIncantamentum.API.http
Normal file
6
LiberIncantamentum.API/LiberIncantamentum.API.http
Normal file
@ -0,0 +1,6 @@
|
||||
@LiberIncantamentum.API_HostAddress = http://localhost:5196
|
||||
|
||||
GET {{LiberIncantamentum.API_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
17
LiberIncantamentum.API/Liber_Incantamentum.API.csproj
Normal file
17
LiberIncantamentum.API/Liber_Incantamentum.API.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,9 +1,3 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.Services.Mappings;
|
||||
using Liber_Incantamentum.Application.Services.Validations;
|
||||
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@ -12,10 +6,6 @@ builder.Services.AddControllers();
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddValidatorsFromAssemblyContaining<MageDtoCreateValidator>();
|
||||
|
||||
builder.Services.AddAutoMapper(cfg => { }, typeof(MageMappingProfile).Assembly);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@ -5,7 +5,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5225",
|
||||
"applicationUrl": "http://localhost:5196",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
@ -14,7 +14,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7239;http://localhost:5225",
|
||||
"applicationUrl": "https://localhost:7236;http://localhost:5196",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,13 +0,0 @@
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.DTOs.Mage
|
||||
{
|
||||
public class MageDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string Rank { get; set; }
|
||||
public required string Specialisation { get; set; }
|
||||
public ICollection<SpellDto> Spells { get; set; } = new List<SpellDto>();
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Mage
|
||||
{
|
||||
public class MageDtoCreate
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public required string Rank { get; set; }
|
||||
public required string Specialisation { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Mage
|
||||
{
|
||||
public class MageDtoFilter
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Rank { get; set; }
|
||||
public string? Specialisation { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.DTOs.Mage
|
||||
{
|
||||
public class MageDtoUpdate
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string Rank { get; set; }
|
||||
public required string Specialisation { get; set; }
|
||||
public ICollection<SpellDto> Spells { get; set; } = new List<SpellDto>();
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Spell
|
||||
{
|
||||
public class SpellDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string Description { get; set; }
|
||||
public required string Type { get; set; }
|
||||
public required DateTime CreationDate { get; set; }
|
||||
public Guid MageId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Spell
|
||||
{
|
||||
public class SpellDtoCreate
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public required string Description { get; set; }
|
||||
public required string Type { get; set; }
|
||||
public required DateTime CreationDate { get; set; }
|
||||
public Guid MageId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Spell
|
||||
{
|
||||
public class SpellDtoFilter
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public DateTime? CreationDate { get; set; }
|
||||
public Guid? MageId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.DTOs.Spell
|
||||
{
|
||||
public class SpellDtoUpdate
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string Description { get; set; }
|
||||
public required string Type { get; set; }
|
||||
public required DateTime CreationDate { get; set; }
|
||||
public Guid MageId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.Exceptions
|
||||
{
|
||||
public class AlreadyExistingException : Exception
|
||||
{
|
||||
public AlreadyExistingException() { }
|
||||
public AlreadyExistingException(string message) : base(message) { }
|
||||
public AlreadyExistingException(string? message, Exception? innerException) : base(message, innerException) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.Exceptions
|
||||
{
|
||||
public class ConflictException : Exception
|
||||
{
|
||||
public ConflictException() { }
|
||||
public ConflictException(string message) : base(message) { }
|
||||
public ConflictException(string? message, Exception? innerException) : base(message, innerException) { }
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
namespace Liber_Incantamentum.Application.Exceptions
|
||||
{
|
||||
public class NotFoundException : Exception
|
||||
{
|
||||
public NotFoundException() { }
|
||||
public NotFoundException(string message) : base(message) { }
|
||||
public NotFoundException(string? message, Exception? innerException) : base(message, innerException) { }
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Interfaces
|
||||
{
|
||||
public interface IMageService
|
||||
{
|
||||
Task<ICollection<MageDto>> GetAllMagesAsync(MageDtoFilter filter);
|
||||
Task<bool> UpdateMageAsync(MageDtoUpdate dto, Guid id);
|
||||
Task<bool> DeleteMageAsync(Guid id);
|
||||
Task<bool> AddMageAsync(MageDtoCreate dto);
|
||||
Task<MageDto>? GetMageByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Interfaces
|
||||
{
|
||||
public interface ISpellService
|
||||
{
|
||||
Task<ICollection<SpellDto>> GetAllSpellsAsync(SpellDtoFilter filter);
|
||||
Task<bool> UpdateSpellAsync(SpellDtoUpdate dto, Guid id);
|
||||
Task<bool> DeleteSpellAsync(Guid id);
|
||||
Task<bool> AddSpellAsync(SpellDtoCreate dto);
|
||||
Task<SpellDto>? GetSpellByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Liber_Incantamentum.Domain\Liber_Incantamentum.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="15.0.1" />
|
||||
<PackageReference Include="FluentValidation" Version="12.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,84 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
using Liber_Incantamentum.Application.Exceptions;
|
||||
using Liber_Incantamentum.Application.Interfaces;
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
using Liber_Incantamentum.Domain.Repositories;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Generals
|
||||
{
|
||||
public class MageService : IMageService
|
||||
{
|
||||
private readonly IMageRepository _mageRepository;
|
||||
private readonly IMapper _mapper;
|
||||
public MageService(IMageRepository mageRepository, IMapper mapper)
|
||||
{
|
||||
_mageRepository = mageRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<bool> AddMageAsync(MageDtoCreate dto)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
throw new ArgumentNullException("The DTO received is null");
|
||||
}
|
||||
var alreadyExistingMage = await GetAllMagesAsync(new MageDtoFilter { Name = dto.Name, Rank = dto.Rank, Specialisation = dto.Specialisation });
|
||||
if (alreadyExistingMage.Any())
|
||||
{
|
||||
throw new AlreadyExistingException("This mage does already exists");
|
||||
}
|
||||
return await _mageRepository.AddMageAsync(_mapper.Map<Mage>(dto));
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteMageAsync(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("The id is null");
|
||||
}
|
||||
var alreadyExistingMage = await GetAllMagesAsync(new MageDtoFilter { Id = id });
|
||||
if (!alreadyExistingMage.Any())
|
||||
{
|
||||
throw new NotFoundException("This mage does not exists");
|
||||
}
|
||||
return await _mageRepository.DeleteMageAsync(id);
|
||||
}
|
||||
|
||||
public async Task<ICollection<MageDto>> GetAllMagesAsync(MageDtoFilter filter)
|
||||
{
|
||||
var entities = await _mageRepository.GetAllMagesAsync(_mapper.Map<MageFilter>(filter));
|
||||
return _mapper.Map<ICollection<MageDto>>(entities);
|
||||
}
|
||||
|
||||
public async Task<MageDto>? GetMageByIdAsync(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("The id is null");
|
||||
}
|
||||
var alreadyExistingMage = await GetAllMagesAsync(new MageDtoFilter { Id = id });
|
||||
if (!alreadyExistingMage.Any())
|
||||
{
|
||||
throw new NotFoundException("This mage does not exists");
|
||||
}
|
||||
var mage = await _mageRepository.GetMageByIdAsync(id);
|
||||
return _mapper.Map<MageDto>(mage);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateMageAsync(MageDtoUpdate dto, Guid id)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
throw new ArgumentNullException("The DTO received is null");
|
||||
}
|
||||
var alreadyExistingMage = await GetMageByIdAsync(id);
|
||||
if (alreadyExistingMage == null)
|
||||
{
|
||||
throw new NotFoundException("This mage does not exists");
|
||||
}
|
||||
return await _mageRepository.UpdateMageAsync(_mapper.Map<Mage>(dto));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
using Liber_Incantamentum.Application.Exceptions;
|
||||
using Liber_Incantamentum.Application.Interfaces;
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
using Liber_Incantamentum.Domain.Repositories;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Generals
|
||||
{
|
||||
public class SpellService : ISpellService
|
||||
{
|
||||
private readonly ISpellRepository _spellRepository;
|
||||
private readonly IMapper _mapper;
|
||||
public SpellService(ISpellRepository spellRepository, IMapper mapper)
|
||||
{
|
||||
_spellRepository = spellRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
public async Task<bool> AddSpellAsync(SpellDtoCreate dto)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
throw new ArgumentNullException("The DTO received is null");
|
||||
}
|
||||
var alreadyExistingSpell = await GetAllSpellsAsync(new SpellDtoFilter { Name = dto.Name, Description = dto.Description, Type = dto.Type, CreationDate = dto.CreationDate, MageId = dto.MageId });
|
||||
if (alreadyExistingSpell.Any())
|
||||
{
|
||||
throw new AlreadyExistingException("This spell does already exists");
|
||||
}
|
||||
return await _spellRepository.AddSpellAsync(_mapper.Map<Spell>(dto));
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteSpellAsync(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("The id is null");
|
||||
}
|
||||
var alreadyExistingSpell = await GetAllSpellsAsync(new SpellDtoFilter { Id = id });
|
||||
if (!alreadyExistingSpell.Any())
|
||||
{
|
||||
throw new AlreadyExistingException("This spell does not exists");
|
||||
}
|
||||
return await _spellRepository.DeleteSpellAsync(id);
|
||||
}
|
||||
|
||||
public async Task<ICollection<SpellDto>> GetAllSpellsAsync(SpellDtoFilter filter)
|
||||
{
|
||||
var entities = await _spellRepository.GetAllSpellsAsync(_mapper.Map<SpellFilter>(filter));
|
||||
return _mapper.Map<ICollection<SpellDto>>(entities);
|
||||
}
|
||||
|
||||
public async Task<SpellDto>? GetSpellByIdAsync(Guid id)
|
||||
{
|
||||
if (id == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("The id is null");
|
||||
}
|
||||
var alreadyExistingMage = await GetAllSpellsAsync(new SpellDtoFilter { Id = id });
|
||||
if (!alreadyExistingMage.Any())
|
||||
{
|
||||
throw new NotFoundException("This spell does not exists");
|
||||
}
|
||||
var mage = await _spellRepository.GetSpellByIdAsync(id);
|
||||
return _mapper.Map<SpellDto>(mage);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateSpellAsync(SpellDtoUpdate dto, Guid i)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
throw new ArgumentNullException("The DTO received is null");
|
||||
}
|
||||
var alreadyExistingSpell = await GetAllSpellsAsync(new SpellDtoFilter { Id = dto.Id, Name = dto.Name, Description = dto.Description, Type = dto.Type, CreationDate = dto.CreationDate, MageId = dto.MageId });
|
||||
if (!alreadyExistingSpell.Any())
|
||||
{
|
||||
throw new NotFoundException("This spell does not exists");
|
||||
}
|
||||
return await _spellRepository.UpdateSpellAsync(_mapper.Map<Spell>(dto));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Mappings
|
||||
{
|
||||
public class MageMappingProfile : Profile
|
||||
{
|
||||
public MageMappingProfile()
|
||||
{
|
||||
CreateMap<MageDtoCreate, Mage>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Spells, opt => opt.Ignore())
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<MageDtoUpdate, Mage>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<MageDtoFilter, MageFilter>()
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<MageDto, Mage>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore())
|
||||
.ReverseMap();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Mappings
|
||||
{
|
||||
public class SpellMappingProfile : Profile
|
||||
{
|
||||
public SpellMappingProfile()
|
||||
{
|
||||
CreateMap<SpellDto, Spell>()
|
||||
.ForMember(x => x.Id, x => x.Ignore())
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<SpellDtoCreate, Spell>()
|
||||
.ForMember(x => x.Id, x => x.Ignore())
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<SpellDtoFilter, SpellFilter>()
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<SpellDtoUpdate, Spell>()
|
||||
.ForMember(x => x.Id, x => x.Ignore())
|
||||
.ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class MageDtoCreateValidator : AbstractValidator<MageDtoCreate>
|
||||
{
|
||||
public MageDtoCreateValidator()
|
||||
{
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The name is required");
|
||||
RuleFor(m => m.Rank)
|
||||
.NotEmpty().WithMessage("The Rank is required");
|
||||
RuleFor(m => m.Specialisation)
|
||||
.NotEmpty().WithMessage("The specialisation is required");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class MageDtoFilterValidator : AbstractValidator<MageDtoFilter>
|
||||
{
|
||||
public MageDtoFilterValidator()
|
||||
{
|
||||
When(m => m.Id.HasValue, () =>
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The id cannot be empty if provided");
|
||||
});
|
||||
When(m => !string.IsNullOrEmpty(m.Name), () =>
|
||||
{
|
||||
RuleFor(m => m.Name)
|
||||
.MinimumLength(2).WithMessage("Name must be at least 2 characters.");
|
||||
});
|
||||
When(m => !string.IsNullOrEmpty(m.Rank), () =>
|
||||
{
|
||||
RuleFor(m => m.Rank)
|
||||
.MinimumLength(2).WithMessage("Name must be at least 2 characters.");
|
||||
});
|
||||
When(m => !string.IsNullOrEmpty(m.Specialisation), () =>
|
||||
{
|
||||
RuleFor(m => m.Specialisation)
|
||||
.MinimumLength(2).WithMessage("Name must be at least 2 characters.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class MageDtoUpdateValidator : AbstractValidator<MageDtoUpdate>
|
||||
{
|
||||
public MageDtoUpdateValidator()
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The Id is required");
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The Name is required");
|
||||
RuleFor(m => m.Rank)
|
||||
.NotEmpty().WithMessage("The Rank is required");
|
||||
RuleFor(m => m.Specialisation)
|
||||
.NotEmpty().WithMessage("The Specialisation is required");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class MageDtoValidator : AbstractValidator<MageDto>
|
||||
{
|
||||
public MageDtoValidator()
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The Id is required");
|
||||
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The Name is required");
|
||||
|
||||
RuleFor(m => m.Rank)
|
||||
.NotEmpty().WithMessage("The Rank is required");
|
||||
|
||||
RuleFor(m => m.Specialisation)
|
||||
.NotEmpty().WithMessage("The Specialisation is required");
|
||||
|
||||
RuleFor(m => m.Spells)
|
||||
.NotNull().WithMessage("Spell collection is required")
|
||||
.NotEmpty().WithMessage("At least one spell is required");
|
||||
|
||||
RuleForEach(m => m.Spells)
|
||||
.SetValidator(new SpellDtoValidator());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class SpellDtoCreateValidator : AbstractValidator<SpellDtoCreate>
|
||||
{
|
||||
public SpellDtoCreateValidator()
|
||||
{
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The Name is required");
|
||||
RuleFor(m => m.Description)
|
||||
.NotEmpty().WithMessage("The description is required");
|
||||
RuleFor(m => m.Type)
|
||||
.NotEmpty().WithMessage("The type is required");
|
||||
RuleFor(m => m.CreationDate)
|
||||
.LessThanOrEqualTo(DateTime.UtcNow);
|
||||
RuleFor(m => m.MageId)
|
||||
.NotEmpty().WithMessage("The mage id is required");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class SpellDtoFilterValidator : AbstractValidator<SpellDtoFilter>
|
||||
{
|
||||
public SpellDtoFilterValidator()
|
||||
{
|
||||
When(m => m.Id.HasValue, () =>
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The id cannot be empty if provided");
|
||||
});
|
||||
When(m => !string.IsNullOrEmpty(m.Name), () =>
|
||||
{
|
||||
RuleFor(m => m.Name)
|
||||
.MinimumLength(2).WithMessage("Name must be at least 2 characters.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class SpellDtoUpdateValidator : AbstractValidator<SpellDtoUpdate>
|
||||
{
|
||||
public SpellDtoUpdateValidator()
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The Id cannot be empty");
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The Name cannot be empty");
|
||||
RuleFor(m => m.Description)
|
||||
.NotEmpty().WithMessage("The Description cannot be empty");
|
||||
RuleFor(m => m.Type)
|
||||
.NotEmpty().WithMessage("The Type cannot be empty");
|
||||
RuleFor(m => m.CreationDate)
|
||||
.LessThanOrEqualTo(DateTime.UtcNow);
|
||||
RuleFor(m => m.MageId)
|
||||
.NotEmpty().WithMessage("The mage id cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
using FluentValidation;
|
||||
using Liber_Incantamentum.Application.DTOs.Spell;
|
||||
|
||||
namespace Liber_Incantamentum.Application.Services.Validations
|
||||
{
|
||||
public class SpellDtoValidator : AbstractValidator<SpellDto>
|
||||
{
|
||||
public SpellDtoValidator()
|
||||
{
|
||||
RuleFor(m => m.Id)
|
||||
.NotEmpty().WithMessage("The Id cannot be empty");
|
||||
RuleFor(m => m.Name)
|
||||
.NotEmpty().WithMessage("The Name cannot be empty");
|
||||
RuleFor(m => m.Description)
|
||||
.NotEmpty().WithMessage("The Description cannot be empty");
|
||||
RuleFor(m => m.Type)
|
||||
.NotEmpty().WithMessage("The Type cannot be empty");
|
||||
RuleFor(m => m.CreationDate)
|
||||
.LessThanOrEqualTo(DateTime.UtcNow);
|
||||
RuleFor(m => m.MageId)
|
||||
.NotEmpty().WithMessage("The mage id cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
namespace Liber_Incantamentum.Domain.Entities
|
||||
{
|
||||
public class Mage
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public Mage()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
public required string Name { get; set; }
|
||||
public required string Rank { get; set; }
|
||||
public required string Specialisation { get; set; }
|
||||
public ICollection<Spell> Spells { get; set; } = new List<Spell>();
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
namespace Liber_Incantamentum.Domain.Entities
|
||||
{
|
||||
public class Spell
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public Spell()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
public required string Name { get; set; }
|
||||
public required string Description { get; set; }
|
||||
public required string Type { get; set; }
|
||||
public required DateTime CreationDate { get; set; }
|
||||
public Guid MageId { get; set; }
|
||||
public Mage Mage { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
namespace Liber_Incantamentum.Domain.Filter
|
||||
{
|
||||
public class MageFilter
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Rank { get; set; }
|
||||
public string? Specialisation { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
namespace Liber_Incantamentum.Domain.Filter
|
||||
{
|
||||
public class SpellFilter
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public DateTime? CreationDate { get; set; }
|
||||
public Guid? MageId { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="DomainEvents\**" />
|
||||
<Compile Remove="Exceptions\**" />
|
||||
<Compile Remove="ValueObjects\**" />
|
||||
<EmbeddedResource Remove="DomainEvents\**" />
|
||||
<EmbeddedResource Remove="Exceptions\**" />
|
||||
<EmbeddedResource Remove="ValueObjects\**" />
|
||||
<None Remove="DomainEvents\**" />
|
||||
<None Remove="Exceptions\**" />
|
||||
<None Remove="ValueObjects\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,14 +0,0 @@
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
|
||||
namespace Liber_Incantamentum.Domain.Repositories
|
||||
{
|
||||
public interface IMageRepository
|
||||
{
|
||||
Task<ICollection<Mage>> GetAllMagesAsync(MageFilter filterEntity);
|
||||
Task<bool> UpdateMageAsync(Mage entity);
|
||||
Task<bool> DeleteMageAsync(Guid id);
|
||||
Task<bool> AddMageAsync(Mage entity);
|
||||
Task<Mage> GetMageByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
|
||||
namespace Liber_Incantamentum.Domain.Repositories
|
||||
{
|
||||
public interface ISpellRepository
|
||||
{
|
||||
Task<ICollection<Spell>> GetAllSpellsAsync(SpellFilter filterEntity);
|
||||
Task<bool> UpdateSpellAsync(Spell entity);
|
||||
Task<bool> DeleteSpellAsync(Guid id);
|
||||
Task<bool> AddSpellAsync(Spell entity);
|
||||
Task<Spell> GetSpellByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,6 +0,0 @@
|
||||
namespace Liber_Incantamentum.Infrastructure.DependencyInjection
|
||||
{
|
||||
public class DependencyInjection
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Data\**" />
|
||||
<EmbeddedResource Remove="Data\**" />
|
||||
<None Remove="Data\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.7" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Liber_Incantamentum.Domain\Liber_Incantamentum.Domain.csproj" />
|
||||
<ProjectReference Include="..\Liber_Incantamentum.Application\Liber_Incantamentum.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,21 +0,0 @@
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Liber_Incantamentum.Infrastructure.Persistence
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions options) : base(options)
|
||||
{
|
||||
}
|
||||
public DbSet<Mage> Mages { get; set; }
|
||||
public DbSet<Spell> Spells { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace Liber_Incantamentum.Infrastructure.Persistence.Configurations
|
||||
{
|
||||
public class MageConfiguration : IEntityTypeConfiguration<Mage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Mage> builder)
|
||||
{
|
||||
builder.ToTable("Mages");
|
||||
|
||||
builder.HasKey(m => m.Id);
|
||||
|
||||
builder.Property(m => m.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
builder.Property(m => m.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(m => m.Rank)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(m => m.Specialisation)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace Liber_Incantamentum.Infrastructure.Persistence.Configurations
|
||||
{
|
||||
internal class SpellConfiguration
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
using Liber_Incantamentum.Application.Exceptions;
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
using Liber_Incantamentum.Domain.Repositories;
|
||||
using Liber_Incantamentum.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Liber_Incantamentum.Infrastructure.Repositories
|
||||
{
|
||||
public class MageRepository : IMageRepository
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public MageRepository(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public async Task<bool> AddMageAsync(Mage entity)
|
||||
{
|
||||
await _context.Mages.AddAsync(entity);
|
||||
if (!_context.ChangeTracker.HasChanges()) return false;
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteMageAsync(Guid id)
|
||||
{
|
||||
var mage = await GetMageByIdAsync(id);
|
||||
_context.Mages.Remove(mage);
|
||||
if (!_context.ChangeTracker.HasChanges()) return false;
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Mage>> GetAllMagesAsync(MageFilter filterEntity)
|
||||
{
|
||||
var query = _context.Mages.AsQueryable();
|
||||
|
||||
if (filterEntity.Id != Guid.Empty)
|
||||
query = query.Where(m => m.Id == filterEntity.Id);
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Name))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Name, filterEntity.Name));
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Rank))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Rank, filterEntity.Rank));
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Specialisation))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Specialisation, filterEntity.Specialisation));
|
||||
|
||||
var mages = await query.ToListAsync();
|
||||
return mages;
|
||||
|
||||
}
|
||||
|
||||
public async Task<Mage> GetMageByIdAsync(Guid id)
|
||||
{
|
||||
var mage = await _context.Mages.FindAsync(id);
|
||||
if (mage == null)
|
||||
{
|
||||
throw new NotFoundException($"No mage has been found with this id {id}");
|
||||
}
|
||||
return mage;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateMageAsync(Mage newMageValues)
|
||||
{
|
||||
var mageToUpdate = await GetMageByIdAsync(newMageValues.Id);
|
||||
|
||||
_context.Entry(mageToUpdate).CurrentValues.SetValues(newMageValues);
|
||||
|
||||
foreach (var spell in newMageValues.Spells)
|
||||
if (!mageToUpdate.Spells.Any(s => s.Id == spell.Id))
|
||||
mageToUpdate.Spells.Add(spell);
|
||||
|
||||
foreach (var spell in mageToUpdate.Spells.ToList())
|
||||
if (!newMageValues.Spells.Any(s => s.Id == spell.Id))
|
||||
mageToUpdate.Spells.Remove(spell);
|
||||
|
||||
if (!_context.ChangeTracker.HasChanges()) return false;
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
using Liber_Incantamentum.Domain.Entities;
|
||||
using Liber_Incantamentum.Domain.Filter;
|
||||
using Liber_Incantamentum.Domain.Repositories;
|
||||
using Liber_Incantamentum.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Liber_Incantamentum.Application.Exceptions;
|
||||
|
||||
namespace Liber_Incantamentum.Infrastructure.Repositories
|
||||
{
|
||||
|
||||
public class SpellRepository : ISpellRepository
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public SpellRepository(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public async Task<bool> AddSpellAsync(Spell entity)
|
||||
{
|
||||
await _context.Spells.AddAsync(entity);
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteSpellAsync(Guid id)
|
||||
{
|
||||
var spell = await GetSpellByIdAsync(id);
|
||||
_context.Spells.Remove(spell);
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Spell>> GetAllSpellsAsync(SpellFilter filterEntity)
|
||||
{
|
||||
var query = _context.Spells.AsQueryable();
|
||||
|
||||
if (filterEntity.Id != Guid.Empty)
|
||||
query = query.Where(m => m.Id == filterEntity.Id);
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Name))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Name, filterEntity.Name));
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Description))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Description, filterEntity.Description));
|
||||
|
||||
if (!string.IsNullOrEmpty(filterEntity.Type))
|
||||
query = query.Where(m => EF.Functions.ILike(m.Type, filterEntity.Type));
|
||||
|
||||
if (filterEntity.CreationDate != default)
|
||||
query = query.Where(m => m.CreationDate == filterEntity.CreationDate);
|
||||
if (filterEntity.MageId != Guid.Empty)
|
||||
query = query.Where(m => m.MageId == filterEntity.MageId);
|
||||
|
||||
var mages = await query.ToListAsync();
|
||||
return mages;
|
||||
}
|
||||
|
||||
public async Task<Spell> GetSpellByIdAsync(Guid id)
|
||||
{
|
||||
var spell = await _context.Spells.FindAsync(id);
|
||||
if (spell == null) throw new NotFoundException($"No spell has been found with the id : {id}");
|
||||
return spell;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateSpellAsync(Spell entity)
|
||||
{
|
||||
var spell = await GetSpellByIdAsync(entity.Id);
|
||||
_context.Entry(spell).CurrentValues.SetValues(entity);
|
||||
if (!_context.ChangeTracker.HasChanges()) return false;
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="IntegrationTests\**" />
|
||||
<Compile Remove="UnitTests\**" />
|
||||
<EmbeddedResource Remove="IntegrationTests\**" />
|
||||
<EmbeddedResource Remove="UnitTests\**" />
|
||||
<None Remove="IntegrationTests\**" />
|
||||
<None Remove="UnitTests\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -3,15 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36109.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.API", "Liber_Incantamentum\Liber_Incantamentum.API.csproj", "{BB761821-A9EC-4EBA-83A2-89F32C50041F}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Domain", "Liber_Incantamentum.Domain\Liber_Incantamentum.Domain.csproj", "{7DF16F8F-C307-455F-8389-5F0B90281347}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{93BEE101-D8F6-4622-95B6-E135AA9C066E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Application", "Liber_Incantamentum.Application\Liber_Incantamentum.Application.csproj", "{1307DD24-0090-4C5A-B56F-8A815DF46AB9}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.API", "LiberIncantamentum.API\Liber_Incantamentum.API.csproj", "{8B578810-E61F-4C5D-89B0-DE62B85346F7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Infrastructure", "Liber_Incantamentum.Infrastructure\Liber_Incantamentum.Infrastructure.csproj", "{C80C19DC-06DA-45DD-ADEE-2BB0F670A014}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Domain", "LiberIncantamentum.Domain\Liber_Incantamentum.Domain.csproj", "{0B68D83C-1751-427D-840D-1285A3DB98D0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Tests", "Liber_Incantamentum.Tests\Liber_Incantamentum.Tests.csproj", "{4C656BB8-ED7B-422A-A984-75522021B031}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Infrastructure", "LiberIncantamentum.Infrastructure\Liber_Incantamentum.Infrastructure.csproj", "{8D09ADAE-591C-4487-924F-2339D29EE60D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.Application", "LiberIncantamentum.Application\Liber_Incantamentum.Application.csproj", "{20EAEB50-C4FD-4A2D-92CC-8D0241556617}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.UnitTests", "LiberIncantamentum.UnitTests\Liber_Incantamentum.UnitTests.csproj", "{B829A2A1-9366-422B-B372-5DDA33BD2690}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.FunctionalTests", "Liber_Incantamentum.FunctionnalTests\Liber_Incantamentum.FunctionalTests.csproj", "{8F1D203C-1A76-4E76-AFC9-7B7477EB143E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Liber_Incantamentum.IntegrationTests", "Liber_Incantamentum.IntegrationTests\Liber_Incantamentum.IntegrationTests.csproj", "{F36ABF3F-5707-463C-BC33-DF8A261E4B5A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -19,30 +27,47 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BB761821-A9EC-4EBA-83A2-89F32C50041F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BB761821-A9EC-4EBA-83A2-89F32C50041F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BB761821-A9EC-4EBA-83A2-89F32C50041F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BB761821-A9EC-4EBA-83A2-89F32C50041F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7DF16F8F-C307-455F-8389-5F0B90281347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7DF16F8F-C307-455F-8389-5F0B90281347}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7DF16F8F-C307-455F-8389-5F0B90281347}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7DF16F8F-C307-455F-8389-5F0B90281347}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1307DD24-0090-4C5A-B56F-8A815DF46AB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1307DD24-0090-4C5A-B56F-8A815DF46AB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1307DD24-0090-4C5A-B56F-8A815DF46AB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1307DD24-0090-4C5A-B56F-8A815DF46AB9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C80C19DC-06DA-45DD-ADEE-2BB0F670A014}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C80C19DC-06DA-45DD-ADEE-2BB0F670A014}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C80C19DC-06DA-45DD-ADEE-2BB0F670A014}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C80C19DC-06DA-45DD-ADEE-2BB0F670A014}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4C656BB8-ED7B-422A-A984-75522021B031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4C656BB8-ED7B-422A-A984-75522021B031}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C656BB8-ED7B-422A-A984-75522021B031}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C656BB8-ED7B-422A-A984-75522021B031}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8B578810-E61F-4C5D-89B0-DE62B85346F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8B578810-E61F-4C5D-89B0-DE62B85346F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8B578810-E61F-4C5D-89B0-DE62B85346F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8B578810-E61F-4C5D-89B0-DE62B85346F7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0B68D83C-1751-427D-840D-1285A3DB98D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0B68D83C-1751-427D-840D-1285A3DB98D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0B68D83C-1751-427D-840D-1285A3DB98D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B68D83C-1751-427D-840D-1285A3DB98D0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8D09ADAE-591C-4487-924F-2339D29EE60D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8D09ADAE-591C-4487-924F-2339D29EE60D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8D09ADAE-591C-4487-924F-2339D29EE60D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8D09ADAE-591C-4487-924F-2339D29EE60D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{20EAEB50-C4FD-4A2D-92CC-8D0241556617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{20EAEB50-C4FD-4A2D-92CC-8D0241556617}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{20EAEB50-C4FD-4A2D-92CC-8D0241556617}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{20EAEB50-C4FD-4A2D-92CC-8D0241556617}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B829A2A1-9366-422B-B372-5DDA33BD2690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B829A2A1-9366-422B-B372-5DDA33BD2690}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B829A2A1-9366-422B-B372-5DDA33BD2690}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B829A2A1-9366-422B-B372-5DDA33BD2690}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8F1D203C-1A76-4E76-AFC9-7B7477EB143E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8F1D203C-1A76-4E76-AFC9-7B7477EB143E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8F1D203C-1A76-4E76-AFC9-7B7477EB143E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8F1D203C-1A76-4E76-AFC9-7B7477EB143E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F36ABF3F-5707-463C-BC33-DF8A261E4B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F36ABF3F-5707-463C-BC33-DF8A261E4B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F36ABF3F-5707-463C-BC33-DF8A261E4B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F36ABF3F-5707-463C-BC33-DF8A261E4B5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{8B578810-E61F-4C5D-89B0-DE62B85346F7} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{0B68D83C-1751-427D-840D-1285A3DB98D0} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{8D09ADAE-591C-4487-924F-2339D29EE60D} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{20EAEB50-C4FD-4A2D-92CC-8D0241556617} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{B829A2A1-9366-422B-B372-5DDA33BD2690} = {93BEE101-D8F6-4622-95B6-E135AA9C066E}
|
||||
{8F1D203C-1A76-4E76-AFC9-7B7477EB143E} = {93BEE101-D8F6-4622-95B6-E135AA9C066E}
|
||||
{F36ABF3F-5707-463C-BC33-DF8A261E4B5A} = {93BEE101-D8F6-4622-95B6-E135AA9C066E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B7CB31CD-9866-48CB-8A83-9F2EB1E9E53B}
|
||||
EndGlobalSection
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace Liber_Incantamentum.API.Controller
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class Example : ControllerBase
|
||||
{
|
||||
// GET: api/<ValuesController>
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET api/<ValuesController>/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST api/<ValuesController>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/<ValuesController>/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/<ValuesController>/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
using Liber_Incantamentum.Application.DTOs.Mage;
|
||||
using Liber_Incantamentum.Application.Services.Generals;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Liber_Incantamentum.API.Controller
|
||||
{
|
||||
public class MageController : ControllerBase
|
||||
{
|
||||
private readonly MageService _mageService;
|
||||
public MageController(MageService mageService)
|
||||
{
|
||||
_mageService = mageService;
|
||||
}
|
||||
|
||||
[HttpGet("/mages")]
|
||||
public async Task<ActionResult<ICollection<MageDto>>> GetAllMages([FromQuery] MageDtoFilter filter)
|
||||
{
|
||||
var mages = await _mageService.GetAllMagesAsync(filter);
|
||||
if (mages == null || mages.Any()) return Ok(mages);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("/mages/{id}")]
|
||||
public async Task<ActionResult<MageDto>> GetMage([FromRoute] Guid id)
|
||||
{
|
||||
var mage = await _mageService.GetMageByIdAsync(id);
|
||||
if (mage != null) return Ok(mage);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[HttpPost("/mages")]
|
||||
public async Task<IActionResult> CreateMage([FromBody] MageDtoCreate mage)
|
||||
{
|
||||
if (await _mageService.AddMageAsync(mage)) return NoContent();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpPut("/mages/{id}")]
|
||||
public async Task<IActionResult> UpdateMage([FromBody] MageDtoUpdate mage, [FromRoute] Guid id)
|
||||
{
|
||||
if (await _mageService.UpdateMageAsync(mage, id)) return NoContent();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpPatch("/mages/{id}")]
|
||||
public async Task<IActionResult> PatchMage([FromBody] MageDtoUpdate mage, [FromRoute] Guid id)
|
||||
{
|
||||
if (await _mageService.UpdateMageAsync(mage, id)) return NoContent();
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
[HttpDelete("/mages/{id}")]
|
||||
public async Task<IActionResult> DeleteMage([FromRoute] Guid id)
|
||||
{
|
||||
if (await _mageService.DeleteMageAsync(id)) return NoContent();
|
||||
return BadRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
namespace Liber_Incantamentum.API.Controller
|
||||
{
|
||||
public class SpellController
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\**" />
|
||||
<Compile Remove="Middlewares\**" />
|
||||
<Content Remove="Controllers\**" />
|
||||
<Content Remove="Middlewares\**" />
|
||||
<EmbeddedResource Remove="Controllers\**" />
|
||||
<EmbeddedResource Remove="Middlewares\**" />
|
||||
<None Remove="Controllers\**" />
|
||||
<None Remove="Middlewares\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
|
||||
<PackageReference Include="FluentValidation" Version="12.0.0" />
|
||||
<PackageReference Include="AutoMapper" Version="15.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Liber_Incantamentum.Application\Liber_Incantamentum.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,6 +0,0 @@
|
||||
@Liber_Incantamentum_HostAddress = http://localhost:5225
|
||||
|
||||
GET {{Liber_Incantamentum_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
Loading…
x
Reference in New Issue
Block a user