forked from sanchezvem/PyroFetes
17:17 09/10
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Brand.Request;
|
namespace API.DTO.Brand.Request;
|
||||||
|
|
||||||
public class CreateBrandDto
|
public class CreateBrandDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Brand.Request;
|
namespace API.DTO.Brand.Request;
|
||||||
|
|
||||||
public class UpdateBrandDto
|
public class UpdateBrandDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Brand.Response;
|
namespace API.DTO.Brand.Response;
|
||||||
|
|
||||||
public class GetBrandDto
|
public class GetBrandDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Classification.Request;
|
namespace API.DTO.Classification.Request;
|
||||||
|
|
||||||
public class CreateClassificationDto
|
public class CreateClassificationDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Classification.Request;
|
namespace API.DTO.Classification.Request;
|
||||||
|
|
||||||
public class UpdateClassificationDto
|
public class UpdateClassificationDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Classification.Response;
|
namespace API.DTO.Classification.Response;
|
||||||
|
|
||||||
public class GetClassificationDto
|
public class GetClassificationDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Color.Request;
|
namespace API.DTO.Color.Request;
|
||||||
|
|
||||||
public class CreateColorDto
|
public class CreateColorDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Color.Request;
|
namespace API.DTO.Color.Request;
|
||||||
|
|
||||||
public class UpdateColorDto
|
public class UpdateColorDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Color.Response;
|
namespace API.DTO.Color.Response;
|
||||||
|
|
||||||
public class GetColorDto
|
public class GetColorDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Effect.Request;
|
namespace API.DTO.Effect.Request;
|
||||||
|
|
||||||
public class CreateEffectDto
|
public class CreateEffectDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Effect.Request;
|
namespace API.DTO.Effect.Request;
|
||||||
|
|
||||||
public class UpdateEffectDto
|
public class UpdateEffectDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Effect.Response;
|
namespace API.DTO.Effect.Response;
|
||||||
|
|
||||||
public class GetEffectDto
|
public class GetEffectDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Material.Request;
|
namespace API.DTO.Material.Request;
|
||||||
|
|
||||||
public class CreateMaterialDto
|
public class CreateMaterialDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Material.Request;
|
namespace API.DTO.Material.Request;
|
||||||
|
|
||||||
public class UpdateMaterialDto
|
public class UpdateMaterialDto
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace PyroFetes.DTO.Material.Response;
|
namespace API.DTO.Material.Response;
|
||||||
|
|
||||||
public class GetMaterialDto
|
public class GetMaterialDto
|
||||||
{
|
{
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
using PyroFetes.Models;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
|
||||||
namespace PyroFetes.DTO.Product.Request;
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
|
||||||
public class CreateProductDto
|
|
||||||
{
|
{
|
||||||
|
public class CreateProductDto
|
||||||
|
{
|
||||||
public int References { get; set; }
|
public int References { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public decimal Duration { get; set; }
|
public decimal Duration { get; set; }
|
||||||
@@ -11,11 +11,16 @@ public class CreateProductDto
|
|||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
public decimal Nec { get; set; }
|
public decimal Nec { get; set; }
|
||||||
public decimal SellingPrice {get; set;}
|
public decimal SellingPrice { get; set; }
|
||||||
public string? Image { get; set; }
|
public string? Image { get; set; }
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
|
|
||||||
public int ClassificationId { get; set;}
|
public int ClassificationId { get; set;}
|
||||||
public int ProductCategoryId { get; set; }
|
public int ProductCategoryId { get; set; }
|
||||||
|
|
||||||
|
// Liste des fournisseurs liés au produit
|
||||||
|
public List<ProductSupplierPriceDto>? Suppliers { get; set; }
|
||||||
|
|
||||||
|
// Liste des entrepôts liés au produit
|
||||||
|
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,20 +1,27 @@
|
|||||||
using PyroFetes.Models;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
|
||||||
namespace PyroFetes.DTO.Product.Request;
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
|
||||||
public class UpdateProductDto
|
|
||||||
{
|
{
|
||||||
|
public class UpdateProductDto
|
||||||
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int Reference { get; set; }
|
public int References { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public decimal Duration { get; set; }
|
public decimal Duration { get; set; }
|
||||||
public decimal Caliber { get; set; }
|
public decimal Caliber { get; set; }
|
||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
public decimal Nec { get; set; }
|
public decimal Nec { get; set; }
|
||||||
public decimal SellingPrice {get; set;}
|
public decimal SellingPrice { get; set; }
|
||||||
public string? Image { get; set; }
|
public string? Image { get; set; }
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
public int ClassificationId { get; set;}
|
public int ClassificationId { get; set; }
|
||||||
public int ProductCategoryId { get; set; }
|
public int ProductCategoryId { get; set; }
|
||||||
|
|
||||||
|
// Liste des fournisseurs associés
|
||||||
|
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
|
||||||
|
|
||||||
|
// Liste des entrepôts associés
|
||||||
|
public List<UpdateProductWarehouseDto> Warehouses { get; set; } = new();
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,9 +1,11 @@
|
|||||||
using PyroFetes.Models;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
|
||||||
namespace PyroFetes.DTO.Product.Response;
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
|
||||||
public class GetProductDto
|
|
||||||
{
|
{
|
||||||
|
public class GetProductDto
|
||||||
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int Reference { get; set; }
|
public int Reference { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
@@ -12,12 +14,16 @@ public class GetProductDto
|
|||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
public decimal Nec { get; set; }
|
public decimal Nec { get; set; }
|
||||||
public decimal SellingPrice {get; set;}
|
public decimal SellingPrice { get; set; }
|
||||||
public string? Image { get; set; }
|
public string? Image { get; set; }
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
public int ClassificationId { get; set;}
|
public int ClassificationId { get; set; }
|
||||||
public string? ClassificationLabel { get; set; }
|
|
||||||
public int ProductCategoryId { get; set; }
|
public int ProductCategoryId { get; set; }
|
||||||
public string? ProductCategoryLabel { get; set; }
|
|
||||||
|
|
||||||
|
// Fournisseurs liés
|
||||||
|
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
|
||||||
|
|
||||||
|
// Entrepôts liés
|
||||||
|
public List<GetProductWarehouseDto> Warehouses { get; set; } = new();
|
||||||
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
{
|
||||||
|
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Supplier
|
||||||
|
public class ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; } // Id du produit (pour update)
|
||||||
|
public int SupplierId { get; set; } // Id du fournisseur
|
||||||
|
public decimal SellingPrice { get; set; } // Prix de vente
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
{
|
||||||
|
// DTO pour la lecture des fournisseurs liés à un produit
|
||||||
|
public class GetProductSupplierDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int SupplierId { get; set; }
|
||||||
|
public string SupplierName { get; set; } = string.Empty;
|
||||||
|
public decimal SellingPrice { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,17 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
{
|
||||||
|
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Warehouse
|
||||||
|
public class CreateProductWarehouseDto
|
||||||
|
{
|
||||||
|
public int WarehouseId { get; set; }
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateProductWarehouseDto
|
||||||
|
{
|
||||||
|
public int WarehouseId { get; set; }
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
{
|
||||||
|
// DTO pour la lecture des entrepôts liés à un produit
|
||||||
|
public class GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
public int WarehouseId { get; set; }
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public string WarehouseName { get; set; } = string.Empty;
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
namespace API.DTO.Supplier.Request;
|
namespace PyroFetes.DTO.Supplier.Request;
|
||||||
|
|
||||||
public class CreateSupplierDto
|
public class CreateSupplierDto
|
||||||
{
|
{
|
||||||
@@ -8,4 +8,13 @@ public class CreateSupplierDto
|
|||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
// Produits que ce fournisseur fournit
|
||||||
|
public List<SupplierProductPriceDto>? Products { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SupplierProductPriceDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public decimal SellingPrice { get; set; }
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
namespace API.DTO.Supplier.Request;
|
namespace PyroFetes.DTO.Supplier.Request;
|
||||||
|
|
||||||
public class UpdateSupplierDto
|
public class UpdateSupplierDto
|
||||||
{
|
{
|
||||||
@@ -9,4 +9,6 @@ public class UpdateSupplierDto
|
|||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
public List<SupplierProductPriceDto>? Products { get; set; }
|
||||||
}
|
}
|
@@ -1,4 +1,6 @@
|
|||||||
namespace API.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Supplier.Response;
|
||||||
|
|
||||||
public class GetSupplierDto
|
public class GetSupplierDto
|
||||||
{
|
{
|
||||||
@@ -9,4 +11,14 @@ public class GetSupplierDto
|
|||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
// Liste des produits liés avec leur prix fournisseur
|
||||||
|
public List<SupplierProductPriceDto> Products { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetSupplierProductDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
public decimal SellingPrice { get; set; }
|
||||||
}
|
}
|
@@ -2,11 +2,20 @@
|
|||||||
|
|
||||||
public class CreateWarehouseDto
|
public class CreateWarehouseDto
|
||||||
{
|
{
|
||||||
public string Name {get; set;}
|
public string Name { get; set; }
|
||||||
public int MaxWeight {get; set;}
|
public int MaxWeight { get; set; }
|
||||||
public int Current {get; set;}
|
public int Current { get; set; }
|
||||||
public int MinWeight {get; set;}
|
public int MinWeight { get; set; }
|
||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
// Liste des produits à stocker dans cet entrepôt
|
||||||
|
public List<CreateWarehouseProductDto>? Products { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateWarehouseProductDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
@@ -2,12 +2,20 @@
|
|||||||
|
|
||||||
public class UpdateWarehouseDto
|
public class UpdateWarehouseDto
|
||||||
{
|
{
|
||||||
public int Id {get; set;}
|
public int Id { get; set; }
|
||||||
public string Name {get; set;}
|
public string Name { get; set; }
|
||||||
public int MaxWeight {get; set;}
|
public int MaxWeight { get; set; }
|
||||||
public int Current {get; set;}
|
public int Current { get; set; }
|
||||||
public int MinWeight {get; set;}
|
public int MinWeight { get; set; }
|
||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
public List<UpdateWarehouseProductDto>? Products { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateWarehouseProductDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
@@ -2,12 +2,21 @@
|
|||||||
|
|
||||||
public class GetWarehouseDto
|
public class GetWarehouseDto
|
||||||
{
|
{
|
||||||
public int Id {get; set;}
|
public int Id { get; set; }
|
||||||
public string Name {get; set;}
|
public string Name { get; set; }
|
||||||
public int MaxWeight {get; set;}
|
public int MaxWeight { get; set; }
|
||||||
public int Current {get; set;}
|
public int Current { get; set; }
|
||||||
public int MinWeight {get; set;}
|
public int MinWeight { get; set; }
|
||||||
public string Adress { get; set; }
|
public string Adress { get; set; }
|
||||||
public int ZipCode { get; set; }
|
public int ZipCode { get; set; }
|
||||||
public string City { get; set; }
|
public string City { get; set; }
|
||||||
|
|
||||||
|
public List<WarehouseProductDto>? Products { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WarehouseProductDto
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public string? ProductName { get; set; }
|
||||||
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
using PyroFetes.DTO.Brand.Request;
|
using API.DTO.Brand.Request;
|
||||||
using PyroFetes.DTO.Brand.Response;
|
using API.DTO.Brand.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Brand;
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using PyroFetes.DTO.Brand.Response;
|
using API.DTO.Brand.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using PyroFetes.DTO.Brand.Response;
|
using API.DTO.Brand.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using PyroFetes.DTO.Brand.Request;
|
using API.DTO.Brand.Request;
|
||||||
using PyroFetes.DTO.Brand.Response;
|
using API.DTO.Brand.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Brand;
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
@@ -8,7 +8,7 @@ public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/brands");
|
Put("/api/brands");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using PyroFetes.DTO.Classification.Request;
|
using API.DTO.Classification.Request;
|
||||||
using PyroFetes.DTO.Classification.Response;
|
using API.DTO.Classification.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Classification;
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using PyroFetes.DTO.Classification.Response;
|
using API.DTO.Classification.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
using PyroFetes.DTO.Classification.Response;
|
using API.DTO.Classification.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using PyroFetes.DTO.Classification.Request;
|
using API.DTO.Classification.Request;
|
||||||
using PyroFetes.DTO.Classification.Response;
|
using API.DTO.Classification.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Classification;
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
@@ -8,7 +8,7 @@ public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/classifications");
|
Put("/api/classifications");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
using PyroFetes.DTO.Color.Request;
|
using API.DTO.Color.Request;
|
||||||
using PyroFetes.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class CreateColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<CreateColorDto, GetColorDto>
|
public class CreateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateColorDto, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/color/create");
|
Post("/color/create");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ public class CreateColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Cre
|
|||||||
Label = req.Label,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Colors.Add(color);
|
pyrofetesdbcontext.Colors.Add(color);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Added Color");
|
Console.WriteLine("Added Color");
|
||||||
|
|
||||||
GetColorDto responseDto = new()
|
GetColorDto responseDto = new()
|
||||||
|
@@ -8,17 +8,17 @@ public class DeleteColorRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<DeleteColorRequest>
|
public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteColorRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/colors/{@id}", x => new { x.Id });
|
Delete("/colors/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? colorToDelete = await appDbContext
|
Models.Color? colorToDelete = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ public class DeleteColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Del
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Colors.Remove(colorToDelete);
|
pyrofetesdbcontext.Colors.Remove(colorToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
using PyroFetes.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class GetAllColorsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest<List<GetColorDto>>
|
public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetColorDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/colors");
|
Get("/colors");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetColorDto> responseDto = await appDbContext.Colors
|
List<GetColorDto> responseDto = await pyrofetesdbcontext.Colors
|
||||||
.Select(a => new GetColorDto
|
.Select(a => new GetColorDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using PyroFetes.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
@@ -10,23 +9,23 @@ public class GetColorRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<GetColorRequest, GetColorDto>
|
public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetColorRequest, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/colors/{@id}", x => new { x.Id});
|
Get("/colors/{@id}", x => new { x.Id});
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? color = await appDbContext
|
Models.Color? color = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (color == null)
|
if (color == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucune couleur avec l'ID {req.Id} trouvé.");
|
Console.WriteLine("Aucune couleur avec l'ID {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,34 +1,33 @@
|
|||||||
using PyroFetes.DTO.Color.Request;
|
using API.DTO.Color.Request;
|
||||||
using PyroFetes.DTO.Color.Response;
|
using API.DTO.Color.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Color;
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
public class UpdateColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint<UpdateColorDto, GetColorDto>
|
public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateColorDto, GetColorDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/colors/{@id}", x => new { x.Id });
|
Put("/colors/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Color? colorToEdit = await appDbContext
|
Models.Color? colorToEdit = await pyrofetesdbcontext
|
||||||
.Colors
|
.Colors
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (colorToEdit == null)
|
if (colorToEdit == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucune couleur avec l'id {req.Id} trouvé.");
|
Console.WriteLine("Aucune couleur avec l'id {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
colorToEdit.Label = req.Label;
|
colorToEdit.Label = req.Label;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetColorDto responseDto = new()
|
GetColorDto responseDto = new()
|
||||||
{
|
{
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
using PyroFetes.DTO.Effect.Request;
|
using API.DTO.Effect.Request;
|
||||||
using PyroFetes.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
|
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class CreateEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<CreateEffectDto, GetEffectDto>
|
public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateEffectDto, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/effect/create");
|
Post("/effect/create");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ public class CreateEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Cr
|
|||||||
Label = req.Label,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Effects.Add(effect);
|
pyrofetesdbcontext.Effects.Add(effect);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Effect added");
|
Console.WriteLine("Effect added");
|
||||||
|
|
||||||
GetEffectDto responseDto = new()
|
GetEffectDto responseDto = new()
|
||||||
|
@@ -7,17 +7,17 @@ public class DeleteEffectRequest
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
public class DeleteEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<DeleteEffectRequest>
|
public class DeleteEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteEffectRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/effects/{@id}", x => new { x.Id });
|
Delete("/effects/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effectToDelete = await appDbContext
|
Models.Effect? effectToDelete = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ public class DeleteEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<De
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Effects.Remove(effectToDelete);
|
pyrofetesdbcontext.Effects.Remove(effectToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
using PyroFetes.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class GetAllEffectsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest<List<GetEffectDto>>
|
public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetEffectDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/effects");
|
Get("/effects");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetEffectDto> responseDto = await appDbContext.Effects
|
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects
|
||||||
.Select(a => new GetEffectDto
|
.Select(a => new GetEffectDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using PyroFetes.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
@@ -10,23 +9,23 @@ public class GetEffectRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<GetEffectRequest, GetEffectDto>
|
public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetEffectRequest, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/effect/{@id}", x => new { x.Id });
|
Get("/effect/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effect = await appDbContext
|
Models.Effect? effect = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (effect == null)
|
if (effect == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé.");
|
Console.WriteLine("Aucun effet avec l'ID {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1,34 +1,33 @@
|
|||||||
using PyroFetes.DTO.Effect.Request;
|
using API.DTO.Effect.Request;
|
||||||
using PyroFetes.DTO.Effect.Response;
|
using API.DTO.Effect.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Effect;
|
namespace PyroFetes.Endpoints.Effect;
|
||||||
|
|
||||||
public class UpdateEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<UpdateEffectDto, GetEffectDto>
|
public class UpdateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateEffectDto, GetEffectDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/effect/{@id}", x => new { x.Id });
|
Put("/effect/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Effect? effectToEdit = await appDbContext
|
Models.Effect? effectToEdit = await pyrofetesdbcontext
|
||||||
.Effects
|
.Effects
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (effectToEdit == null)
|
if (effectToEdit == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun effet avec l'id {req.Id} trouvé.");
|
Console.WriteLine("Aucun effet avec l'id {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
effectToEdit.Label = req.Label;
|
effectToEdit.Label = req.Label;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetEffectDto responseDto = new()
|
GetEffectDto responseDto = new()
|
||||||
{
|
{
|
||||||
|
@@ -1,33 +1,34 @@
|
|||||||
using PyroFetes.DTO.Material.Request;
|
using API.DTO.Material.Request;
|
||||||
using PyroFetes.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class CreateMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<CreateMaterialDto, GetMaterialDto>
|
public class CreateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMaterialDto, GetMaterialDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/material/create");
|
Post("/material/create");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material material = new()
|
Models.Material quantity = new()
|
||||||
{
|
{
|
||||||
Label = req.Label,
|
Name = req.Label,
|
||||||
Quantity = req.Quantity,
|
Quantity = req.Quantity,
|
||||||
WarehouseId = req.WarehouseId,
|
WarehouseId = req.WarehouseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
appDbContext.Materials.Add(material);
|
pyrofetesdbcontext.Materials.Add(quantity);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
Console.WriteLine("Material added");
|
Console.WriteLine("Material added");
|
||||||
|
|
||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
Id = material.Id,
|
Id = quantity.Id,
|
||||||
WarehouseId = material.WarehouseId,
|
WarehouseId = quantity.WarehouseId,
|
||||||
Label = req.Label,
|
Label = req.Label,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -6,17 +6,17 @@ public class DeleteMaterialRequest
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
public class DeleteMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<DeleteMaterialRequest>
|
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete("/api/materials/{@id}", x => new { x.Id });
|
Delete("/materials/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? materialToDelete = await appDbContext
|
Models.Material? materialToDelete = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ public class DeleteMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appDbContext.Materials.Remove(materialToDelete);
|
pyrofetesdbcontext.Materials.Remove(materialToDelete);
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
using PyroFetes.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class GetAllMaterialsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/material");
|
Get("/material");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetMaterialDto> responseDto = await appDbContext.Materials
|
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
|
||||||
.Select(a => new GetMaterialDto
|
.Select(a => new GetMaterialDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
Label = a.Label,
|
Label = a.Name,
|
||||||
Quantity = a.Quantity,
|
Quantity = a.Quantity,
|
||||||
WarehouseId = a.WarehouseId,
|
WarehouseId = a.WarehouseId,
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using PyroFetes.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
@@ -10,17 +9,17 @@ public class GetMaterialRequest
|
|||||||
public int Id { get; set; }
|
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()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/material/{@id}", x => new { x.Id });
|
Get("/material/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? material = await appDbContext
|
Models.Material? material = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<Get
|
|||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
Id = material.Id,
|
Id = material.Id,
|
||||||
Label = material.Label,
|
Label = material.Name,
|
||||||
WarehouseId = material.WarehouseId,
|
WarehouseId = material.WarehouseId,
|
||||||
};
|
};
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
@@ -1,35 +1,34 @@
|
|||||||
using PyroFetes.DTO.Material.Request;
|
using API.DTO.Material.Request;
|
||||||
using PyroFetes.DTO.Material.Response;
|
using API.DTO.Material.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Material;
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
|
||||||
public class UpdateMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
|
public class UpdateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put("/api/material/{@id}", x => new { x.Id });
|
Put("/material/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Material? materialToEdit = await appDbContext
|
Models.Material? materialToEdit = await pyrofetesdbcontext
|
||||||
.Materials
|
.Materials
|
||||||
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (materialToEdit == null)
|
if (materialToEdit == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun matériel avec l'id {req.Id} trouvé.");
|
Console.WriteLine("Aucun matériel avec l'id {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
materialToEdit.Label = req.Label;
|
materialToEdit.Name = req.Label;
|
||||||
materialToEdit.WarehouseId = req.WarehouseId;
|
materialToEdit.WarehouseId = req.WarehouseId;
|
||||||
await appDbContext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetMaterialDto responseDto = new()
|
GetMaterialDto responseDto = new()
|
||||||
{
|
{
|
||||||
|
@@ -8,7 +8,7 @@ public class UpdateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/movements");
|
Put("/api/movements");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,15 @@
|
|||||||
using FastEndpoints;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Product.Request;
|
using PyroFetes.DTO.Product.Request;
|
||||||
using PyroFetes.DTO.Product.Response;
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Product;
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateProductDto, GetProductDto>
|
public class CreateProductEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<CreateProductDto, GetProductDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +19,7 @@ public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateProductDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateProductDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Product product = new ()
|
var product = new Models.Product
|
||||||
{
|
{
|
||||||
References = req.References,
|
References = req.References,
|
||||||
Name = req.Name!,
|
Name = req.Name!,
|
||||||
@@ -30,12 +35,47 @@ public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
|
|||||||
ClassificationId = req.ClassificationId
|
ClassificationId = req.ClassificationId
|
||||||
};
|
};
|
||||||
|
|
||||||
pyrofetesdbcontext.Products.Add(product);
|
db.Products.Add(product);
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
Console.WriteLine("Product créé avec succès !");
|
// Ajout des fournisseurs liés
|
||||||
|
if (req.Suppliers is not null && req.Suppliers.Any())
|
||||||
|
{
|
||||||
|
foreach (var s in req.Suppliers)
|
||||||
|
{
|
||||||
|
var price = new Price
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
};
|
||||||
|
db.Prices.Add(price);
|
||||||
|
}
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
GetProductDto responseDto = new ()
|
// Ajout des entrepôts liés
|
||||||
|
if (req.Warehouses is not null && req.Warehouses.Any())
|
||||||
|
{
|
||||||
|
foreach (var w in req.Warehouses)
|
||||||
|
{
|
||||||
|
var exists = await db.Warehouses.AnyAsync(x => x.Id == w.WarehouseId, ct);
|
||||||
|
if (!exists)
|
||||||
|
continue; // sécurité : on ignore les warehouses inexistants
|
||||||
|
|
||||||
|
var warehouseProduct = new WarehouseProduct
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity
|
||||||
|
};
|
||||||
|
db.WarehouseProducts.Add(warehouseProduct);
|
||||||
|
}
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construction de la réponse
|
||||||
|
var response = new GetProductDto
|
||||||
{
|
{
|
||||||
Id = product.Id,
|
Id = product.Id,
|
||||||
Reference = req.References,
|
Reference = req.References,
|
||||||
@@ -49,9 +89,20 @@ public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
|
|||||||
Image = req.Image,
|
Image = req.Image,
|
||||||
Link = req.Link,
|
Link = req.Link,
|
||||||
ProductCategoryId = req.ProductCategoryId,
|
ProductCategoryId = req.ProductCategoryId,
|
||||||
ClassificationId = req.ClassificationId
|
ClassificationId = req.ClassificationId,
|
||||||
|
Suppliers = req.Suppliers?.Select(s => new ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
}).ToList() ?? new(),
|
||||||
|
Warehouses = req.Warehouses?.Select(w => new GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity,
|
||||||
|
WarehouseName = db.Warehouses.FirstOrDefault(x => x.Id == w.WarehouseId)?.Name ?? string.Empty
|
||||||
|
}).ToList() ?? new()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Product;
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ public class DeleteProductRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteProductRequest>
|
public class DeleteProductEndpoint(PyroFetesDbContext db) : Endpoint<DeleteProductRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -18,19 +19,40 @@ public class DeleteProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteProductRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteProductRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Product? productToDelete = await pyrofetesdbcontext
|
// Récupérer le produit
|
||||||
.Products
|
var productToDelete = await db.Products
|
||||||
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
|
||||||
|
|
||||||
if (productToDelete == null)
|
if (productToDelete is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
|
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pyrofetesdbcontext.Products.Remove(productToDelete);
|
// Supprimer les liaisons Price
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
var relatedPrices = await db.Prices
|
||||||
|
.Where(p => p.ProductId == req.Id)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
if (relatedPrices.Any())
|
||||||
|
{
|
||||||
|
db.Prices.RemoveRange(relatedPrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer les liaisons WarehouseProduct
|
||||||
|
var relatedWarehouseProducts = await db.WarehouseProducts
|
||||||
|
.Where(wp => wp.ProductId == req.Id)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
if (relatedWarehouseProducts.Any())
|
||||||
|
{
|
||||||
|
db.WarehouseProducts.RemoveRange(relatedWarehouseProducts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer le produit
|
||||||
|
db.Products.Remove(productToDelete);
|
||||||
|
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
Console.WriteLine($"Produit {req.Id}, ses prix et ses entrepôts liés ont été supprimés avec succès.");
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,15 @@
|
|||||||
using FastEndpoints;
|
using PyroFetes.DTO.Product.Request;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PyroFetes.DTO.Product.Response;
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Product;
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetProductDto>>
|
public class GetAllProductsEndpoint(PyroFetesDbContext db)
|
||||||
|
: EndpointWithoutRequest<List<GetProductDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,8 +19,14 @@ public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetProductDto> responseDto = await pyrofetesdbcontext.Products
|
// Inclure toutes les relations nécessaires : Prices + WarehouseProducts + Warehouse
|
||||||
.Select(p => new GetProductDto()
|
var products = await db.Products
|
||||||
|
.Include(p => p.Prices)
|
||||||
|
.Include(p => p.WarehouseProducts)
|
||||||
|
.ThenInclude(wp => wp.Warehouse)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
var responseDto = products.Select(p => new GetProductDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Reference = p.References,
|
Reference = p.References,
|
||||||
@@ -29,11 +40,23 @@ public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
Image = p.Image,
|
Image = p.Image,
|
||||||
Link = p.Link,
|
Link = p.Link,
|
||||||
ClassificationId = p.ClassificationId,
|
ClassificationId = p.ClassificationId,
|
||||||
ClassificationLabel = p.Classification!.Label,
|
|
||||||
ProductCategoryId = p.ProductCategoryId,
|
ProductCategoryId = p.ProductCategoryId,
|
||||||
ProductCategoryLabel = p.ProductCategory!.Label,
|
|
||||||
}
|
// Liste des fournisseurs liés via Price
|
||||||
).ToListAsync(ct);
|
Suppliers = p.Prices.Select(pr => new ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
SupplierId = pr.SupplierId,
|
||||||
|
SellingPrice = pr.SellingPrice
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
// Liste des entrepôts via WarehouseProduct
|
||||||
|
Warehouses = p.WarehouseProducts.Select(wp => new GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
WarehouseId = wp.WarehouseId,
|
||||||
|
WarehouseName = wp.Warehouse?.Name ?? string.Empty,
|
||||||
|
Quantity = wp.Quantity
|
||||||
|
}).ToList()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
using FastEndpoints;
|
using PyroFetes.DTO.Product.Request;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PyroFetes.DTO.Product.Response;
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Product;
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
@@ -9,20 +13,23 @@ public class GetProductRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GetProductEndpoint(PyroFetesDbContext db)
|
||||||
public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetProductRequest, GetProductDto>
|
: Endpoint<GetProductRequest, GetProductDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/api/product/{@id}", x => new { x.Id });
|
Get("/api/products/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetProductRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetProductRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Product? product = await pyrofetesdbcontext
|
// Inclure toutes les relations : Prices + WarehouseProducts + Warehouse
|
||||||
.Products.Include(product => product.Classification).Include(product => product.ProductCategory)
|
var product = await db.Products
|
||||||
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
|
.Include(p => p.Prices)
|
||||||
|
.Include(p => p.WarehouseProducts)
|
||||||
|
.ThenInclude(wp => wp.Warehouse)
|
||||||
|
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
|
||||||
|
|
||||||
if (product == null)
|
if (product == null)
|
||||||
{
|
{
|
||||||
@@ -31,7 +38,7 @@ public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetProductDto responseDto = new()
|
var responseDto = new GetProductDto
|
||||||
{
|
{
|
||||||
Id = product.Id,
|
Id = product.Id,
|
||||||
Reference = product.References,
|
Reference = product.References,
|
||||||
@@ -45,9 +52,22 @@ public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint
|
|||||||
Image = product.Image,
|
Image = product.Image,
|
||||||
Link = product.Link,
|
Link = product.Link,
|
||||||
ClassificationId = product.ClassificationId,
|
ClassificationId = product.ClassificationId,
|
||||||
ClassificationLabel = product.Classification!.Label,
|
|
||||||
ProductCategoryId = product.ProductCategoryId,
|
ProductCategoryId = product.ProductCategoryId,
|
||||||
ProductCategoryLabel = product.ProductCategory!.Label,
|
|
||||||
|
// Fournisseurs liés via Price
|
||||||
|
Suppliers = product.Prices.Select(pr => new ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
SupplierId = pr.SupplierId,
|
||||||
|
SellingPrice = pr.SellingPrice
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
// Entrepôts liés via WarehouseProduct
|
||||||
|
Warehouses = product.WarehouseProducts.Select(wp => new GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
WarehouseId = wp.WarehouseId,
|
||||||
|
WarehouseName = wp.Warehouse?.Name ?? string.Empty,
|
||||||
|
Quantity = wp.Quantity
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
@@ -1,47 +1,90 @@
|
|||||||
using FastEndpoints;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Product.Request;
|
using PyroFetes.DTO.Product.Request;
|
||||||
using PyroFetes.DTO.Product.Response;
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Product;
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
public class UpdateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<UpdateProductDto, GetProductDto>
|
// Endpoint permettant de mettre à jour un produit existant
|
||||||
|
public class UpdateProductEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<UpdateProductDto, GetProductDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
// Route HTTP PUT avec un paramètre d'identifiant dans l'URL
|
||||||
Put("/api/products/{@id}", x => new { x.Id });
|
Put("/api/products/{@id}", x => new { x.Id });
|
||||||
|
|
||||||
|
// Autorise les requêtes anonymes (sans authentification)
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Product? productToEdit = await pyrofetesdbcontext
|
// Recherche du produit à mettre à jour, en incluant les relations Prices et WarehouseProducts
|
||||||
.Products
|
var product = await db.Products
|
||||||
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
|
.Include(p => p.Prices)
|
||||||
|
.Include(p => p.WarehouseProducts)
|
||||||
|
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
|
||||||
|
|
||||||
if (productToEdit == null)
|
// Si le produit n'existe pas, on retourne une réponse 404
|
||||||
|
if (product is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
|
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
productToEdit.References = req.Reference;
|
// Mise à jour des propriétés principales du produit
|
||||||
productToEdit.Name = req.Name;
|
product.References = req.References;
|
||||||
productToEdit.Duration = req.Duration;
|
product.Name = req.Name;
|
||||||
productToEdit.Caliber = req.Caliber;
|
product.Duration = req.Duration;
|
||||||
productToEdit.ApprovalNumber = req.ApprovalNumber;
|
product.Caliber = req.Caliber;
|
||||||
productToEdit.Weight = req.Weight;
|
product.ApprovalNumber = req.ApprovalNumber;
|
||||||
productToEdit.Nec = req.Nec;
|
product.Weight = req.Weight;
|
||||||
productToEdit.SellingPrice = req.SellingPrice;
|
product.Nec = req.Nec;
|
||||||
productToEdit.Image = req.Image;
|
product.SellingPrice = req.SellingPrice;
|
||||||
productToEdit.Link = req.Link;
|
product.Image = req.Image;
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
product.Link = req.Link;
|
||||||
|
product.ClassificationId = req.ClassificationId;
|
||||||
|
product.ProductCategoryId = req.ProductCategoryId;
|
||||||
|
|
||||||
GetProductDto responseDto = new()
|
// Mise à jour des prix fournisseurs associés
|
||||||
|
// On supprime les anciens enregistrements pour les remplacer
|
||||||
|
db.Prices.RemoveRange(product.Prices);
|
||||||
|
foreach (var s in req.Suppliers)
|
||||||
{
|
{
|
||||||
Id = req.Id,
|
db.Prices.Add(new Price
|
||||||
Reference = req.Reference,
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des entrepôts associés
|
||||||
|
// On supprime les anciens liens avant d'ajouter les nouveaux
|
||||||
|
db.WarehouseProducts.RemoveRange(product.WarehouseProducts);
|
||||||
|
foreach (var w in req.Warehouses)
|
||||||
|
{
|
||||||
|
db.WarehouseProducts.Add(new WarehouseProduct
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sauvegarde des modifications dans la base de données
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// Construction de la réponse renvoyée au client
|
||||||
|
// On reconstruit les listes Suppliers et Warehouses au bon format de DTO
|
||||||
|
var response = new GetProductDto
|
||||||
|
{
|
||||||
|
Id = product.Id,
|
||||||
|
Reference = req.References,
|
||||||
Name = req.Name,
|
Name = req.Name,
|
||||||
Duration = req.Duration,
|
Duration = req.Duration,
|
||||||
Caliber = req.Caliber,
|
Caliber = req.Caliber,
|
||||||
@@ -50,9 +93,27 @@ public class UpdateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpo
|
|||||||
Nec = req.Nec,
|
Nec = req.Nec,
|
||||||
SellingPrice = req.SellingPrice,
|
SellingPrice = req.SellingPrice,
|
||||||
Image = req.Image,
|
Image = req.Image,
|
||||||
Link = req.Link
|
Link = req.Link,
|
||||||
|
ClassificationId = req.ClassificationId,
|
||||||
|
ProductCategoryId = req.ProductCategoryId,
|
||||||
|
|
||||||
|
// Mapping des fournisseurs pour la réponse
|
||||||
|
Suppliers = req.Suppliers.Select(s => new ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
// Mapping des entrepôts pour la réponse
|
||||||
|
Warehouses = req.Warehouses.Select(w => new GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity,
|
||||||
|
WarehouseName = db.Warehouses.FirstOrDefault(x => x.Id == w.WarehouseId)?.Name ?? string.Empty
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
// Envoi de la réponse HTTP 200 avec les données du produit mis à jour
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +1,13 @@
|
|||||||
using API.DTO.Supplier.Request;
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
using API.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Supplier;
|
namespace PyroFetes.Endpoints.Supplier;
|
||||||
|
|
||||||
public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateSupplierDto, GetSupplierDto>
|
public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||||
|
: Endpoint<CreateSupplierDto, GetSupplierDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,8 +17,7 @@ public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
// Création d'un nouvel objet Supplier
|
var supplier = new Models.Supplier
|
||||||
Models.Supplier supplier = new()
|
|
||||||
{
|
{
|
||||||
Name = req.Name,
|
Name = req.Name,
|
||||||
Email = req.Email,
|
Email = req.Email,
|
||||||
@@ -25,14 +27,26 @@ public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
City = req.City
|
City = req.City
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ajout à la base et sauvegarde
|
|
||||||
pyrofetesdbcontext.Suppliers.Add(supplier);
|
pyrofetesdbcontext.Suppliers.Add(supplier);
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
Console.WriteLine("Fournisseur créé avec succès !");
|
// Ajout des liaisons Price si produits renseignés
|
||||||
|
if (req.Products is not null && req.Products.Any())
|
||||||
|
{
|
||||||
|
foreach (var p in req.Products)
|
||||||
|
{
|
||||||
|
var price = new Price
|
||||||
|
{
|
||||||
|
SupplierId = supplier.Id,
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
SellingPrice = p.SellingPrice
|
||||||
|
};
|
||||||
|
pyrofetesdbcontext.Prices.Add(price);
|
||||||
|
}
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
// Préparation de la réponse
|
var response = new GetSupplierDto
|
||||||
GetSupplierDto responseDto = new()
|
|
||||||
{
|
{
|
||||||
Id = supplier.Id,
|
Id = supplier.Id,
|
||||||
Name = supplier.Name,
|
Name = supplier.Name,
|
||||||
@@ -43,6 +57,6 @@ public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
City = supplier.City
|
City = supplier.City
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Supplier;
|
namespace PyroFetes.Endpoints.Supplier;
|
||||||
|
|
||||||
@@ -18,19 +19,32 @@ public class DeleteSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
|
|
||||||
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Supplier? supplierToDelete = await pyrofetesdbcontext
|
var supplierToDelete = await pyrofetesdbcontext
|
||||||
.Suppliers
|
.Suppliers
|
||||||
.SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||||
|
|
||||||
if (supplierToDelete == null)
|
if (supplierToDelete is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé.");
|
Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supprimer les liaisons Price avant le fournisseur
|
||||||
|
var relatedPrices = await pyrofetesdbcontext.Prices
|
||||||
|
.Where(p => p.SupplierId == req.Id)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
if (relatedPrices.Any())
|
||||||
|
{
|
||||||
|
pyrofetesdbcontext.Prices.RemoveRange(relatedPrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer le fournisseur
|
||||||
pyrofetesdbcontext.Suppliers.Remove(supplierToDelete);
|
pyrofetesdbcontext.Suppliers.Remove(supplierToDelete);
|
||||||
|
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
Console.WriteLine($"Fournisseur {req.Id} et ses prix liés supprimés avec succès.");
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
using API.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Response;
|
||||||
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Supplier;
|
namespace PyroFetes.Endpoints.Supplier;
|
||||||
|
|
||||||
public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetSupplierDto>>
|
public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||||
|
: EndpointWithoutRequest<List<GetSupplierDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,8 +17,11 @@ public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetSupplierDto> responseDto = await pyrofetesdbcontext.Suppliers
|
var suppliers = await pyrofetesdbcontext.Suppliers
|
||||||
.Select(s => new GetSupplierDto
|
.Include(s => s.Prices)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
var responseDto = suppliers.Select(s => new GetSupplierDto
|
||||||
{
|
{
|
||||||
Id = s.Id,
|
Id = s.Id,
|
||||||
Name = s.Name!,
|
Name = s.Name!,
|
||||||
@@ -23,9 +29,15 @@ public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
PhoneNumber = s.Phone!,
|
PhoneNumber = s.Phone!,
|
||||||
Adress = s.Address!,
|
Adress = s.Address!,
|
||||||
ZipCode = s.ZipCode,
|
ZipCode = s.ZipCode,
|
||||||
City = s.City!
|
City = s.City!,
|
||||||
})
|
|
||||||
.ToListAsync(ct);
|
// 🔹 Liste des produits liés via Price
|
||||||
|
Products = s.Prices.Select(pr => new SupplierProductPriceDto
|
||||||
|
{
|
||||||
|
ProductId = pr.ProductId,
|
||||||
|
SellingPrice = pr.SellingPrice
|
||||||
|
}).ToList()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using API.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
|
using PyroFetes.DTO.Supplier.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@@ -9,7 +10,8 @@ public class GetSupplierRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetSupplierRequest, GetSupplierDto>
|
public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||||
|
: Endpoint<GetSupplierRequest, GetSupplierDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -19,9 +21,9 @@ public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
|||||||
|
|
||||||
public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Supplier? supplier = await pyrofetesdbcontext
|
var supplier = await pyrofetesdbcontext.Suppliers
|
||||||
.Suppliers
|
.Include(s => s.Prices)
|
||||||
.SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||||
|
|
||||||
if (supplier == null)
|
if (supplier == null)
|
||||||
{
|
{
|
||||||
@@ -30,7 +32,7 @@ public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetSupplierDto responseDto = new()
|
var responseDto = new GetSupplierDto
|
||||||
{
|
{
|
||||||
Id = supplier.Id,
|
Id = supplier.Id,
|
||||||
Name = supplier.Name!,
|
Name = supplier.Name!,
|
||||||
@@ -38,7 +40,14 @@ public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
|||||||
PhoneNumber = supplier.Phone!,
|
PhoneNumber = supplier.Phone!,
|
||||||
Adress = supplier.Address!,
|
Adress = supplier.Address!,
|
||||||
ZipCode = supplier.ZipCode,
|
ZipCode = supplier.ZipCode,
|
||||||
City = supplier.City!
|
City = supplier.City!,
|
||||||
|
|
||||||
|
// Produits liés
|
||||||
|
Products = supplier.Prices.Select(p => new SupplierProductPriceDto
|
||||||
|
{
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
SellingPrice = p.SellingPrice
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
using API.DTO.Supplier.Request;
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
using API.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Supplier;
|
namespace PyroFetes.Endpoints.Supplier;
|
||||||
|
|
||||||
@@ -15,18 +16,16 @@ public class UpdateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Supplier? supplierToEdit = await pyrofetesdbcontext
|
var supplierToEdit = await pyrofetesdbcontext
|
||||||
.Suppliers
|
.Suppliers
|
||||||
.SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct);
|
.Include(s => s.Prices)
|
||||||
|
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||||
|
|
||||||
if (supplierToEdit == null)
|
if (supplierToEdit is null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé.");
|
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise à jour des propriétés
|
|
||||||
supplierToEdit.Name = req.Name;
|
supplierToEdit.Name = req.Name;
|
||||||
supplierToEdit.Email = req.Email;
|
supplierToEdit.Email = req.Email;
|
||||||
supplierToEdit.Phone = req.PhoneNumber;
|
supplierToEdit.Phone = req.PhoneNumber;
|
||||||
@@ -34,9 +33,28 @@ public class UpdateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
supplierToEdit.ZipCode = req.ZipCode;
|
supplierToEdit.ZipCode = req.ZipCode;
|
||||||
supplierToEdit.City = req.City;
|
supplierToEdit.City = req.City;
|
||||||
|
|
||||||
|
if (req.Products is not null)
|
||||||
|
{
|
||||||
|
// Supprimer les anciennes liaisons
|
||||||
|
var existingPrices = pyrofetesdbcontext.Prices
|
||||||
|
.Where(p => p.SupplierId == supplierToEdit.Id);
|
||||||
|
pyrofetesdbcontext.Prices.RemoveRange(existingPrices);
|
||||||
|
|
||||||
|
// Ajouter les nouvelles liaisons
|
||||||
|
foreach (var p in req.Products)
|
||||||
|
{
|
||||||
|
pyrofetesdbcontext.Prices.Add(new Price
|
||||||
|
{
|
||||||
|
SupplierId = supplierToEdit.Id,
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
SellingPrice = p.SellingPrice
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetSupplierDto responseDto = new()
|
var response = new GetSupplierDto
|
||||||
{
|
{
|
||||||
Id = supplierToEdit.Id,
|
Id = supplierToEdit.Id,
|
||||||
Name = supplierToEdit.Name,
|
Name = supplierToEdit.Name,
|
||||||
@@ -47,6 +65,6 @@ public class UpdateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
|
|||||||
City = supplierToEdit.City
|
City = supplierToEdit.City
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +1,12 @@
|
|||||||
using API.DTO.Warehouse.Request;
|
using API.DTO.Warehouse.Request;
|
||||||
using API.DTO.Warehouse.Response;
|
using API.DTO.Warehouse.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Warehouse;
|
namespace PyroFetes.Endpoints.Warehouse;
|
||||||
|
|
||||||
public class CreateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateWarehouseDto, GetWarehouseDto>
|
public class CreateWarehouseEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<CreateWarehouseDto, GetWarehouseDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +16,7 @@ public class CreateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateWarehouseDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateWarehouseDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Warehouse warehouse = new()
|
var warehouse = new Models.Warehouse
|
||||||
{
|
{
|
||||||
Name = req.Name,
|
Name = req.Name,
|
||||||
MaxWeight = req.MaxWeight,
|
MaxWeight = req.MaxWeight,
|
||||||
@@ -25,12 +27,26 @@ public class CreateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
City = req.City
|
City = req.City
|
||||||
};
|
};
|
||||||
|
|
||||||
pyrofetesdbcontext.Warehouses.Add(warehouse);
|
db.Warehouses.Add(warehouse);
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
Console.WriteLine("Entrepôt créé avec succès !");
|
// 🔹 Ajout des produits liés à cet entrepôt
|
||||||
|
if (req.Products is not null && req.Products.Any())
|
||||||
|
{
|
||||||
|
foreach (var p in req.Products)
|
||||||
|
{
|
||||||
|
var warehouseProduct = new WarehouseProduct
|
||||||
|
{
|
||||||
|
WarehouseId = warehouse.Id,
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
Quantity = p.Quantity
|
||||||
|
};
|
||||||
|
db.WarehouseProducts.Add(warehouseProduct);
|
||||||
|
}
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
GetWarehouseDto responseDto = new()
|
var response = new GetWarehouseDto
|
||||||
{
|
{
|
||||||
Id = warehouse.Id,
|
Id = warehouse.Id,
|
||||||
Name = warehouse.Name,
|
Name = warehouse.Name,
|
||||||
@@ -42,6 +58,6 @@ public class CreateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
City = warehouse.City
|
City = warehouse.City
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Warehouse;
|
namespace PyroFetes.Endpoints.Warehouse;
|
||||||
|
|
||||||
@@ -8,18 +9,20 @@ public class DeleteWarehouseRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeleteWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteWarehouseRequest>
|
public class DeleteWarehouseEndpoint(PyroFetesDbContext db) : Endpoint<DeleteWarehouseRequest>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
// L’annotation correcte du paramètre est {id}, pas {@id}
|
||||||
Delete("/api/warehouse/{@id}", x => new { x.Id });
|
Delete("/api/warehouse/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteWarehouseRequest req, CancellationToken ct)
|
public override async Task HandleAsync(DeleteWarehouseRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Warehouse? warehouseToDelete = await pyrofetesdbcontext
|
// On charge aussi les WarehouseProducts liés pour les supprimer proprement
|
||||||
.Warehouses
|
var warehouseToDelete = await db.Warehouses
|
||||||
|
.Include(w => w.WarehouseProducts)
|
||||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (warehouseToDelete == null)
|
if (warehouseToDelete == null)
|
||||||
@@ -29,9 +32,21 @@ public class DeleteWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pyrofetesdbcontext.Warehouses.Remove(warehouseToDelete);
|
// 🔹 Suppression des relations WarehouseProduct avant l'entrepôt
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
var relatedWarehouseProducts = await db.WarehouseProducts
|
||||||
|
.Where(wp => wp.WarehouseId == req.Id)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
if (relatedWarehouseProducts.Any())
|
||||||
|
{
|
||||||
|
db.WarehouseProducts.RemoveRange(relatedWarehouseProducts);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔹 Suppression de l’entrepôt
|
||||||
|
db.Warehouses.Remove(warehouseToDelete);
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
Console.WriteLine($"Entrepôt {warehouseToDelete.Name} (ID {req.Id}) supprimé avec succès.");
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,10 +1,13 @@
|
|||||||
using API.DTO.Warehouse.Response;
|
using API.DTO.Warehouse.Response;
|
||||||
|
using API.DTO.Warehouse.Request;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Warehouse;
|
namespace PyroFetes.Endpoints.Warehouse;
|
||||||
|
|
||||||
public class GetAllWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetWarehouseDto>>
|
public class GetAllWarehouseEndpoint(PyroFetesDbContext db)
|
||||||
|
: EndpointWithoutRequest<List<GetWarehouseDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,8 +17,13 @@ public class GetAllWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetWarehouseDto> responseDto = await pyrofetesdbcontext.Warehouses
|
// 🔹 On inclut les relations avec WarehouseProducts et Product
|
||||||
.Select(w => new GetWarehouseDto
|
var warehouses = await db.Warehouses
|
||||||
|
.Include(w => w.WarehouseProducts)
|
||||||
|
.ThenInclude(wp => wp.Product)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
var response = warehouses.Select(w => new GetWarehouseDto
|
||||||
{
|
{
|
||||||
Id = w.Id,
|
Id = w.Id,
|
||||||
Name = w.Name,
|
Name = w.Name,
|
||||||
@@ -24,10 +32,15 @@ public class GetAllWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
MinWeight = w.MinWeight,
|
MinWeight = w.MinWeight,
|
||||||
Adress = w.Address,
|
Adress = w.Address,
|
||||||
ZipCode = w.ZipCode,
|
ZipCode = w.ZipCode,
|
||||||
City = w.City
|
City = w.City,
|
||||||
})
|
Products = w.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||||
.ToListAsync(ct);
|
{
|
||||||
|
ProductId = wp.ProductId,
|
||||||
|
ProductName = wp.Product?.Name,
|
||||||
|
Quantity = wp.Quantity
|
||||||
|
}).ToList()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
using API.DTO.Warehouse.Response;
|
using API.DTO.Warehouse.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Warehouse;
|
namespace PyroFetes.Endpoints.Warehouse;
|
||||||
|
|
||||||
@@ -9,28 +10,32 @@ public class GetWarehouseRequest
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetWarehouseRequest, GetWarehouseDto>
|
public class GetWarehouseEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<GetWarehouseRequest, GetWarehouseDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
// Pas de "@id" ici, juste {id}
|
||||||
Get("/api/warehouses/{@id}", x => new { x.Id });
|
Get("/api/warehouses/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(GetWarehouseRequest req, CancellationToken ct)
|
public override async Task HandleAsync(GetWarehouseRequest req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Warehouse? warehouse = await pyrofetesdbcontext
|
// 🔹 Inclut les produits associés à cet entrepôt
|
||||||
.Warehouses
|
var warehouse = await db.Warehouses
|
||||||
|
.Include(w => w.WarehouseProducts)
|
||||||
|
.ThenInclude(wp => wp.Product)
|
||||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (warehouse == null)
|
if (warehouse == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé.");
|
Console.WriteLine($" Aucun entrepôt avec l'ID {req.Id} trouvé.");
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWarehouseDto responseDto = new()
|
var response = new GetWarehouseDto
|
||||||
{
|
{
|
||||||
Id = warehouse.Id,
|
Id = warehouse.Id,
|
||||||
Name = warehouse.Name!,
|
Name = warehouse.Name!,
|
||||||
@@ -39,9 +44,15 @@ public class GetWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
|
|||||||
MinWeight = warehouse.MinWeight,
|
MinWeight = warehouse.MinWeight,
|
||||||
Adress = warehouse.Address!,
|
Adress = warehouse.Address!,
|
||||||
ZipCode = warehouse.ZipCode,
|
ZipCode = warehouse.ZipCode,
|
||||||
City = warehouse.City!
|
City = warehouse.City!,
|
||||||
|
Products = warehouse.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||||
|
{
|
||||||
|
ProductId = wp.ProductId,
|
||||||
|
ProductName = wp.Product?.Name,
|
||||||
|
Quantity = wp.Quantity
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,21 +2,25 @@
|
|||||||
using API.DTO.Warehouse.Response;
|
using API.DTO.Warehouse.Response;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Warehouse;
|
namespace PyroFetes.Endpoints.Warehouse;
|
||||||
|
|
||||||
public class UpdateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateWarehouseDto, GetWarehouseDto>
|
public class UpdateWarehouseEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<UpdateWarehouseDto, GetWarehouseDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
// Utilise {id} plutôt que {@id}
|
||||||
Put("/api/warehouses/{@id}", x => new { x.Id });
|
Put("/api/warehouses/{@id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateWarehouseDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateWarehouseDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Models.Warehouse? warehouseToEdit = await pyrofetesdbcontext
|
// 🔹 On inclut les produits existants pour pouvoir les modifier
|
||||||
.Warehouses
|
var warehouseToEdit = await db.Warehouses
|
||||||
|
.Include(w => w.WarehouseProducts)
|
||||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
if (warehouseToEdit == null)
|
if (warehouseToEdit == null)
|
||||||
@@ -26,7 +30,7 @@ public class UpdateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise à jour des champs
|
// 🔹 Mise à jour des champs de base
|
||||||
warehouseToEdit.Name = req.Name;
|
warehouseToEdit.Name = req.Name;
|
||||||
warehouseToEdit.MaxWeight = req.MaxWeight;
|
warehouseToEdit.MaxWeight = req.MaxWeight;
|
||||||
warehouseToEdit.Current = req.Current;
|
warehouseToEdit.Current = req.Current;
|
||||||
@@ -35,9 +39,30 @@ public class UpdateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
warehouseToEdit.ZipCode = req.ZipCode;
|
warehouseToEdit.ZipCode = req.ZipCode;
|
||||||
warehouseToEdit.City = req.City;
|
warehouseToEdit.City = req.City;
|
||||||
|
|
||||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
// 🔹 Gestion des produits associés
|
||||||
|
if (req.Products is not null)
|
||||||
|
{
|
||||||
|
// On supprime les anciens liens pour recréer proprement
|
||||||
|
var existingLinks = warehouseToEdit.WarehouseProducts.ToList();
|
||||||
|
if (existingLinks.Any())
|
||||||
|
db.WarehouseProducts.RemoveRange(existingLinks);
|
||||||
|
|
||||||
GetWarehouseDto responseDto = new()
|
foreach (var p in req.Products)
|
||||||
|
{
|
||||||
|
var newLink = new WarehouseProduct
|
||||||
|
{
|
||||||
|
WarehouseId = warehouseToEdit.Id,
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
Quantity = p.Quantity
|
||||||
|
};
|
||||||
|
db.WarehouseProducts.Add(newLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// 🔹 On renvoie la version mise à jour
|
||||||
|
var response = new GetWarehouseDto
|
||||||
{
|
{
|
||||||
Id = warehouseToEdit.Id,
|
Id = warehouseToEdit.Id,
|
||||||
Name = warehouseToEdit.Name,
|
Name = warehouseToEdit.Name,
|
||||||
@@ -46,9 +71,16 @@ public class UpdateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
|
|||||||
MinWeight = warehouseToEdit.MinWeight,
|
MinWeight = warehouseToEdit.MinWeight,
|
||||||
Adress = warehouseToEdit.Address,
|
Adress = warehouseToEdit.Address,
|
||||||
ZipCode = warehouseToEdit.ZipCode,
|
ZipCode = warehouseToEdit.ZipCode,
|
||||||
City = warehouseToEdit.City
|
City = warehouseToEdit.City,
|
||||||
|
Products = warehouseToEdit.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||||
|
{
|
||||||
|
ProductId = wp.ProductId,
|
||||||
|
ProductName = wp.Product?.Name,
|
||||||
|
Quantity = wp.Quantity
|
||||||
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(responseDto, ct);
|
Console.WriteLine($"Entrepôt {warehouseToEdit.Name} mis à jour avec succès.");
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,13 +4,11 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Availability
|
public class Availability
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required] public DateOnly AvailabilityDate { get; set; }
|
[Required] public DateOnly AvailabilityDate { get; set; }
|
||||||
[Required] public DateOnly DeliveryDate { get; set; }
|
[Required] public DateOnly DeliveryDate { get; set; }
|
||||||
[Required] public DateOnly ExpirationDate { get; set; }
|
[Required] public DateOnly ExpirationDate { get; set; }
|
||||||
[Required] public DateOnly RenewallDate { get; set; }
|
[Required] public DateOnly RenewallDate { get; set; }
|
||||||
|
|
||||||
//Relations
|
|
||||||
public List<StaffAvailability>? StaffAvailabilities { get; set; }
|
public List<StaffAvailability>? StaffAvailabilities { get; set; }
|
||||||
}
|
}
|
@@ -4,11 +4,9 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Brand
|
public class Brand
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Name { get; set; }
|
[Required, MaxLength(100)] public string? Name { get; set; }
|
||||||
[Required] public int ProductId { get; set; }
|
|
||||||
|
|
||||||
//Relations
|
[Required] public int ProductId { get; set; }
|
||||||
[Required] public Product? Product { get; set; }
|
[Required] public Product? Product { get; set; }
|
||||||
}
|
}
|
@@ -4,11 +4,9 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class City
|
public class City
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Name { get; set; }
|
[Required, MaxLength(100)] public string? Name { get; set; }
|
||||||
[Required] public int ZipCode { get; set; }
|
[Required] public int ZipCode { get; set; }
|
||||||
|
|
||||||
//Relations
|
|
||||||
public List<Show>? Shows { get; set; }
|
public List<Show>? Shows { get; set; }
|
||||||
}
|
}
|
@@ -4,10 +4,8 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Classification
|
public class Classification
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Label { get; set; }
|
[Required, MaxLength(100)] public string? Label { get; set; }
|
||||||
|
|
||||||
//Relations
|
|
||||||
public List<Product>? Products { get; set; }
|
public List<Product>? Products { get; set; }
|
||||||
}
|
}
|
@@ -4,10 +4,8 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Color
|
public class Color
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Label { get; set; }
|
[Required, MaxLength(100)] public string? Label { get; set; }
|
||||||
|
|
||||||
//Relations
|
|
||||||
public List<ProductColor>? ProductColors { get; set; }
|
public List<ProductColor>? ProductColors { get; set; }
|
||||||
}
|
}
|
@@ -4,13 +4,11 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Communication
|
public class Communication
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Calling { get; set; }
|
[Required, MaxLength(100)] public string? Calling { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Email { get; set; }
|
[Required, MaxLength(100)] public string? Email { get; set; }
|
||||||
[Required, MaxLength(300)] public string? Meeting { get; set; }
|
[Required, MaxLength(300)] public string? Meeting { get; set; }
|
||||||
|
|
||||||
//Relations
|
|
||||||
[Required] public int ContactId { get; set; }
|
[Required] public int ContactId { get; set; }
|
||||||
public Contact? Contact { get; set; }
|
public Contact? Contact { get; set; }
|
||||||
}
|
}
|
@@ -4,7 +4,6 @@ namespace PyroFetes.Models;
|
|||||||
|
|
||||||
public class Contact
|
public class Contact
|
||||||
{
|
{
|
||||||
//Champs
|
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? LastName { get; set; }
|
[Required, MaxLength(100)] public string? LastName { get; set; }
|
||||||
[Required, MaxLength(100)] public string? FirstName { get; set; }
|
[Required, MaxLength(100)] public string? FirstName { get; set; }
|
||||||
@@ -15,8 +14,6 @@ public class Contact
|
|||||||
[Required, MaxLength(100)] public string? City { get; set; }
|
[Required, MaxLength(100)] public string? City { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Role { get; set; }
|
[Required, MaxLength(100)] public string? Role { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//Relations
|
|
||||||
public Customer? Customer { get; set; }
|
public Customer? Customer { get; set; }
|
||||||
[Required] public int CustomerId { get; set; }
|
[Required] public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ namespace PyroFetes.Models;
|
|||||||
public class Material
|
public class Material
|
||||||
{
|
{
|
||||||
[Key] public int Id {get; set;}
|
[Key] public int Id {get; set;}
|
||||||
[Required, MaxLength(100)] public string? Label {get; set;}
|
[Required, MaxLength(100)] public string? Name {get; set;}
|
||||||
[Required] public int Quantity {get; set;}
|
[Required] public int Quantity {get; set;}
|
||||||
|
|
||||||
[Required] public int WarehouseId {get; set;}
|
[Required] public int WarehouseId {get; set;}
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
||||||
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.20" />
|
<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">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
Reference in New Issue
Block a user