Ajout des Key et Required

This commit is contained in:
reignem
2025-10-02 14:43:34 +02:00
parent 423f4c4a6c
commit 964faa0b6b
14 changed files with 95 additions and 85 deletions

View File

@@ -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; }
}

View File

@@ -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<Product> Products { get; set; }
[Required] public List<Product> Products { get; set; }
}

View File

@@ -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; }
}

View File

@@ -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; }
}

View File

@@ -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;}
}

View File

@@ -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;}
}

View File

@@ -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; }
}

View File

@@ -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<Brand> Brands { get; set; }
[Required] public List<Brand> Brands { get; set; }
public List<Movement> Movements { get; set; }
[Required] public List<Movement> Movements { get; set; }
}
}

View File

@@ -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<Product> Products { get; set; }
[Required] public List<Product> Products { get; set; }
}

View File

@@ -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; }
}

View File

@@ -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; }
}

View File

@@ -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; }
}

View File

@@ -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<Material> Materials {get; set;}
[Required] public List<Material> Materials {get; set;}
public List<Movement> MovementsSource { get; set; }
public List<Movement> MovementsDestination { get; set; }
[Required] public List<Movement> MovementsSource { get; set; }
[Required] public List<Movement> MovementsDestination { get; set; }
}

View File

@@ -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; }
}