forked from sanchezvem/pyrofetes-backend
Refactor all code
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Product.Response;
|
||||
using PyroFetes.Models;
|
||||
using PyroFetes.Repositories;
|
||||
@@ -18,7 +17,7 @@ public class GetProductEndpoint(
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/products/{@Id}", x => new {x.Id});
|
||||
Get("/products/{@Id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
@@ -26,12 +25,12 @@ public class GetProductEndpoint(
|
||||
{
|
||||
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct);
|
||||
|
||||
if (product == null)
|
||||
if (product is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
await Send.OkAsync(mapper.Map<GetProductDto>(product), ct);
|
||||
|
||||
await Send.OkAsync(mapper.Map<GetProductDto>(product), ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user