diff --git a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs index 5e0990d..f862856 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs @@ -8,5 +8,4 @@ public class CreateDeliveryNoteDto public DateOnly RealDeliveryDate { get; set; } public int DelivererId { get; set; } - } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Request/PatchDeliveryNoteRealDeliveryDateDto.cs b/PyroFetes/DTO/DeliveryNote/Request/PatchDeliveryNoteRealDeliveryDateDto.cs index 486df5e..eb2182e 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/PatchDeliveryNoteRealDeliveryDateDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/PatchDeliveryNoteRealDeliveryDateDto.cs @@ -4,5 +4,4 @@ public class PatchDeliveryNoteRealDeliveryDateDto { public int Id { get; set; } public DateOnly RealDeliveryDate { get; set; } - } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs index 1ab7cbf..b4746ff 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs @@ -9,5 +9,4 @@ public class UpdateDeliveryNoteDto public DateOnly? RealDeliveryDate { get; set; } public int DelivererId { get; set; } - } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs index 6b4ffc7..3683ed3 100644 --- a/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs @@ -13,5 +13,5 @@ public class GetDeliveryNoteDto public int DelivererId { get; set; } public string? DelivererTransporter { get; set; } - public List Products { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseOrder/Request/PatchPurchaseOrderPurchaseConditionsDto.cs b/PyroFetes/DTO/PurchaseOrder/Request/PatchPurchaseOrderPurchaseConditionsDto.cs new file mode 100644 index 0000000..77586b0 --- /dev/null +++ b/PyroFetes/DTO/PurchaseOrder/Request/PatchPurchaseOrderPurchaseConditionsDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.PurchaseOrder.Request; + +public class PatchPurchaseOrderPurchaseConditionsDto +{ + public int Id { get; set; } + public string? PurchaseConditions { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs new file mode 100644 index 0000000..38a012f --- /dev/null +++ b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.PurchaseOrder.Response; + +public class GetPurchaseOrderDto +{ + public int Id { get; set; } + public string? PurchaseConditions { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/User/Request/PatchUserPasswordDto.cs b/PyroFetes/DTO/User/Request/PatchUserPasswordDto.cs new file mode 100644 index 0000000..bfa2051 --- /dev/null +++ b/PyroFetes/DTO/User/Request/PatchUserPasswordDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.User.Request; + +public class PatchUserPasswordDto +{ + public int Id { get; set; } + public string? Password { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs index 7af1030..5a02644 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs @@ -12,7 +12,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint { public override void Configure() { - Delete("/api/purchaseOrders/{Id:int}"); + Delete("/api/purchaseOrders/{Id}", x => new {x.Id}); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/PurchaseProduct/GetAllPurchasesProductsEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/GetAllPurchasesProductsEndpoint.cs deleted file mode 100644 index 54517ff..0000000 --- a/PyroFetes/Endpoints/PurchaseProduct/GetAllPurchasesProductsEndpoint.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace PyroFetes.Endpoints.PurchaseProduct; - -public class GetAllPurchasesProductsEndpoint -{ - -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProduct/GetPurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/GetPurchaseProductEndpoint.cs deleted file mode 100644 index 9527e4c..0000000 --- a/PyroFetes/Endpoints/PurchaseProduct/GetPurchaseProductEndpoint.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace PyroFetes.Endpoints.PurchaseProduct; - -public class GetPurchaseProductEndpoint -{ - -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs index 7772a82..dd53757 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs @@ -1,6 +1,36 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.PurchaseProduct.Request; +using PyroFetes.DTO.PurchaseProduct.Response; + namespace PyroFetes.Endpoints.PurchaseProduct; -public class PatchPurchaseProductQuantityEndpoint +public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint { - + 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); + } } \ No newline at end of file