finalisation des endpoints

This commit is contained in:
2025-11-13 15:11:12 +01:00
parent 55f92ad761
commit 5c12a45ae6
41 changed files with 79 additions and 258 deletions

View File

@@ -1,11 +1,10 @@
using FastEndpoints;
using PF3.DTO.SoundCategory.Request;
using PF3.DTO.SoundCategory.Response;
using PF3.Models;
using PyroFetes.DTO.SoundCategory.Request;
using PyroFetes.DTO.SoundCategory.Response;
namespace PF3.Endpoints.SoundCategory;
namespace PyroFetes.Endpoints.SoundCategory;
public class CreateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
public class CreateSoundCategoryEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
{
public override void Configure()
{
@@ -15,13 +14,13 @@ public class CreateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<C
public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct)
{
var soundCategory = new Models.SoundCategory
var soundCategory = new PyroFetes.Models.SoundCategory
{
Name = req.Name,
};
pf3DbContext.SoundsCategorys.Add(soundCategory);
await pf3DbContext.SaveChangesAsync(ct);
pyroFetesDbContext.SoundCategories.Add(soundCategory);
await pyroFetesDbContext.SaveChangesAsync(ct);
var result = new ReadSoundCategoryDto
{

View File

@@ -1,10 +1,10 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.SoundCategory.Request;
using PyroFetes.DTO.SoundCategory.Request;
namespace PF3.Endpoints.SoundCategory;
namespace PyroFetes.Endpoints.SoundCategory;
public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
public class DeleteSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
{
public override void Configure()
{
@@ -14,14 +14,14 @@ public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<I
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
{
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
if (soundCategory is null)
{
await Send.NotFoundAsync(ct);
return;
}
pf3DbContext.SoundsCategorys.Remove(soundCategory);
pf3DbContext.SoundCategories.Remove(soundCategory);
await pf3DbContext.SaveChangesAsync(ct);
await Send.OkAsync(ct);

View File

@@ -1,10 +1,10 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.SoundCategory.Response;
using PyroFetes.DTO.SoundCategory.Response;
namespace PF3.Endpoints.SoundCategory;
namespace PyroFetes.Endpoints.SoundCategory;
public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
public class GetAllSoundCategorysEndpoint(PyroFetesDbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
{
public override void Configure()
{
@@ -14,7 +14,7 @@ public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointW
public override async Task HandleAsync(CancellationToken ct)
{
var soundCategorys = await pf3DbContext.SoundsCategorys.ToListAsync(ct);
var soundCategorys = await pf3DbContext.SoundCategories.ToListAsync(ct);
var result = soundCategorys.Select(sC => new ReadSoundCategoryDto
{

View File

@@ -1,11 +1,11 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.SoundCategory.Request;
using PF3.DTO.SoundCategory.Response;
using PyroFetes.DTO.SoundCategory.Request;
using PyroFetes.DTO.SoundCategory.Response;
namespace PF3.Endpoints.SoundCategory;
namespace PyroFetes.Endpoints.SoundCategory;
public class GetSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
public class GetSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
{
public override void Configure()
{
@@ -15,7 +15,7 @@ public class GetSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSo
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
{
var soundCategory = await pf3DbContext.SoundsCategorys
var soundCategory = await pf3DbContext.SoundCategories
.Where(sc => sc.Id == req.Id)
.Select(sc => new ReadSoundCategoryDto
{

View File

@@ -1,11 +1,11 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PF3.DTO.SoundCategory.Request;
using PF3.DTO.SoundCategory.Response;
using PyroFetes.DTO.SoundCategory.Request;
using PyroFetes.DTO.SoundCategory.Response;
namespace PF3.Endpoints.SoundCategory;
namespace PyroFetes.Endpoints.SoundCategory;
public class UpdateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
public class UpdateSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
{
public override void Configure()
{
@@ -15,7 +15,7 @@ public class UpdateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<U
public override async Task HandleAsync(UpdateSoundCategoryDto req, CancellationToken ct)
{
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
if (soundCategory is null)
{
await Send.NotFoundAsync(ct);