creating purchaseproduct's endpoint and fix error in dto
This commit is contained in:
@@ -8,5 +8,4 @@ public class CreateDeliveryNoteDto
|
|||||||
public DateOnly RealDeliveryDate { get; set; }
|
public DateOnly RealDeliveryDate { get; set; }
|
||||||
|
|
||||||
public int DelivererId { get; set; }
|
public int DelivererId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
@@ -4,5 +4,4 @@ public class PatchDeliveryNoteRealDeliveryDateDto
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateOnly RealDeliveryDate { get; set; }
|
public DateOnly RealDeliveryDate { get; set; }
|
||||||
|
|
||||||
}
|
}
|
@@ -9,5 +9,4 @@ public class UpdateDeliveryNoteDto
|
|||||||
public DateOnly? RealDeliveryDate { get; set; }
|
public DateOnly? RealDeliveryDate { get; set; }
|
||||||
|
|
||||||
public int DelivererId { get; set; }
|
public int DelivererId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
@@ -13,5 +13,5 @@ public class GetDeliveryNoteDto
|
|||||||
public int DelivererId { get; set; }
|
public int DelivererId { get; set; }
|
||||||
public string? DelivererTransporter { get; set; }
|
public string? DelivererTransporter { get; set; }
|
||||||
|
|
||||||
public List<GetProductDeliveryDto> Products { get; set; }
|
public List<GetProductDeliveryDto>? Products { get; set; }
|
||||||
}
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PyroFetes.DTO.PurchaseOrder.Request;
|
||||||
|
|
||||||
|
public class PatchPurchaseOrderPurchaseConditionsDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? PurchaseConditions { get; set; }
|
||||||
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PyroFetes.DTO.PurchaseOrder.Response;
|
||||||
|
|
||||||
|
public class GetPurchaseOrderDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? PurchaseConditions { get; set; }
|
||||||
|
}
|
7
PyroFetes/DTO/User/Request/PatchUserPasswordDto.cs
Normal file
7
PyroFetes/DTO/User/Request/PatchUserPasswordDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PyroFetes.DTO.User.Request;
|
||||||
|
|
||||||
|
public class PatchUserPasswordDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Password { get; set; }
|
||||||
|
}
|
@@ -12,7 +12,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/purchaseOrders/{Id:int}");
|
Delete("/api/purchaseOrders/{Id}", x => new {x.Id});
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
|
||||||
|
|
||||||
public class GetAllPurchasesProductsEndpoint
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,6 +0,0 @@
|
|||||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
|
||||||
|
|
||||||
public class GetPurchaseProductEndpoint
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,6 +1,36 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Request;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Response;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.PurchaseProduct;
|
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||||
|
|
||||||
public class PatchPurchaseProductQuantityEndpoint
|
public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchPurchaseProductQuantityDto, GetPurchaseProductDto>
|
||||||
{
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Patch("/api/purchaseOrders/{ProductId}/{PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var purchaseProduct = await database.PurchaseProducts.SingleOrDefaultAsync(po => po.ProductId == req.ProductId && po.PurchaseOrderId == req.PurchaseOrderId, ct);
|
||||||
|
if (purchaseProduct == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
purchaseProduct.Quantity = req.Quantity;
|
||||||
|
await database.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetPurchaseProductDto responseDto = new()
|
||||||
|
{
|
||||||
|
ProductId = purchaseProduct.ProductId,
|
||||||
|
PurchaseOrderId = purchaseProduct.PurchaseOrderId,
|
||||||
|
Quantity = purchaseProduct.Quantity
|
||||||
|
};
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user