Provider typê added + delete customer updated
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Customer.Request;
|
||||
using PyroFetes.DTO.Customer.Response;
|
||||
using PyroFetes.DTO.CustomerType.Request;
|
||||
using PyroFetes.DTO.CustomerType.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.CustomerType;
|
||||
|
||||
public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCustomerRequest, GetCustomerDto>
|
||||
public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCustomerTypeRequest, GetCustomerTypeDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -15,16 +13,16 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetCustomerRequest req, CancellationToken ct)
|
||||
public override async Task HandleAsync(GetCustomerTypeRequest req, CancellationToken ct)
|
||||
{
|
||||
Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (databaseCustomer == null)
|
||||
if (databaseCustomerType == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
pyroFetesDbContext.Customers.Remove(databaseCustomer);
|
||||
pyroFetesDbContext.CustomerTypes.Remove(databaseCustomerType);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
|
||||
Reference in New Issue
Block a user