Adapted Deliverer endpoints with repository spec and automapper

This commit is contained in:
Cristiano
2025-11-13 15:26:22 +01:00
parent 60a7c059b4
commit c6d4ef2c58
7 changed files with 38 additions and 23 deletions

View File

@@ -2,11 +2,12 @@ using FastEndpoints;
using PyroFetes.DTO.Deliverer.Request;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Deliverers;
public class CreateDelivererEndpoint(
PyroFetesDbContext database,
DeliverersRepository deliverersRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateDelivererDto, GetDelivererDto>
{
public override void Configure()
@@ -23,9 +24,7 @@ public class CreateDelivererEndpoint(
Transporter = req.Transporter,
};
database.Deliverers.Add(newDeliverer);
await database.SaveChangesAsync(ct);
await deliverersRepository.AddAsync(newDeliverer, ct);
await Send.OkAsync(mapper.Map<GetDelivererDto>(newDeliverer), ct);
}