editing dto from PurchaseProduct
This commit is contained in:
@@ -3,20 +3,7 @@ namespace PyroFetes.DTO.PurchaseProduct.Request;
|
||||
public class CreatePurchaseProductDto
|
||||
{
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public int ProductId { get; set; }
|
||||
public int ProductReferences { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public decimal ProductDuration {get; set;}
|
||||
public decimal ProductCaliber { get; set; }
|
||||
public int ProductApprovalNumber { get; set; }
|
||||
public decimal ProductWeight { get; set; }
|
||||
public decimal ProductNec { get; set; }
|
||||
public string? ProductImage { get; set; }
|
||||
public string? ProductLink { get; set; }
|
||||
public int ProductMinimalQuantity { get; set; }
|
||||
|
||||
|
||||
public int PurchaseOrderId { get; set; }
|
||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
||||
}
|
@@ -2,9 +2,6 @@ namespace PyroFetes.DTO.PurchaseProduct.Response;
|
||||
|
||||
public class GetPurchaseProductDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public int ProductId { get; set; }
|
||||
public int ProductReferences { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
@@ -18,7 +15,8 @@ public class GetPurchaseProductDto
|
||||
public string? ProductLink { get; set; }
|
||||
public int ProductMinimalQuantity { get; set; }
|
||||
|
||||
|
||||
public int PurchaseOrderId { get; set; }
|
||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
||||
|
||||
public int Quantity { get; set; }
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using FastEndpoints;
|
||||
using PyroFetes.DTO.PurchaseProduct.Request;
|
||||
using PyroFetes.DTO.PurchaseProduct.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoint<CreatePurchaseProductDto, GetPurchaseProductDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/purchaseProducts");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct)
|
||||
{
|
||||
var purchaseOrderExists = await database.PurchaseOrders.FirstOrDefaultAsync(a => a.Id == req.PurchaseOrderId, ct);
|
||||
|
||||
if (purchaseOrderExists == null)
|
||||
{
|
||||
await Send.NoContentAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
var purchaseProduct = new Models.PurchaseProduct()
|
||||
{
|
||||
ProductId = req.ProductId,
|
||||
PurchaseOrderId = req.PurchaseOrderId,
|
||||
Quantity = req.Quantity
|
||||
};
|
||||
database.PurchaseProducts.Add(purchaseProduct);
|
||||
|
||||
var purchaseOrder = new Models.PurchaseOrder()
|
||||
{
|
||||
PurchaseConditions = req.PurchaseOrderPurchaseConditions,
|
||||
};
|
||||
database.PurchaseOrders.Add(purchaseOrder);
|
||||
|
||||
await database.SaveChangesAsync(ct);
|
||||
|
||||
GetPurchaseProductDto responseDto = new()
|
||||
{
|
||||
ProductId = purchaseProduct.ProductId,
|
||||
PurchaseOrderId = purchaseProduct.PurchaseOrderId,
|
||||
Quantity = purchaseProduct.Quantity,
|
||||
PurchaseOrderPurchaseConditions = purchaseOrder.PurchaseConditions,
|
||||
};
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class DeletePurchaseProductEndpoint
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class GetAllPurchasesProductsEndpoint
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class GetPurchaseProductEndpoint
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class PatchPurchaseProductQuantityEndpoint
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||
|
||||
public class UpdatePurchaseProductEndpoint
|
||||
{
|
||||
|
||||
}
|
@@ -7,6 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
||||
|
Reference in New Issue
Block a user