forked from sanchezvem/PyroFetes
17:17 09/10
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using PyroFetes.DTO.Material.Response;
|
||||
using API.DTO.Material.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PyroFetes.Endpoints.Material;
|
||||
@@ -10,17 +9,17 @@ public class GetMaterialRequest
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<GetMaterialRequest, GetMaterialDto>
|
||||
public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetMaterialRequest, GetMaterialDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/material/{@id}", x => new { x.Id });
|
||||
Get("/material/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
||||
{
|
||||
Models.Material? material = await appDbContext
|
||||
Models.Material? material = await pyrofetesdbcontext
|
||||
.Materials
|
||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
@@ -34,7 +33,7 @@ public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Get
|
||||
GetMaterialDto responseDto = new()
|
||||
{
|
||||
Id = material.Id,
|
||||
Label = material.Label,
|
||||
Label = material.Name,
|
||||
WarehouseId = material.WarehouseId,
|
||||
};
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
|
||||
Reference in New Issue
Block a user