From 964faa0b6b038934fb4aa169c89de40fe6421863 Mon Sep 17 00:00:00 2001 From: reignem Date: Thu, 2 Oct 2025 14:43:34 +0200 Subject: [PATCH] Ajout des Key et Required --- PyroFetes/Models/Brand.cs | 11 +++++---- PyroFetes/Models/Classification.cs | 9 ++++--- PyroFetes/Models/Color.cs | 7 +++--- PyroFetes/Models/Effect.cs | 7 +++--- PyroFetes/Models/Material.cs | 13 +++++----- PyroFetes/Models/Movement.cs | 25 ++++++++++--------- PyroFetes/Models/Price.cs | 6 ++--- PyroFetes/Models/Product.cs | 37 ++++++++++++++-------------- PyroFetes/Models/ProductCategory.cs | 9 ++++--- PyroFetes/Models/ProductColor.cs | 4 +-- PyroFetes/Models/ProductEffect.cs | 4 +-- PyroFetes/Models/Supplier.cs | 17 +++++++------ PyroFetes/Models/Warehouse.cs | 25 ++++++++++--------- PyroFetes/Models/WarehouseProduct.cs | 6 ++--- 14 files changed, 95 insertions(+), 85 deletions(-) diff --git a/PyroFetes/Models/Brand.cs b/PyroFetes/Models/Brand.cs index 7278cec..93b596c 100644 --- a/PyroFetes/Models/Brand.cs +++ b/PyroFetes/Models/Brand.cs @@ -1,12 +1,13 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Brand { - public int Id { get; set; } - public string Name { get; set; } + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string Name { get; set; } - public int ProductId { get; set; } - public Product Product { get; set; } + [Required] public int ProductId { get; set; } + [Required] public Product Product { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Classification.cs b/PyroFetes/Models/Classification.cs index bdc57b2..43be442 100644 --- a/PyroFetes/Models/Classification.cs +++ b/PyroFetes/Models/Classification.cs @@ -1,11 +1,12 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Classification { - public int Id { get; set; } - public string Label { get; set; } + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } - public List Products { get; set; } + [Required] public List Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Color.cs b/PyroFetes/Models/Color.cs index 2654725..d7a0d7d 100644 --- a/PyroFetes/Models/Color.cs +++ b/PyroFetes/Models/Color.cs @@ -1,10 +1,11 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Color { - public int Id { get; set; } - public string Label { get; set; } + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Effect.cs b/PyroFetes/Models/Effect.cs index 7643d4b..b8f083f 100644 --- a/PyroFetes/Models/Effect.cs +++ b/PyroFetes/Models/Effect.cs @@ -1,10 +1,11 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Effect { - public int Id { get; set; } - public string Label { get; set; } + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Material.cs b/PyroFetes/Models/Material.cs index 872c1c9..f60fc61 100644 --- a/PyroFetes/Models/Material.cs +++ b/PyroFetes/Models/Material.cs @@ -1,13 +1,14 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Material { - public int Id {get; set;} - public string Name {get; set;} - public int Quantity {get; set;} + [Key] public int Id {get; set;} + [Required, MaxLength(100)] public string Name {get; set;} + [Required] public int Quantity {get; set;} - public int WarehouseId {get; set;} - public Warehouse Warehouse {get; set;} + [Required] public int WarehouseId {get; set;} + [Required] public Warehouse Warehouse {get; set;} } \ No newline at end of file diff --git a/PyroFetes/Models/Movement.cs b/PyroFetes/Models/Movement.cs index 436a1ad..ff875d8 100644 --- a/PyroFetes/Models/Movement.cs +++ b/PyroFetes/Models/Movement.cs @@ -1,21 +1,22 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class Movement { - public int Id { get; set; } - public DateTime Date { get; set; } - public DateTime Start {get; set;} - public DateTime Arrival {get; set;} - public int Quantity {get; set;} + [Key] public int Id { get; set; } + [Required] public DateTime Date { get; set; } + [Required] public DateTime Start {get; set;} + [Required] public DateTime Arrival {get; set;} + [Required] public int Quantity {get; set;} - public int ProductId {get; set;} - public Product Product {get; set;} + [Required] public int ProductId {get; set;} + [Required] public Product Product {get; set;} - public int? sourceWarehouse {get; set;} - public Warehouse SourceWarehouse {get; set;} + [Required] public int? sourceWarehouse {get; set;} + [Required] public Warehouse SourceWarehouse {get; set;} - public int? destinationWarehouse {get; set;} - public Warehouse DestinationWarehouse {get; set;} + [Required] public int? destinationWarehouse {get; set;} + [Required] public Warehouse DestinationWarehouse {get; set;} } \ No newline at end of file diff --git a/PyroFetes/Models/Price.cs b/PyroFetes/Models/Price.cs index 6f28e60..9878768 100644 --- a/PyroFetes/Models/Price.cs +++ b/PyroFetes/Models/Price.cs @@ -7,11 +7,11 @@ namespace API.Models; [PrimaryKey(nameof(SupplierId), nameof(ProductId))] public class Price { - public decimal Label { get; set; } + [Required] public decimal Label { get; set; } - public int SupplierId { get; set; } + [Required] public int SupplierId { get; set; } [Required] public Supplier Supplier { get; set; } - public int ProductId { get; set; } + [Required] public int ProductId { get; set; } [Required] public Product Product { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Product.cs b/PyroFetes/Models/Product.cs index 0399afb..e2d5db3 100644 --- a/PyroFetes/Models/Product.cs +++ b/PyroFetes/Models/Product.cs @@ -1,31 +1,32 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models { public class Product { - public int Id { get; set; } - public int References { get; set; } - public string Name { get; set; } - public decimal Duration {get; set;} - public decimal Caliber { get; set; } - public int ApprovalNumber { get; set; } - public decimal Weight { get; set; } - public decimal Nec { get; set; } - public decimal SellingPrice { get; set; } - public string Image { get; set; } - public string Link { get; set; } + [Key] public int Id { get; set; } + [Required] public int References { get; set; } + [Required, MaxLength(100)] public string Name { get; set; } + [Required] public decimal Duration {get; set;} + [Required] public decimal Caliber { get; set; } + [Required] public int ApprovalNumber { get; set; } + [Required] public decimal Weight { get; set; } + [Required] public decimal Nec { get; set; } + [Required] public decimal SellingPrice { get; set; } + [Required] public string Image { get; set; } + [Required] public string Link { get; set; } // Relations - public int ClassificationId { get; set; } - public Classification Classification { get; set; } + [Required] public int ClassificationId { get; set; } + [Required] public Classification Classification { get; set; } - public int ProductCategoryId { get; set; } - public ProductCategory ProductCategory { get; set; } + [Required] public int ProductCategoryId { get; set; } + [Required] public ProductCategory ProductCategory { get; set; } - public List Brands { get; set; } + [Required] public List Brands { get; set; } - public List Movements { get; set; } + [Required] public List Movements { get; set; } } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductCategory.cs b/PyroFetes/Models/ProductCategory.cs index ca4bacd..419970c 100644 --- a/PyroFetes/Models/ProductCategory.cs +++ b/PyroFetes/Models/ProductCategory.cs @@ -1,11 +1,12 @@ -using API.Class; +using System.ComponentModel.DataAnnotations; +using API.Class; namespace API.Models; public class ProductCategory { - public int Id { get; set; } - public string Label { get; set; } + [Key] public int Id { get; set; } + [Required] public string Label { get; set; } - public List Products { get; set; } + [Required] public List Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductColor.cs b/PyroFetes/Models/ProductColor.cs index 58d17bf..8beac4d 100644 --- a/PyroFetes/Models/ProductColor.cs +++ b/PyroFetes/Models/ProductColor.cs @@ -6,9 +6,9 @@ namespace API.Models; [PrimaryKey(nameof(ProductId), nameof(ColorId))] public class ProductColor { - public Product? Product { get; set; } + [Required] public Product? Product { get; set; } [Required] public int ProductId { get; set; } - public Color? Color { get; set; } + [Required] public Color? Color { get; set; } [Required] public int ColorId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductEffect.cs b/PyroFetes/Models/ProductEffect.cs index bc6b33c..5289662 100644 --- a/PyroFetes/Models/ProductEffect.cs +++ b/PyroFetes/Models/ProductEffect.cs @@ -6,10 +6,10 @@ namespace API.Models; [PrimaryKey(nameof(ProductId), nameof(EffectId))] public class ProductEffect { - public Product? Product { get; set; } + [Required] public Product? Product { get; set; } [Required] public int ProductId { get; set; } - public Effect? Effect { get; set; } + [Required] public Effect? Effect { get; set; } [Required] public int EffectId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Supplier.cs b/PyroFetes/Models/Supplier.cs index b519e1f..6d44a91 100644 --- a/PyroFetes/Models/Supplier.cs +++ b/PyroFetes/Models/Supplier.cs @@ -1,15 +1,16 @@ -using API.Models; +using System.ComponentModel.DataAnnotations; +using API.Models; namespace API.Class; public class Supplier { - public int Id { get; set; } - public string Name { get; set; } - public string Email { get; set; } - public string PhoneNumber { get; set; } - public string Adress { get; set; } - public int ZipCode { get; set; } - public string City { get; set; } + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string Name { get; set; } + [Required] public string Email { get; set; } + [Required] public string PhoneNumber { get; set; } + [Required] public string Adress { get; set; } + [Required] public int ZipCode { get; set; } + [Required] public string City { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Warehouse.cs b/PyroFetes/Models/Warehouse.cs index 3145ac4..388e4d2 100644 --- a/PyroFetes/Models/Warehouse.cs +++ b/PyroFetes/Models/Warehouse.cs @@ -1,22 +1,23 @@ -using API.Models; +using System.ComponentModel.DataAnnotations; +using API.Models; namespace API.Class; public class Warehouse { - public int Id {get; set;} - public string Name {get; set;} - public int MaxWeight {get; set;} - public int Current {get; set;} - public int MinWeight {get; set;} - public string Adress { get; set; } - public int ZipCode { get; set; } - public string City { get; set; } + [Key] public int Id {get; set;} + [Required, MaxLength(100)] public string Name {get; set;} + [Required] public int MaxWeight {get; set;} + [Required] public int Current {get; set;} + [Required] public int MinWeight {get; set;} + [Required] public string Adress { get; set; } + [Required] public int ZipCode { get; set; } + [Required] public string City { get; set; } - public List Materials {get; set;} + [Required] public List Materials {get; set;} - public List MovementsSource { get; set; } - public List MovementsDestination { get; set; } + [Required] public List MovementsSource { get; set; } + [Required] public List MovementsDestination { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/WarehouseProduct.cs b/PyroFetes/Models/WarehouseProduct.cs index 7aeb873..79e5329 100644 --- a/PyroFetes/Models/WarehouseProduct.cs +++ b/PyroFetes/Models/WarehouseProduct.cs @@ -5,11 +5,11 @@ namespace API.Models; public class WarehouseProduct { - public int Quantity { get; set; } + [Key] public int Quantity { get; set; } - public int ProductId { get; set; } + [Required] public int ProductId { get; set; } [Required] public Product Product { get; set; } - public int WarehouseId { get; set; } + [Required] public int WarehouseId { get; set; } [Required] public Warehouse Warehouse { get; set; } } \ No newline at end of file