forked from sanchezvem/pyrofetes-backend
Refactor all code
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
using FastEndpoints;
|
||||
using PyroFetes.DTO.Supplier.Request;
|
||||
using PyroFetes.DTO.Supplier.Response;
|
||||
using PyroFetes.Models;
|
||||
using PyroFetes.Repositories;
|
||||
|
||||
namespace PyroFetes.Endpoints.Suppliers;
|
||||
|
||||
public class CreateSupplierEndpoint(
|
||||
SuppliersRepository suppliersRepository,
|
||||
AutoMapper.IMapper mapper) : Endpoint<CreateSupplierDto, GetSupplierDto>
|
||||
public class CreateSupplierEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint<CreateSupplierDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -18,19 +15,7 @@ public class CreateSupplierEndpoint(
|
||||
|
||||
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
|
||||
{
|
||||
Supplier? supplier = new Supplier()
|
||||
{
|
||||
Name = req.Name,
|
||||
Email = req.Email,
|
||||
Phone = req.Phone,
|
||||
Address = req.Address,
|
||||
City = req.City,
|
||||
ZipCode = req.ZipCode,
|
||||
DeliveryDelay = req.DeliveryDelay
|
||||
};
|
||||
|
||||
await suppliersRepository.AddAsync(supplier, ct);
|
||||
|
||||
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
|
||||
await suppliersRepository.AddAsync(mapper.Map<Supplier>(req), ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user