Compare commits
7 Commits
b79e07dd8b
...
8bd7fadabc
Author | SHA1 | Date | |
---|---|---|---|
8bd7fadabc | |||
e4e6c1c3f7 | |||
791eff9256 | |||
b4502ae562 | |||
347003c24a | |||
31e69aae1a | |||
74b5fa6666 |
@@ -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; }
|
||||||
|
}
|
@@ -3,20 +3,7 @@ namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|||||||
public class CreatePurchaseProductDto
|
public class CreatePurchaseProductDto
|
||||||
{
|
{
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
public int ProductId { 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 int PurchaseOrderId { get; set; }
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
public string? PurchaseOrderPurchaseConditions { get; set; }
|
||||||
}
|
}
|
@@ -2,6 +2,7 @@ namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|||||||
|
|
||||||
public class PatchPurchaseProductQuantityDto
|
public class PatchPurchaseProductQuantityDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
public int PurchaseOrderId { get; set; }
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
@@ -2,10 +2,11 @@ namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|||||||
|
|
||||||
public class UpdatePurchaseProductDto
|
public class UpdatePurchaseProductDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
public int PurchaseOrderId { get; set; }
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
public int ProductReferences { get; set; }
|
||||||
public string? ProductName { get; set; }
|
public string? ProductName { get; set; }
|
||||||
public decimal ProductDuration {get; set;}
|
public decimal ProductDuration {get; set;}
|
||||||
@@ -17,7 +18,5 @@ public class UpdatePurchaseProductDto
|
|||||||
public string? ProductLink { get; set; }
|
public string? ProductLink { get; set; }
|
||||||
public int ProductMinimalQuantity { get; set; }
|
public int ProductMinimalQuantity { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public int PurchaseOrderId { get; set; }
|
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
public string? PurchaseOrderPurchaseConditions { get; set; }
|
||||||
}
|
}
|
@@ -2,23 +2,20 @@ namespace PyroFetes.DTO.PurchaseProduct.Response;
|
|||||||
|
|
||||||
public class GetPurchaseProductDto
|
public class GetPurchaseProductDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
public int ProductReferences { get; set; }
|
public string? ProductReferences { get; set; }
|
||||||
public string? ProductName { get; set; }
|
public string? ProductName { get; set; }
|
||||||
public decimal ProductDuration {get; set;}
|
public decimal ProductDuration {get; set;}
|
||||||
public decimal ProductCaliber { get; set; }
|
public decimal ProductCaliber { get; set; }
|
||||||
public int ProductApprovalNumber { get; set; }
|
public int ProductApprovalNumber { get; set; }
|
||||||
public decimal ProductWeight { get; set; }
|
public decimal ProductWeight { get; set; }
|
||||||
public decimal ProductNec { get; set; }
|
public decimal ProductNec { get; set; }
|
||||||
public decimal ProductSellingPrice { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
public string? ProductImage { get; set; }
|
||||||
public string? ProductLink { get; set; }
|
public string? ProductLink { get; set; }
|
||||||
public int ProductMinimalQuantity { get; set; }
|
public int ProductMinimalQuantity { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public int PurchaseOrderId { get; set; }
|
public int PurchaseOrderId { get; set; }
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
public string? PurchaseOrderPurchaseConditions { get; set; }
|
||||||
|
|
||||||
|
public int Quantity { 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; }
|
||||||
|
}
|
@@ -0,0 +1,67 @@
|
|||||||
|
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 product = await database.Products.FirstOrDefaultAsync(p => p.Id == req.ProductId, ct);
|
||||||
|
if (product == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var purchaseOrder = await database.PurchaseOrders.FirstOrDefaultAsync(po => po.Id == req.PurchaseOrderId, ct);
|
||||||
|
|
||||||
|
if (purchaseOrder == null)
|
||||||
|
{
|
||||||
|
purchaseOrder = new Models.PurchaseOrder()
|
||||||
|
{
|
||||||
|
PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées"
|
||||||
|
};
|
||||||
|
database.PurchaseOrders.Add(purchaseOrder);
|
||||||
|
await database.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
var purchaseProduct = new Models.PurchaseProduct()
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
PurchaseOrderId = purchaseOrder.Id,
|
||||||
|
Quantity = req.Quantity
|
||||||
|
};
|
||||||
|
database.PurchaseProducts.Add(purchaseProduct);
|
||||||
|
await database.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var responseDto = new GetPurchaseProductDto()
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
ProductReferences = product.Reference,
|
||||||
|
ProductName = product.Name,
|
||||||
|
ProductDuration = product.Duration,
|
||||||
|
ProductCaliber = product.Caliber,
|
||||||
|
ProductApprovalNumber = product.ApprovalNumber,
|
||||||
|
ProductWeight = product.Weight,
|
||||||
|
ProductNec = product.Nec,
|
||||||
|
ProductImage = product.Image,
|
||||||
|
ProductLink = product.Link,
|
||||||
|
ProductMinimalQuantity = product.MinimalQuantity,
|
||||||
|
|
||||||
|
PurchaseOrderId = purchaseOrder.Id,
|
||||||
|
PurchaseOrderPurchaseConditions = purchaseOrder.PurchaseConditions,
|
||||||
|
Quantity = purchaseProduct.Quantity
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||||
|
|
||||||
|
public class DeletePurchaseOrderRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint<DeletePurchaseOrderRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/purchaseOrders/{Id}", x => new {x.Id});
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var purchaseOrder = await database.PurchaseOrders
|
||||||
|
.Include(po => po.PurchaseProducts)
|
||||||
|
.SingleOrDefaultAsync(po => po.Id == req.Id, ct);
|
||||||
|
|
||||||
|
if (purchaseOrder == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (purchaseOrder.PurchaseProducts != null && purchaseOrder.PurchaseProducts.Any())
|
||||||
|
{
|
||||||
|
database.PurchaseProducts.RemoveRange(purchaseOrder.PurchaseProducts);
|
||||||
|
}
|
||||||
|
|
||||||
|
database.PurchaseOrders.Remove(purchaseOrder);
|
||||||
|
await database.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Request;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.PurchaseProduct;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@@ -7,6 +7,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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.AspNetCore.OpenApi" Version="8.0.19"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
||||||
|
Reference in New Issue
Block a user