diff --git a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs new file mode 100644 index 0000000..53105bf --- /dev/null +++ b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Customer.Response; + +public class GetCustomerDto +{ + public int Id { get; set; } + public string? Note { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Deliverer/Response/GetDelivererDto.cs b/PyroFetes/DTO/Deliverer/Response/GetDelivererDto.cs index ee22196..ba638b8 100644 --- a/PyroFetes/DTO/Deliverer/Response/GetDelivererDto.cs +++ b/PyroFetes/DTO/Deliverer/Response/GetDelivererDto.cs @@ -6,6 +6,6 @@ public class GetDelivererDto { public int Id { get; set; } public string? Transporter { get; set; } - + public List? DeliveryNotes { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs index c2ee0d9..3dbde13 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs @@ -3,10 +3,9 @@ namespace PyroFetes.DTO.DeliveryNote.Request; public class CreateDeliveryNoteDto { public string? TrackingNumber { get; set; } - public DateOnly EstimateDeliveryDate { get; set; } - public DateOnly ExpeditionDate { get; set; } - + public int DelivererId { get; set; } - - public Dictionary? ProductQuantities { get; set; } + public int SupplierId { get; set; } + + public Dictionary? ProductQuantities { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Request/GetDeliveryNotePdfDto.cs b/PyroFetes/DTO/DeliveryNote/Request/GetDeliveryNotePdfDto.cs new file mode 100644 index 0000000..080ef0d --- /dev/null +++ b/PyroFetes/DTO/DeliveryNote/Request/GetDeliveryNotePdfDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.DeliveryNote.Request; + +public class GetDeliveryNotePdfDto +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs index b4746ff..95856e4 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/UpdateDeliveryNoteDto.cs @@ -7,6 +7,6 @@ public class UpdateDeliveryNoteDto public DateOnly EstimateDeliveryDate { get; set; } public DateOnly ExpeditionDate { get; set; } public DateOnly? RealDeliveryDate { get; set; } - + public int DelivererId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs index 3683ed3..6365143 100644 --- a/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Response/GetDeliveryNoteDto.cs @@ -9,9 +9,9 @@ public class GetDeliveryNoteDto public DateOnly EstimateDeliveryDate { get; set; } public DateOnly ExpeditionDate { get; set; } public DateOnly? RealDeliveryDate { get; set; } - + public int DelivererId { get; set; } public string? DelivererTransporter { get; set; } - - public List? Products { get; set; } + + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Price/Request/CreatePriceDto.cs b/PyroFetes/DTO/Price/Request/CreatePriceDto.cs index 26e52e7..c465649 100644 --- a/PyroFetes/DTO/Price/Request/CreatePriceDto.cs +++ b/PyroFetes/DTO/Price/Request/CreatePriceDto.cs @@ -3,25 +3,6 @@ public class CreatePriceDto { public decimal SellingPrice { get; set; } - public int? SupplierId { get; set; } - public string? SupplierName { get; set; } - public string? SupplierEmail { get; set; } - public string? SupplierPhone { get; set; } - public string? SupplierAddress { get; set; } - public string? SupplierZipCode { get; set; } - public string? SupplierCity { get; set; } - public int SupplierDeliveryDelay { get; set; } - - public int? ProductId { get; set; } - public string? ProductReferences { get; set; } - public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public int ProductCaliber { get; set; } - public string? ProductApprovalNumber { get; set; } - public decimal ProductWeight { get; set; } - public decimal ProductNec { get; set; } - public string? ProductImage { get; set; } - public string? ProductLink { get; set; } - public int ProductMinimalQuantity { get; set; } + public int ProductId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Price/Request/UpdatePriceDto.cs b/PyroFetes/DTO/Price/Request/UpdatePriceDto.cs deleted file mode 100644 index 1eac827..0000000 --- a/PyroFetes/DTO/Price/Request/UpdatePriceDto.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace PyroFetes.DTO.Price.Request; - -public class UpdatePriceDto -{ - public int Id { get; set; } - public decimal SellingPrice { get; set; } - - public int SupplierId { get; set; } - public string? SupplierName { get; set; } - public string? SupplierEmail { get; set; } - public string? SupplierPhone { get; set; } - public string? SupplierAddress { get; set; } - public int SupplierZipCode { get; set; } - public string? SupplierCity { get; set; } - public int SupplierDeliveryDelay { get; set; } - - public int ProductId { get; set; } - public string? ProductReferences { get; set; } - public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } - public decimal ProductWeight { get; set; } - public decimal ProductNec { get; set; } - public string? ProductImage { get; set; } - public string? ProductLink { get; set; } - public int ProductMinimalQuantity { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/Price/Response/GetPriceDto.cs b/PyroFetes/DTO/Price/Response/GetPriceDto.cs index a042cd2..8ad649c 100644 --- a/PyroFetes/DTO/Price/Response/GetPriceDto.cs +++ b/PyroFetes/DTO/Price/Response/GetPriceDto.cs @@ -2,24 +2,14 @@ public class GetPriceDto { - public int Id { get; set; } public decimal SellingPrice { get; set; } - - public int SupplierId { get; set; } - public string? SupplierName { get; set; } - public string? SupplierEmail { get; set; } - public string? SupplierPhone { get; set; } - public string? SupplierAddress { get; set; } - public int SupplierZipCode { get; set; } - public string? SupplierCity { get; set; } - public int SupplierDeliveryDelay { get; set; } - + public int ProductId { get; set; } - public string? ProductReferences { get; set; } + public string? ProductReference { get; set; } public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } + public decimal ProductDuration { get; set; } + public int ProductCaliber { get; set; } + public string? ProductApprovalNumber { get; set; } public decimal ProductWeight { get; set; } public decimal ProductNec { get; set; } public string? ProductImage { get; set; } diff --git a/PyroFetes/DTO/Product/Request/CreateProductDto.cs b/PyroFetes/DTO/Product/Request/CreateProductDto.cs deleted file mode 100644 index ddc689c..0000000 --- a/PyroFetes/DTO/Product/Request/CreateProductDto.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace PyroFetes.DTO.Product.Request; - -public class CreateProductDto -{ - public string? References { get; set; } - public string? Name { get; set; } - public decimal Duration {get; set;} - public int Caliber { get; set; } - public string? ApprovalNumber { get; set; } - public decimal Weight { get; set; } - public decimal Nec { get; set; } - public string? Image { get; set; } - public string? Link { get; set; } - public int MinimalQuantity { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs index db70e9c..9a95a03 100644 --- a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs +++ b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs @@ -5,7 +5,7 @@ public class UpdateProductDto public int Id { get; set; } public string? References { get; set; } public string? Name { get; set; } - public decimal Duration {get; set;} + public decimal Duration { get; set; } public int Caliber { get; set; } public string? ApprovalNumber { get; set; } public decimal Weight { get; set; } diff --git a/PyroFetes/DTO/Product/Response/GetProductDto.cs b/PyroFetes/DTO/Product/Response/GetProductDto.cs index c1f85f0..145f245 100644 --- a/PyroFetes/DTO/Product/Response/GetProductDto.cs +++ b/PyroFetes/DTO/Product/Response/GetProductDto.cs @@ -5,7 +5,7 @@ public class GetProductDto public int Id { get; set; } public string? References { get; set; } public string? Name { get; set; } - public decimal Duration {get; set;} + public decimal Duration { get; set; } public int Caliber { get; set; } public string? ApprovalNumber { get; set; } public decimal Weight { get; set; } diff --git a/PyroFetes/DTO/ProductDelivery/Request/CreateProductDeliveryDto.cs b/PyroFetes/DTO/ProductDelivery/Request/CreateProductDeliveryDto.cs deleted file mode 100644 index d993ad3..0000000 --- a/PyroFetes/DTO/ProductDelivery/Request/CreateProductDeliveryDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace PyroFetes.DTO.ProductDelivery.Request; - -public class CreateProductDeliveryDto -{ - public int ProductId { get; set; } - public int DeliveryNoteId { get; set; } - public int Quantity { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductDelivery/Request/UpdateProductDeliveryDto.cs b/PyroFetes/DTO/ProductDelivery/Request/UpdateProductDeliveryDto.cs deleted file mode 100644 index 7a6bb71..0000000 --- a/PyroFetes/DTO/ProductDelivery/Request/UpdateProductDeliveryDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace PyroFetes.DTO.ProductDelivery.Request; - -public class UpdateProductDeliveryDto -{ - public int Quantity { get; set; } - public int ProductId { get; set; } - public int DeliveryNoteId { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs b/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs index ef82503..58c47ae 100644 --- a/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs +++ b/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs @@ -3,26 +3,16 @@ namespace PyroFetes.DTO.ProductDelivery.Response; public class GetProductDeliveryDto { public int ProductId { get; set; } - public int ProductReference { get; set; } + public string? ProductReference { get; set; } public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } + public decimal ProductDuration { get; set; } + public int ProductCaliber { get; set; } + public string? ProductApprovalNumber { get; set; } public decimal ProductWeight { get; set; } public decimal ProductNec { get; set; } public string? ProductImage { get; set; } public string? ProductLink { get; set; } public int ProductMinimalQuantity { get; set; } - - public int DeliveryNoteId { get; set; } - public string? DeliveryNoteTrackingNumber { get; set; } - public DateOnly DeliveryNoteEstimateDeliveryDate { get; set; } - public DateOnly DeliveryNoteExpeditionDate { get; set; } - public DateOnly? DeliveryNoteRealDeliveryDate { get; set; } - - public int DeliveryNoteDeliverId { get; set; } - public string? DeliveryNoteDeliverTransporter { get; set; } - - + public int Quantity { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseOrder/Request/CreatePurchaseOrderDto.cs b/PyroFetes/DTO/PurchaseOrder/Request/CreatePurchaseOrderDto.cs new file mode 100644 index 0000000..87d17c1 --- /dev/null +++ b/PyroFetes/DTO/PurchaseOrder/Request/CreatePurchaseOrderDto.cs @@ -0,0 +1,10 @@ +using PyroFetes.DTO.PurchaseProduct.Request; + +namespace PyroFetes.DTO.PurchaseOrder.Request; + +public class CreatePurchaseOrderDto +{ + public string? PurchaseConditions { get; set; } + public int SupplierId { get; set; } + public List? Products { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseOrder/Request/GetPurchaseOrderPdfDto.cs b/PyroFetes/DTO/PurchaseOrder/Request/GetPurchaseOrderPdfDto.cs new file mode 100644 index 0000000..5ed195d --- /dev/null +++ b/PyroFetes/DTO/PurchaseOrder/Request/GetPurchaseOrderPdfDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.PurchaseOrder.Request; + +public class GetPurchaseOrderPdfDto +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs index 9854d8b..282ff85 100644 --- a/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs +++ b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs @@ -6,5 +6,7 @@ public class GetPurchaseOrderDto { public int Id { get; set; } public string? PurchaseConditions { get; set; } - public List? GetPurchaseProductDto { get; set; } + public int SupplierId { get; set; } + public string? SupplierName { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseOrderProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseOrderProductDto.cs new file mode 100644 index 0000000..60c2f07 --- /dev/null +++ b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseOrderProductDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.PurchaseProduct.Request; + +// Pour ajouter les produits lors de la création +public class CreatePurchaseOrderProductDto +{ + public int ProductId { get; set; } + public int Quantity { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs index 1249b41..007ab5f 100644 --- a/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs +++ b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs @@ -2,8 +2,7 @@ namespace PyroFetes.DTO.PurchaseProduct.Request; public class CreatePurchaseProductDto { - public int Quantity { get; set; } + public int Quantity { get; set; } public int ProductId { get; set; } public int PurchaseOrderId { get; set; } - public string? PurchaseOrderPurchaseConditions { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseProduct/Request/PatchPurchaseProductQuantityDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/PatchPurchaseProductQuantityDto.cs index 8bd9499..c19ef2f 100644 --- a/PyroFetes/DTO/PurchaseProduct/Request/PatchPurchaseProductQuantityDto.cs +++ b/PyroFetes/DTO/PurchaseProduct/Request/PatchPurchaseProductQuantityDto.cs @@ -4,5 +4,5 @@ public class PatchPurchaseProductQuantityDto { public int ProductId { get; set; } public int PurchaseOrderId { get; set; } - public int Quantity { get; set; } + public int Quantity { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseProduct/Request/UpdatePurchaseProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/UpdatePurchaseProductDto.cs deleted file mode 100644 index ea6b7ae..0000000 --- a/PyroFetes/DTO/PurchaseProduct/Request/UpdatePurchaseProductDto.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace PyroFetes.DTO.PurchaseProduct.Request; - -public class UpdatePurchaseProductDto -{ - public int ProductId { get; set; } - public int PurchaseOrderId { get; set; } - - public int Quantity { get; set; } - - public int ProductReferences { get; set; } - public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } - public decimal ProductWeight { get; set; } - public decimal ProductNec { get; set; } - public string? ProductImage { get; set; } - public string? ProductLink { get; set; } - public int ProductMinimalQuantity { get; set; } - - public string? PurchaseOrderPurchaseConditions { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs index d086ed3..80bccec 100644 --- a/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs +++ b/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs @@ -3,19 +3,19 @@ namespace PyroFetes.DTO.PurchaseProduct.Response; public class GetPurchaseProductDto { public int ProductId { get; set; } - public string? ProductReferences { get; set; } + public string? ProductReference { get; set; } public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } + public decimal ProductDuration { get; set; } + public int ProductCaliber { get; set; } + public string? ProductApprovalNumber { get; set; } public decimal ProductWeight { get; set; } public decimal ProductNec { get; set; } public string? ProductImage { get; set; } public string? ProductLink { get; set; } public int ProductMinimalQuantity { get; set; } + public decimal ProductPrice { get; set; } public int PurchaseOrderId { get; set; } - public string? PurchaseOrderPurchaseConditions { get; set; } - + public int Quantity { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Quotation/Request/CreateQuotationDto.cs b/PyroFetes/DTO/Quotation/Request/CreateQuotationDto.cs new file mode 100644 index 0000000..890f999 --- /dev/null +++ b/PyroFetes/DTO/Quotation/Request/CreateQuotationDto.cs @@ -0,0 +1,12 @@ +using PyroFetes.DTO.QuotationProduct.Request; + +namespace PyroFetes.DTO.Quotation.Request; + +public class CreateQuotationDto +{ + public string? Message { get; set; } + public string? ConditionsSale { get; set; } + public int CustomerId { get; set; } + public int SupplierId { get; set; } + public List? Products { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Quotation/Request/GetQuotationPdfDto.cs b/PyroFetes/DTO/Quotation/Request/GetQuotationPdfDto.cs new file mode 100644 index 0000000..fb37fa8 --- /dev/null +++ b/PyroFetes/DTO/Quotation/Request/GetQuotationPdfDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Quotation.Request; + +public class GetQuotationPdfDto +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Quotation/Request/UpdateQuotationDto.cs b/PyroFetes/DTO/Quotation/Request/UpdateQuotationDto.cs new file mode 100644 index 0000000..dbc0898 --- /dev/null +++ b/PyroFetes/DTO/Quotation/Request/UpdateQuotationDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Quotation.Request; + +public class UpdateQuotationDto +{ + public int Id { get; set; } + public string? Message { get; set; } + public string? ConditionsSale { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Quotation/Response/GetQuotationDto.cs b/PyroFetes/DTO/Quotation/Response/GetQuotationDto.cs index 589197c..f77195f 100644 --- a/PyroFetes/DTO/Quotation/Response/GetQuotationDto.cs +++ b/PyroFetes/DTO/Quotation/Response/GetQuotationDto.cs @@ -7,5 +7,5 @@ public class GetQuotationDto public int Id { get; set; } public string? Message { get; set; } public string? ConditionsSale { get; set; } - public List? GetQuotationProductDto { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Request/AddQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Request/AddQuotationProductDto.cs new file mode 100644 index 0000000..c7abdcf --- /dev/null +++ b/PyroFetes/DTO/QuotationProduct/Request/AddQuotationProductDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.QuotationProduct.Request; + +public class AddQuotationProductDto +{ + public int Quantity { get; set; } + public int QuotationId { get; set; } + public int ProductId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs b/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs new file mode 100644 index 0000000..43bcca7 --- /dev/null +++ b/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.QuotationProduct.Request; + +public class CreateProductQuotationDto +{ + public int ProductId { get; set; } + public int Quantity { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs deleted file mode 100644 index 86610d4..0000000 --- a/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace PyroFetes.DTO.QuotationProduct.Request; - -public class CreateQuotationProductDto -{ - public int Quantity { get; set; } - - public int QuotationId { get; set; } - public string? QuotationMessage { get; set; } - public string? QuotationConditionsSale { get; set; } - - public int ProductId { get; set; } - public int ProductReferences { get; set; } - public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } - public decimal ProductWeight { get; set; } - public decimal ProductNec { get; set; } - public string? ProductImage { get; set; } - public string? ProductLink { get; set; } - public int ProductMinimalQuantity { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Request/UpdateQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Request/UpdateQuotationProductDto.cs deleted file mode 100644 index 0247b6f..0000000 --- a/PyroFetes/DTO/QuotationProduct/Request/UpdateQuotationProductDto.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace PyroFetes.DTO.QuotationProduct.Request; - -public class UpdateQuotationProductDto -{ - public int Id { get; set; } - public int Quantity { get; set; } - - public int QuotationId { get; set; } - public string? QuotationMessage { get; set; } - public string? QuotationConditionsSale { get; set; } - - public int ProductId { get; set; } - public int ProductReferences { get; set; } - public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } - public decimal ProductWeight { get; set; } - public decimal ProductNec { get; set; } - public string? ProductImage { get; set; } - public string? ProductLink { get; set; } - public int ProductMinimalQuantity { get; set; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs index 4ef123b..08a8d6b 100644 --- a/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs +++ b/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs @@ -3,20 +3,18 @@ namespace PyroFetes.DTO.QuotationProduct.Response; public class GetQuotationProductDto { public int Quantity { get; set; } - - public int QuotationId { get; set; } - public string? QuotationMessage { get; set; } - public string? QuotationConditionsSale { get; set; } - + public int ProductId { get; set; } - public string? ProductReferences { get; set; } + public string? ProductReference { get; set; } public string? ProductName { get; set; } - public decimal ProductDuration {get; set;} - public decimal ProductCaliber { get; set; } - public int ProductApprovalNumber { get; set; } + public decimal ProductDuration { get; set; } + public int ProductCaliber { get; set; } + public string? ProductApprovalNumber { get; set; } public decimal ProductWeight { get; set; } public decimal ProductNec { get; set; } public string? ProductImage { get; set; } public string? ProductLink { get; set; } public int ProductMinimalQuantity { get; set; } + public decimal ProductPrice { get; set; } + public int QuotationId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Refresh/Request/RefreshTokenDto.cs b/PyroFetes/DTO/Refresh/Request/RefreshTokenDto.cs new file mode 100644 index 0000000..ab2c503 --- /dev/null +++ b/PyroFetes/DTO/Refresh/Request/RefreshTokenDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Refresh.Request; + +public class RefreshTokenDto +{ + public string? Token { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Refresh/Response/GetRefreshTokenDto.cs b/PyroFetes/DTO/Refresh/Response/GetRefreshTokenDto.cs new file mode 100644 index 0000000..ac16d1e --- /dev/null +++ b/PyroFetes/DTO/Refresh/Response/GetRefreshTokenDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Refresh.Response; + +public class GetRefreshTokenDto +{ + public string? Token { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs b/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs index 56146d3..35abce9 100644 --- a/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs +++ b/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs @@ -2,6 +2,6 @@ namespace PyroFetes.DTO.SettingDTO.Request; public class CreateSettingDto { - public string? ElectronicSignature { get; set; } - public string? Logo { get; set; } + public IFormFile? ElectronicSignature { get; set; } + public IFormFile? Logo { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs b/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs index 44e567e..fe2c421 100644 --- a/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs +++ b/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs @@ -2,6 +2,5 @@ namespace PyroFetes.DTO.SettingDTO.Request; public class PatchSettingElectronicSignatureDto { - public int Id { get; set; } - public string? ElectronicSignature { get; set; } + public IFormFile? ElectronicSignature { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs b/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs index 58a952e..24f1b8e 100644 --- a/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs +++ b/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs @@ -2,6 +2,5 @@ namespace PyroFetes.DTO.SettingDTO.Request; public class PatchSettingLogoDto { - public int Id { get; set; } - public string? Logo { get; set; } + public IFormFile? Logo { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs index 1fc9a60..bea9b70 100644 --- a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -1,3 +1,5 @@ +using PyroFetes.DTO.Price.Response; + namespace PyroFetes.DTO.Supplier.Response; public class GetSupplierDto @@ -10,4 +12,5 @@ public class GetSupplierDto public string? ZipCode { get; set; } public string? City { get; set; } public int DeliveryDelay { get; set; } + public List? Prices { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/User/Response/GetUserDto.cs b/PyroFetes/DTO/User/Response/GetUserDto.cs index 1bbf572..764e677 100644 --- a/PyroFetes/DTO/User/Response/GetUserDto.cs +++ b/PyroFetes/DTO/User/Response/GetUserDto.cs @@ -5,7 +5,6 @@ public class GetUserDto public int Id { get; set; } public string? Name { get; set; } public string? Password { get; set; } - public string? Salt { get; set; } public string? Fonction { get; set; } public string? Email { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/WareHouse/Response/GetWareHouseDto.cs b/PyroFetes/DTO/WareHouse/Response/GetWareHouseDto.cs new file mode 100644 index 0000000..7b820dc --- /dev/null +++ b/PyroFetes/DTO/WareHouse/Response/GetWareHouseDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.WareHouse.Response; + +public class GetWareHouseDto +{ + public int Id { get; set; } + public string? Name { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customers/GetAllCustomersEndpoint.cs b/PyroFetes/Endpoints/Customers/GetAllCustomersEndpoint.cs new file mode 100644 index 0000000..4fc3e17 --- /dev/null +++ b/PyroFetes/Endpoints/Customers/GetAllCustomersEndpoint.cs @@ -0,0 +1,19 @@ +using FastEndpoints; +using PyroFetes.DTO.Customer.Response; +using PyroFetes.Repositories; + +namespace PyroFetes.Endpoints.Customers; + +public class GetAllCustomersEndpoint(CustomersRepository customersRepository, AutoMapper.IMapper mapper) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/customers"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CancellationToken ct) + { + await Send.OkAsync(await customersRepository.ProjectToListAsync(ct), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs index 4eabfa5..c78bb26 100644 --- a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs @@ -6,25 +6,22 @@ using PyroFetes.Repositories; namespace PyroFetes.Endpoints.Deliverers; -public class CreateDelivererEndpoint( - DeliverersRepository deliverersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class CreateDelivererEndpoint(DeliverersRepository deliverersRepository) : Endpoint { public override void Configure() { Post("/deliverers"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CreateDelivererDto req, CancellationToken ct) { - Deliverer newDeliverer = new Deliverer() + Deliverer newDeliverer = new() { Transporter = req.Transporter, }; await deliverersRepository.AddAsync(newDeliverer, ct); - - await Send.OkAsync(mapper.Map(newDeliverer), ct); + await Send.NoContentAsync(ct); } -} +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/DeleteDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/DeleteDelivererEndpoint.cs index a2981fe..df8c6bc 100644 --- a/PyroFetes/Endpoints/Deliverers/DeleteDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/DeleteDelivererEndpoint.cs @@ -9,28 +9,26 @@ public class DeleteDelivererRequest { public int DelivererId { get; set; } } + public class DeleteDelivererEndpoint(DeliverersRepository deliverersRepository) : Endpoint { public override void Configure() { - Delete("/deliverers/{@id}", x=>new {x.DelivererId}); - AllowAnonymous(); - + Delete("/deliverers/{@Id}", x => new { x.DelivererId }); + Roles("Admin"); } public override async Task HandleAsync(DeleteDelivererRequest req, CancellationToken ct) { - Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); + Deliverer? deliverer = await deliverersRepository.SingleOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); - if (deliverer == null) + if (deliverer is null) { await Send.NotFoundAsync(ct); return; } - + await deliverersRepository.DeleteAsync(deliverer, ct); - - await Send.OkAsync(ct); + await Send.NoContentAsync(ct); } - } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/GetAllDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/GetAllDelivererEndpoint.cs index 5710628..b635ef7 100644 --- a/PyroFetes/Endpoints/Deliverers/GetAllDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/GetAllDelivererEndpoint.cs @@ -1,6 +1,4 @@ -using AutoMapper.QueryableExtensions; using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Deliverer.Response; using PyroFetes.Repositories; @@ -11,13 +9,11 @@ public class GetAllDelivererEndpoint(DeliverersRepository deliverersRepository) public override void Configure() { Get("/deliverers"); - AllowAnonymous(); - + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) { await Send.OkAsync(await deliverersRepository.ProjectToListAsync(ct), ct); } - } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/GetDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/GetDelivererEndpoint.cs index 22a027f..bc6b259 100644 --- a/PyroFetes/Endpoints/Deliverers/GetDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/GetDelivererEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Deliverer.Response; using PyroFetes.Models; using PyroFetes.Repositories; @@ -12,22 +11,19 @@ public class GetDelivererRequest public int DelivererId { get; set; } } -public class GetDelivererEndpoint( - DeliverersRepository deliverersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class GetDelivererEndpoint(DeliverersRepository deliverersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Get("/deliverers/{@id}", x=>new {x.DelivererId}); - AllowAnonymous(); - + Get("/deliverers/{@Id}", x => new { x.DelivererId }); + Roles("Admin","Employe"); } public override async Task HandleAsync(GetDelivererRequest req, CancellationToken ct) { - Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); + Deliverer? deliverer = await deliverersRepository.SingleOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); - if (deliverer == null) + if (deliverer is null) { await Send.NotFoundAsync(ct); return; @@ -35,5 +31,4 @@ public class GetDelivererEndpoint( await Send.OkAsync(mapper.Map(deliverer), ct); } - } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/UpdateDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/UpdateDelivererEndpoint.cs index ebf153e..c9fd77c 100644 --- a/PyroFetes/Endpoints/Deliverers/UpdateDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/UpdateDelivererEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Deliverer.Request; using PyroFetes.DTO.Deliverer.Response; using PyroFetes.Models; @@ -8,32 +7,27 @@ using PyroFetes.Specifications.Deliverers; namespace PyroFetes.Endpoints.Deliverers; -public class UpdateDelivererEndpoint( - DeliverersRepository deliverersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class UpdateDelivererEndpoint(DeliverersRepository deliverersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Put("/deliverers/{@id}", x=>new {x.Id}); - AllowAnonymous(); - + Put("/deliverers/{@Id}", x => new { x.Id }); + Roles("Admin"); } public override async Task HandleAsync(UpdateDelivererDto req, CancellationToken ct) { - Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.Id), ct); + Deliverer? deliverer = await deliverersRepository.SingleOrDefaultAsync(new GetDelivererByIdSpec(req.Id), ct); - if (deliverer == null) + if (deliverer is null) { await Send.NotFoundAsync(ct); return; } - - deliverer.Transporter = req.Transporter; - - await deliverersRepository.UpdateAsync(deliverer,ct); - await Send.OkAsync(mapper.Map(deliverer), ct); + mapper.Map(req, deliverer); + + await deliverersRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } - } \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs index 63d3103..01834a7 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs @@ -1,10 +1,10 @@ using FastEndpoints; using PyroFetes.DTO.DeliveryNote.Request; -using PyroFetes.DTO.DeliveryNote.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Deliverers; using PyroFetes.Specifications.Products; +using PyroFetes.Specifications.Suppliers; namespace PyroFetes.Endpoints.DeliveryNotes; @@ -12,57 +12,58 @@ public class CreateDeliveryNoteEndpoint( DeliveryNotesRepository deliveryNotesRepository, DeliverersRepository deliverersRepository, ProductsRepository productsRepository, - ProductDeliveriesRepository productDeliveriesRepository, - AutoMapper.IMapper mapper) : Endpoint + SuppliersRepository suppliersRepository, + ProductDeliveriesRepository productDeliveriesRepository) : Endpoint { public override void Configure() { Post("/deliveryNotes"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CreateDeliveryNoteDto req, CancellationToken ct) { - Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); - - if (deliverer == null) + Deliverer? deliverer = await deliverersRepository.SingleOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct); + Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct); + if (deliverer is null || supplier is null) { - await Send.StringAsync("No deliverer found", 404, cancellation: ct); + await Send.NotFoundAsync(ct); return; } - + //Creating the Delivery Note - DeliveryNote newDeliveryNote = new DeliveryNote() + DeliveryNote newDeliveryNote = new() { TrackingNumber = req.TrackingNumber, - EstimateDeliveryDate = req.EstimateDeliveryDate, - ExpeditionDate = req.ExpeditionDate, - DelivererId = req.DelivererId, + EstimateDeliveryDate = DateOnly.FromDateTime(DateTime.Today).AddMonths(2), + ExpeditionDate = DateOnly.FromDateTime(DateTime.Today), + DelivererId = deliverer.Id, Deliverer = deliverer, - + SupplierId = req.SupplierId, + Supplier = supplier }; - + await deliveryNotesRepository.AddAsync(newDeliveryNote, ct); - foreach (var productQuantity in req.ProductQuantities!) + if (req.ProductQuantities is not null) { - Product? product = - await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct); - if (product != null) + foreach (KeyValuePair productQuantity in req.ProductQuantities) { - ProductDelivery productDelivery = new ProductDelivery() + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct); + if (product is null) continue; + ProductDelivery productDelivery = new() { DeliveryNote = newDeliveryNote, Quantity = productQuantity.Value, Product = product, + ProductId = product.Id, DeliveryNoteId = newDeliveryNote.Id }; - + await productDeliveriesRepository.AddAsync(productDelivery, ct); } - } - - await Send.OkAsync(mapper.Map(newDeliveryNote), ct); + + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/DeleteDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/DeleteDeliveryNoteEndpoint.cs new file mode 100644 index 0000000..b2c9f7b --- /dev/null +++ b/PyroFetes/Endpoints/DeliveryNotes/DeleteDeliveryNoteEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.DeliveryNotes; + +namespace PyroFetes.Endpoints.DeliveryNotes; + +public class DeleteDeliveryNoteRequest +{ + public int Id { get; set; } +} + +public class DeleteDeliveryNoteEndpoint( + DeliveryNotesRepository deliveryNotesRepository) : Endpoint +{ + public override void Configure() + { + Delete("/deliveryNotes/{@Id}", x => new { x.Id }); + Roles("Admin"); + } + + public override async Task HandleAsync(DeleteDeliveryNoteRequest req, CancellationToken ct) + { + DeliveryNote? deliveryNote = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); + + if (deliveryNote is null) + { + await Send.NotFoundAsync(ct); + return; + } + + await deliveryNotesRepository.DeleteAsync(deliveryNote, ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNoteEndpoint.cs index 7e126b8..480983d 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNoteEndpoint.cs @@ -1,6 +1,7 @@ using FastEndpoints; using PyroFetes.DTO.DeliveryNote.Response; using PyroFetes.Repositories; +using PyroFetes.Specifications.DeliveryNotes; namespace PyroFetes.Endpoints.DeliveryNotes; @@ -9,12 +10,11 @@ public class GetAllDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRep public override void Configure() { Get("/deliveryNotes"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) { - await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync(ct), ct); + await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync(new GetAllDeliveryNoteSpec(), ct), ct); } - } \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs new file mode 100644 index 0000000..7693ac9 --- /dev/null +++ b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs @@ -0,0 +1,20 @@ +using FastEndpoints; +using PyroFetes.DTO.DeliveryNote.Response; +using PyroFetes.Repositories; +using PyroFetes.Specifications.DeliveryNotes; + +namespace PyroFetes.Endpoints.DeliveryNotes; + +public class GetAllDeliveryNotesNotArrivedEndpoint(DeliveryNotesRepository deliveryNotesRepository) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/deliveryNotes/validation"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CancellationToken ct) + { + await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync(new GetAllDeliveryNotesByRealDateSpec(), ct), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNoteEndpoint.cs index 90f3387..6088774 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNoteEndpoint.cs @@ -10,26 +10,27 @@ public class GetDeliveryNoteRequest { public int DeliveryNoteId { get; set; } } + public class GetDeliveryNoteEndpoint( DeliveryNotesRepository deliveryNotesRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Get("/deliveryNotes/{@id}", x=> new {x.DeliveryNoteId}); - AllowAnonymous(); + Get("/deliveryNotes/{@Id}", x => new { x.DeliveryNoteId }); + Roles("Admin","Employe"); } public override async Task HandleAsync(GetDeliveryNoteRequest req, CancellationToken ct) { - DeliveryNote? deliveryNote = await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.DeliveryNoteId), ct); + DeliveryNote? deliveryNote = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.DeliveryNoteId), ct); - if (deliveryNote == null) + if (deliveryNote is null) { await Send.NotFoundAsync(ct); return; } - + await Send.OkAsync(mapper.Map(deliveryNote), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNotePdfEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNotePdfEndpoint.cs new file mode 100644 index 0000000..dfacbf6 --- /dev/null +++ b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNotePdfEndpoint.cs @@ -0,0 +1,42 @@ +using System.Net.Mime; +using FastEndpoints; +using PyroFetes.DTO.DeliveryNote.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Services.Pdf; +using PyroFetes.Specifications.DeliveryNotes; + +namespace PyroFetes.Endpoints.DeliveryNotes; + +public class GetDeliveryNotePdfEndpoint(DeliveryNotesRepository deliveryNotesRepository, IDeliveryNotePdfService deliveryNotePdfService, SettingsRepository settingsRepository) + : Endpoint +{ + public override void Configure() + { + Get("/deliveryNotes/{@Id}/pdf", x => new { x.Id }); + Roles("Admin","Employe"); + Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); + } + + public override async Task HandleAsync(GetDeliveryNotePdfDto req, CancellationToken ct) + { + DeliveryNote? deliveryNote = await deliveryNotesRepository + .SingleOrDefaultAsync(new GetDeliveryNoteByIdWithProductsSpec(req.Id), ct); + + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + if (deliveryNote is null) + { + await Send.NotFoundAsync(ct); + return; + } + + byte[] bytes = deliveryNotePdfService.Generate(deliveryNote, deliveryNote.ProductDeliveries!, setting!); + + await Send.BytesAsync( + bytes: bytes, + contentType: "application/pdf", + fileName: $"bon-de-livraison-{deliveryNote.Id}{DateOnly.FromDateTime(DateTime.Now)}.pdf", + cancellation: ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs index bad22b7..6bf0485 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs @@ -1,39 +1,41 @@ using FastEndpoints; using PyroFetes.DTO.DeliveryNote.Request; -using PyroFetes.DTO.DeliveryNote.Response; -using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.Models; using PyroFetes.Repositories; -using PyroFetes.Specifications.Deliverers; using PyroFetes.Specifications.DeliveryNotes; namespace PyroFetes.Endpoints.DeliveryNotes; public class PatchRealDeliveryDateEndpoint( DeliveryNotesRepository deliveryNotesRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Patch("/deliveryNotes/{@id}", x=> new {x.Id}); - AllowAnonymous(); + Patch("/deliveryNotes/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchDeliveryNoteRealDeliveryDateDto req, CancellationToken ct) { - DeliveryNote? deliveryNoteToPath = - await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id),ct); + DeliveryNote? deliveryNoteToPath = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); - if (deliveryNoteToPath == null) + if (deliveryNoteToPath is null) { await Send.NotFoundAsync(ct); return; } - - deliveryNoteToPath.RealDeliveryDate = req.RealDeliveryDate; - + + if (deliveryNoteToPath.RealDeliveryDate is not null) + { + await Send.StringAsync("Impossible de modifier la date.", 400, cancellation: ct); + return; + } + + mapper.Map(req, deliveryNoteToPath); + await deliveryNotesRepository.UpdateAsync(deliveryNoteToPath, ct); - - await Send.OkAsync(mapper.Map(deliveryNoteToPath), ct); + + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/DeliveryNotes/UpdateDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/UpdateDeliveryNoteEndpoint.cs new file mode 100644 index 0000000..ecf3194 --- /dev/null +++ b/PyroFetes/Endpoints/DeliveryNotes/UpdateDeliveryNoteEndpoint.cs @@ -0,0 +1,32 @@ +using FastEndpoints; +using PyroFetes.DTO.DeliveryNote.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.DeliveryNotes; + +namespace PyroFetes.Endpoints.DeliveryNotes; + +public class UpdateDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRepository, AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Put("/deliveryNotes/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(UpdateDeliveryNoteDto req, CancellationToken ct) + { + DeliveryNote? deliveryNote = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); + + if (deliveryNote is null) + { + await Send.NotFoundAsync(ct); + return; + } + + mapper.Map(req, deliveryNote); + + await deliveryNotesRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs b/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs deleted file mode 100644 index 5445c0d..0000000 --- a/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs +++ /dev/null @@ -1,84 +0,0 @@ -using FastEndpoints; -using PyroFetes.DTO.Price.Request; -using PyroFetes.DTO.Price.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.Prices; -using PyroFetes.Specifications.Products; -using PyroFetes.Specifications.Suppliers; - -namespace PyroFetes.Endpoints.Prices; - -public class CreatePriceEndpoint( - SuppliersRepository suppliersRepository, - ProductsRepository productsRepository, - PricesRepository pricesRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Post("/prices"); - AllowAnonymous(); - } - - public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct) - { - // Gestion du fournisseur - Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct); - if (supplier == null) - { - supplier = new Supplier() - { - Name = req.SupplierName, - Email = req.SupplierEmail, - Phone = req.SupplierPhone, - Address = req.SupplierAddress, - City = req.SupplierCity, - ZipCode = req.SupplierZipCode, - DeliveryDelay = req.SupplierDeliveryDelay - }; - await suppliersRepository.AddAsync(supplier, ct); - } - - // Gestion du produit - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); - if (product == null) - { - product = new Product() - { - Reference = req.ProductReferences, - Name = req.ProductName, - Duration = req.ProductDuration, - Caliber = req.ProductCaliber, - ApprovalNumber = req.ProductApprovalNumber, - Weight = req.ProductWeight, - Nec = req.ProductNec, - Image = req.ProductImage, - Link = req.ProductLink, - MinimalQuantity = req.ProductMinimalQuantity - }; - await productsRepository.AddAsync(product, ct); - } - - // Vérifie si le prix existe déjà pour ce fournisseur et produit - Price? existingPrice = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); - - if (existingPrice != null) - { - await Send.StringAsync("Le fournisseur a déjà un prix pour ce produit.", 400, cancellation: ct); - return; - } - - // Création du prix - var priceAdded = new Price() - { - SellingPrice = req.SellingPrice, - SupplierId = supplier.Id, - ProductId = product.Id - }; - await pricesRepository.AddAsync(priceAdded, ct); - - - await Send.OkAsync(mapper.Map(priceAdded), ct); - } -} diff --git a/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs b/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs deleted file mode 100644 index 6ff6577..0000000 --- a/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.Prices; - -namespace PyroFetes.Endpoints.Prices; - -public class DeletePriceRequest -{ - public int ProductId { get; set; } - public int SupplierId { get; set; } -} - -public class DeletePriceEndpoint(PricesRepository pricesRepository) : Endpoint -{ - public override void Configure() - { - Delete("/prices/{@ProductId}/{@SupplierId}", x => new {x.ProductId, x.SupplierId}); - AllowAnonymous(); - } - - public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct) - { - Price? price = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId,req.SupplierId), ct); - - if (price == null) - { - await Send.NotFoundAsync(ct); - return; - } - - await pricesRepository.DeleteAsync(price, ct); - - await Send.NoContentAsync(ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs b/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs new file mode 100644 index 0000000..f8465e7 --- /dev/null +++ b/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Products; + +namespace PyroFetes.Endpoints.Products; + +public class DeleteProductsRequest +{ + public int ProductId { get; set; } +} + +public class DeleteProductEndpoint(ProductsRepository productsRepository) : Endpoint +{ + public override void Configure() + { + Delete("/products/{@Id}", x => new { x.ProductId }); + Roles("Admin"); + + } + + public override async Task HandleAsync(DeleteProductsRequest req, CancellationToken ct) + { + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); + + if (product is null) + { + await Send.NotFoundAsync(ct); + return; + } + + await productsRepository.DeleteAsync(product, ct); + await Send.OkAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs b/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs index 6b4f2e0..5b36622 100644 --- a/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs +++ b/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs @@ -1,7 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Response; -using PyroFetes.Models; using PyroFetes.Repositories; namespace PyroFetes.Endpoints.Products; @@ -11,7 +9,7 @@ public class GetAllProductsEndpoint(ProductsRepository productsRepository) : End public override void Configure() { Get("/products"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) diff --git a/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs b/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs new file mode 100644 index 0000000..a509256 --- /dev/null +++ b/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs @@ -0,0 +1,20 @@ +using FastEndpoints; +using PyroFetes.DTO.Product.Response; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Products; + +namespace PyroFetes.Endpoints.Products; + +public class GetAllProductsUnderLimitEndpoint(ProductsRepository productsRepository) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/products/underLimit"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CancellationToken ct) + { + await Send.OkAsync(await productsRepository.ProjectToListAsync(new GetProductsUnderLimitSpec(), ct), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Products/GetProductEndpoint.cs b/PyroFetes/Endpoints/Products/GetProductEndpoint.cs index 705f5d2..277e90e 100644 --- a/PyroFetes/Endpoints/Products/GetProductEndpoint.cs +++ b/PyroFetes/Endpoints/Products/GetProductEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Response; using PyroFetes.Models; using PyroFetes.Repositories; @@ -18,20 +17,21 @@ public class GetProductEndpoint( { public override void Configure() { - Get("/products/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/products/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); + } public override async Task HandleAsync(GetProductRequest req, CancellationToken ct) { Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct); - if (product == null) + if (product is null) { await Send.NotFoundAsync(ct); return; } - - await Send.OkAsync(mapper.Map(product), ct); + + await Send.OkAsync(mapper.Map(product), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs b/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs index 6d2cf8b..1a27b21 100644 --- a/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs +++ b/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs @@ -1,36 +1,32 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Request; -using PyroFetes.DTO.Product.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Products; namespace PyroFetes.Endpoints.Products; -public class PatchProductMinimalStockEndpoint( - ProductsRepository productsRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchProductMinimalStockEndpoint(ProductsRepository productsRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Patch("/products/{@Id}/MinimalStock", x => new { x.Id }); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchProductMinimalStockDto req, CancellationToken ct) { - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct); - - if (product == null) + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(req.Id), ct); + + if (product is null) { await Send.NotFoundAsync(ct); return; } - product.MinimalQuantity = req.MinimalQuantity; + mapper.Map(req, product); + await productsRepository.UpdateAsync(product, ct); - - await Send.OkAsync(mapper.Map(product), ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs b/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs index 0b37aa9..ee43e99 100644 --- a/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs @@ -1,46 +1,32 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Request; -using PyroFetes.DTO.Product.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Products; namespace PyroFetes.Endpoints.Products; -public class UpdateProductEndpoint( - ProductsRepository productsRepository, - AutoMapper.IMapper mapper) : Endpoint +public class UpdateProductEndpoint(ProductsRepository productsRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Put("/products/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Put("/products/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct) { - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct); - - if (product == null) + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(req.Id), ct); + + if (product is null) { await Send.NotFoundAsync(ct); return; } - product.Reference = req.References; - product.Name = req.Name; - product.Duration = req.Duration; - product.Caliber = req.Caliber; - product.ApprovalNumber = req.ApprovalNumber; - product.Weight = req.Weight; - product.Nec = req.Nec; - product.Image = req.Image; - product.Link = req.Link; - product.MinimalQuantity = req.MinimalQuantity; - + mapper.Map(req, product); + await productsRepository.UpdateAsync(product, ct); - - await Send.OkAsync(mapper.Map(product), ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/AddProductFromPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/AddProductFromPurchaseOrderEndpoint.cs new file mode 100644 index 0000000..9df4f09 --- /dev/null +++ b/PyroFetes/Endpoints/PurchaseOrders/AddProductFromPurchaseOrderEndpoint.cs @@ -0,0 +1,32 @@ +using FastEndpoints; +using PyroFetes.DTO.PurchaseProduct.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.PurchaseProducts; + +namespace PyroFetes.Endpoints.PurchaseOrders; + +public class AddProductFromPurchaseOrderEndpoint(PurchaseProductsRepository purchaseProductsRepository, AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/purchaseOrders/{@PurchaseOrderId}/{@ProductId}", x => new { x.PurchaseOrderId, x.ProductId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct) + { + PurchaseProduct? purchaseOrderProduct = + await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); + if (purchaseOrderProduct is not null) + { + await Send.StringAsync("Le produit est déjà dans le bon de commande", 400, cancellation: ct); + return; + } + + purchaseOrderProduct = mapper.Map(req); + + await purchaseProductsRepository.AddAsync(purchaseOrderProduct, ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs b/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs new file mode 100644 index 0000000..3947e32 --- /dev/null +++ b/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs @@ -0,0 +1,57 @@ +using FastEndpoints; +using PyroFetes.DTO.PurchaseOrder.Request; +using PyroFetes.DTO.PurchaseOrder.Response; +using PyroFetes.DTO.PurchaseProduct.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Products; +using PyroFetes.Specifications.PurchaseProducts; + +namespace PyroFetes.Endpoints.PurchaseOrders; + +public class CreatePurchaseOrder( + PurchaseOrdersRepository purchaseOrdersRepository, + ProductsRepository productsRepository, + PurchaseProductsRepository purchaseProductsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/purchaseOrders"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CreatePurchaseOrderDto req, CancellationToken ct) + { + PurchaseOrder purchaseOrder = mapper.Map(req); + await purchaseOrdersRepository.AddAsync(purchaseOrder, ct); + + if (req.Products != null) + { + foreach (CreatePurchaseOrderProductDto line in req.Products) + { + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(line.ProductId), ct); + if (product is null) + { + await Send.NotFoundAsync(ct); + return; + } + + PurchaseProduct? purchaseProduct = + await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(line.ProductId, purchaseOrder.Id), ct); + + if (purchaseProduct is not null) + { + await Send.StringAsync("Le produit est déjà dans le bon de commande", 400, cancellation: ct); + return; + } + + PurchaseProduct? productOnPurchase = mapper.Map(line); + productOnPurchase.PurchaseOrderId = purchaseOrder.Id; + + await purchaseProductsRepository.AddAsync(productOnPurchase, ct); + } + } + await Send.OkAsync(mapper.Map(purchaseOrder), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs new file mode 100644 index 0000000..ce6505d --- /dev/null +++ b/PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.PurchaseProducts; + +namespace PyroFetes.Endpoints.PurchaseOrders; + +public class DeletePurchaseProductRequest +{ + public int ProductId { get; set; } + public int PurchaseOrderId { get; set; } +} + +public class DeleteProductFromPurchaseOrderEndpoint(PurchaseProductsRepository purchaseProductsRepository) : Endpoint +{ + public override void Configure() + { + Delete("/purchaseOrders/{@ProductId}/{@PurchaseOrderId}", x => new { x.ProductId, x.PurchaseOrderId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(DeletePurchaseProductRequest req, CancellationToken ct) + { + PurchaseProduct? purchaseProduct = + await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); + + if (purchaseProduct is null) + { + await Send.NotFoundAsync(ct); + return; + } + + await purchaseProductsRepository.DeleteAsync(purchaseProduct, ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs index 580efb6..a0fe2f1 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.PurchaseOrders; @@ -11,33 +10,26 @@ public class DeletePurchaseOrderRequest public int Id { get; set; } } -public class DeletePurchaseOrderEndpoint( - PurchaseOrdersRepository purchaseOrdersRepository, - PurchaseProductsRepository purchaseProductsRepository) : Endpoint +public class DeletePurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrdersRepository) : Endpoint { public override void Configure() { - Delete("/purchaseOrders/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Delete("/purchaseOrders/{@Id}", x => new { x.Id }); + Roles("Admin"); + } public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct) { PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct); - if (purchaseOrder == null) + if (purchaseOrder is null) { await Send.NotFoundAsync(ct); return; } - - if (purchaseOrder.PurchaseProducts != null && purchaseOrder.PurchaseProducts.Any()) - { - await purchaseProductsRepository.DeleteRangeAsync(purchaseOrder.PurchaseProducts, ct); - } - - await purchaseOrdersRepository.DeleteAsync(purchaseOrder, ct); - + + await purchaseOrdersRepository.DeleteAsync(purchaseOrder, ct); await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs index 4bfd012..6d42c0f 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs @@ -1,8 +1,7 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Response; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Repositories; +using PyroFetes.Specifications.PurchaseOrders; namespace PyroFetes.Endpoints.PurchaseOrders; @@ -11,11 +10,11 @@ public class GetAllPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrders public override void Configure() { Get("/purchaseOrders"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) { - await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync(ct), ct); + await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync(new GetAllPurchaseOrderSpec(), ct), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs index 2b66aee..9c39ce4 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs @@ -1,7 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Response; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.PurchaseOrders; @@ -13,26 +11,24 @@ public class GetPurchaseOrderRequest public int Id { get; set; } } -public class GetPurchaseOrderEndpoint( - PurchaseOrdersRepository purchaseOrdersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class GetPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrdersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Get("/purchaseOrders/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/purchaseOrders/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } public override async Task HandleAsync(GetPurchaseOrderRequest req, CancellationToken ct) { - PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct); + PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.SingleOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct); - if (purchaseOrder == null) + if (purchaseOrder is null) { await Send.NotFoundAsync(ct); return; } - + await Send.OkAsync(mapper.Map(purchaseOrder), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderPdfEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderPdfEndpoint.cs new file mode 100644 index 0000000..a532874 --- /dev/null +++ b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderPdfEndpoint.cs @@ -0,0 +1,44 @@ +using System.Net.Mime; +using FastEndpoints; +using PyroFetes.DTO.PurchaseOrder.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Services.Pdf; +using PyroFetes.Specifications.PurchaseOrders; + +namespace PyroFetes.Endpoints.PurchaseOrders; + +public class GetPurchaseOrderPdfEndpoint( + PurchaseOrdersRepository purchaseOrdersRepository, + IPurchaseOrderPdfService purchaseOrderPdfService, + SettingsRepository settingsRepository) + : Endpoint +{ + public override void Configure() + { + Get("/purchaseOrders/{@Id}/pdf", x => new { x.Id }); + Roles("Admin","Employe"); + Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); + } + + public override async Task HandleAsync(GetPurchaseOrderPdfDto req, CancellationToken ct) + { + PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.SingleOrDefaultAsync(new GetPurchaseOrderByIdWithProductsSpec(req.Id), ct); + + if (purchaseOrder is null) + { + await Send.NotFoundAsync(ct); + return; + } + + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + byte[] bytes = purchaseOrderPdfService.Generate(purchaseOrder, purchaseOrder.PurchaseProducts!, setting!); + + await Send.BytesAsync( + bytes: bytes, + contentType: "application/pdf", + fileName: $"bon-de-commande-{purchaseOrder.Id}{DateOnly.FromDateTime(DateTime.Now)}.pdf", + cancellation: ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs index 7b5c1f5..f8a516a 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs @@ -1,36 +1,33 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Request; using PyroFetes.DTO.PurchaseOrder.Response; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.PurchaseOrders; namespace PyroFetes.Endpoints.PurchaseOrders; -public class PatchPurchaseOrderPurchaseConditionsEndpoint( - PurchaseOrdersRepository purchaseOrdersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchPurchaseOrderPurchaseConditionsEndpoint(PurchaseOrdersRepository purchaseOrdersRepository, AutoMapper.IMapper mapper) + : Endpoint { public override void Configure() { Patch("/purchaseOrders/{@Id}/PurchaseConditions", x => new { x.Id }); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchPurchaseOrderPurchaseConditionsDto req, CancellationToken ct) { - PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct); - if (purchaseOrder == null) + PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.SingleOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct); + if (purchaseOrder is null) { await Send.NotFoundAsync(ct); return; } - - purchaseOrder.PurchaseConditions = req.PurchaseConditions; - await purchaseOrdersRepository.UpdateAsync(purchaseOrder, ct); - await Send.OkAsync(mapper.Map(purchaseOrder), ct); + mapper.Map(req, purchaseOrder); + + await purchaseOrdersRepository.UpdateAsync(purchaseOrder, ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseProductQuantityEndpoint.cs new file mode 100644 index 0000000..3c28f91 --- /dev/null +++ b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseProductQuantityEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.DTO.PurchaseProduct.Request; +using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.PurchaseProducts; + +namespace PyroFetes.Endpoints.PurchaseOrders; + +public class PatchPurchaseProductQuantityEndpoint(PurchaseProductsRepository purchaseProductsRepository, AutoMapper.IMapper mapper) + : Endpoint +{ + public override void Configure() + { + Patch("/purchaseOrders/{@ProductId}/{@PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct) + { + PurchaseProduct? purchaseProduct = + await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); + + if (purchaseProduct is null) + { + await Send.NotFoundAsync(ct); + return; + } + + mapper.Map(req, purchaseProduct); + + await purchaseProductsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs deleted file mode 100644 index 24fe1f7..0000000 --- a/PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs +++ /dev/null @@ -1,56 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.PurchaseProduct.Request; -using PyroFetes.DTO.PurchaseProduct.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.Products; -using PyroFetes.Specifications.PurchaseOrders; - -namespace PyroFetes.Endpoints.PurchaseProducts; - -public class CreatePurchaseProductEndpoint( - ProductsRepository productsRepository, - PurchaseOrdersRepository purchaseOrdersRepository, - PurchaseProductsRepository purchaseProductsRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Post("/purchaseProducts"); - AllowAnonymous(); - } - - public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct) - { - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); - if (product == null) - { - await Send.NotFoundAsync(ct); - return; - } - - PurchaseOrder? purchaseOrder = - await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.PurchaseOrderId), ct); - - if (purchaseOrder == null) - { - purchaseOrder = new PurchaseOrder() - { - PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées" - }; - await purchaseOrdersRepository.AddAsync(purchaseOrder, ct); - } - - PurchaseProduct purchaseProduct = new PurchaseProduct() - { - ProductId = product.Id, - PurchaseOrderId = purchaseOrder.Id, - Quantity = req.Quantity - }; - - await purchaseProductsRepository.AddAsync(purchaseProduct, ct); - - await Send.OkAsync(mapper.Map(purchaseProduct), ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs deleted file mode 100644 index 7ce0dff..0000000 --- a/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.PurchaseProducts; - -namespace PyroFetes.Endpoints.PurchaseProducts; - -public class DeletePurchaseProductRequest -{ - public int ProductId { get; set; } - public int PurchaseOrderId { get; set; } -} - -public class DeletePurchaseProductEndpoint(PurchaseProductsRepository purchaseProductsRepository) : Endpoint -{ - public override void Configure() - { - Delete("/purchaseProducts/{@ProductId}/{@PurchaseOrderId}", x => new {x.ProductId, x.PurchaseOrderId}); - AllowAnonymous(); - } - - public override async Task HandleAsync(DeletePurchaseProductRequest req, CancellationToken ct) - { - PurchaseProduct? purchaseProduct = await purchaseProductsRepository.FirstOrDefaultAsync( - new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); - - if (purchaseProduct == null) - { - await Send.NotFoundAsync(ct); - return; - } - - await purchaseProductsRepository.DeleteAsync(purchaseProduct, ct); - - await Send.NoContentAsync(ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs deleted file mode 100644 index d1aad89..0000000 --- a/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs +++ /dev/null @@ -1,38 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.PurchaseProduct.Request; -using PyroFetes.DTO.PurchaseProduct.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.PurchaseProducts; - -namespace PyroFetes.Endpoints.PurchaseProducts; - -public class PatchPurchaseProductQuantityEndpoint( - PurchaseProductsRepository purchaseProductsRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Patch("/purchaseProducts/{@ProductId}/{@PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId }); - AllowAnonymous(); - } - - public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct) - { - PurchaseProduct? purchaseProduct = - await purchaseProductsRepository.FirstOrDefaultAsync( - new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); - - if (purchaseProduct == null) - { - await Send.NotFoundAsync(ct); - return; - } - - purchaseProduct.Quantity = req.Quantity; - await purchaseProductsRepository.UpdateAsync(purchaseProduct, ct); - - await Send.OkAsync(mapper.Map(purchaseProduct), ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs b/PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs deleted file mode 100644 index 2c13b2e..0000000 --- a/PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs +++ /dev/null @@ -1,58 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.QuotationProduct.Request; -using PyroFetes.DTO.QuotationProduct.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.Products; -using PyroFetes.Specifications.Quotations; - -namespace PyroFetes.Endpoints.QuotationProducts; - -public class CreateQuotationProductEndpoint( - QuotationProductsRepository quotationProductsRepository, - ProductsRepository productsRepository, - QuotationsRepository quotationsRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Post("/quotationProducts"); - AllowAnonymous(); - } - - public override async Task HandleAsync(CreateQuotationProductDto req, CancellationToken ct) - { - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); - - if (product == null) - { - await Send.NotFoundAsync(ct); - return; - } - - Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.QuotationId), ct); - - if (quotation == null) - { - quotation = new Quotation() - { - Message = req.QuotationMessage ?? "", - ConditionsSale = req.QuotationConditionsSale, - }; - - await quotationsRepository.AddAsync(quotation, ct); - } - - QuotationProduct quotationProduct = new QuotationProduct() - { - ProductId = product.Id, - QuotationId = quotation.Id, - Quantity = req.Quantity - }; - - await quotationProductsRepository.AddAsync(quotationProduct, ct); - - await Send.OkAsync(mapper.Map(quotationProduct), ct); - } -} diff --git a/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs b/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs deleted file mode 100644 index de8546e..0000000 --- a/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.QuotationProduct.Request; -using PyroFetes.DTO.QuotationProduct.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.QuotationProducts; - -namespace PyroFetes.Endpoints.QuotationProducts; - -public class PatchQuotationProductQuantityEndpoint( - QuotationProductsRepository quotationProductsRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Patch("/quotationProducts/{@ProductId}/{@QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId }); - AllowAnonymous(); - } - - public override async Task HandleAsync(PatchQuotationProductQuantityDto req, CancellationToken ct) - { - QuotationProduct? quotationProduct = - await quotationProductsRepository.FirstOrDefaultAsync( - new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); - if (quotationProduct == null) - { - await Send.NotFoundAsync(ct); - return; - } - - quotationProduct.Quantity = req.Quantity; - await quotationProductsRepository.UpdateAsync(quotationProduct, ct); - - await Send.OkAsync(mapper.Map(quotationProduct), ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/AddProductoToQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/AddProductoToQuotationEndpoint.cs new file mode 100644 index 0000000..731d1f6 --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/AddProductoToQuotationEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using PyroFetes.DTO.QuotationProduct.Request; +using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.QuotationProducts; + +namespace PyroFetes.Endpoints.Quotations; + +public class AddProductoToQuotationEndpoint( + QuotationProductsRepository quotationProductsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/quotations/{@Id}/products", x => new { x.ProductId, x.QuotationId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(AddQuotationProductDto req, CancellationToken ct) + { + QuotationProduct? productQuotation = + await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); + + if (productQuotation is not null) + { + await Send.StringAsync("ce produit existe déjà dans le devis", 400, cancellation: ct); + return; + } + + QuotationProduct quotationProduct = mapper.Map(req); + + await quotationProductsRepository.AddAsync(quotationProduct, ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs new file mode 100644 index 0000000..2f04dee --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs @@ -0,0 +1,57 @@ +using FastEndpoints; +using PyroFetes.DTO.Quotation.Request; +using PyroFetes.DTO.QuotationProduct.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Products; +using PyroFetes.Specifications.QuotationProducts; + +namespace PyroFetes.Endpoints.Quotations; + +public class CreateQuotationEndpoint( + QuotationsRepository quotationsRepository, + QuotationProductsRepository quotationProductsRepository, + ProductsRepository productsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/quotations"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CreateQuotationDto req, CancellationToken ct) + { + Quotation quotation = mapper.Map(req); + await quotationsRepository.AddAsync(quotation, ct); + + if (req.Products != null) + { + foreach (CreateProductQuotationDto line in req.Products) + { + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(line.ProductId), ct); + QuotationProduct? quotationProduct = + await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(line.ProductId, quotation.Id), ct); + + if (product is null) + { + await Send.NotFoundAsync(ct); + return; + } + + if (quotationProduct is not null) + { + await Send.StringAsync("Le produit est déjà dans le devis", 400, cancellation: ct); + return; + } + + QuotationProduct? productOnQuotation = mapper.Map(line); + productOnQuotation.QuotationId = quotation.Id; + + await quotationProductsRepository.AddAsync(productOnQuotation, ct); + } + } + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs b/PyroFetes/Endpoints/Quotations/DeleteProductFromQuotationEndpoint.cs similarity index 52% rename from PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs rename to PyroFetes/Endpoints/Quotations/DeleteProductFromQuotationEndpoint.cs index 554ccd4..a857879 100644 --- a/PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/DeleteProductFromQuotationEndpoint.cs @@ -1,10 +1,9 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.QuotationProducts; -namespace PyroFetes.Endpoints.QuotationProducts; +namespace PyroFetes.Endpoints.Quotations; public class DeleteQuotationProductRequest { @@ -12,28 +11,26 @@ public class DeleteQuotationProductRequest public int QuotationId { get; set; } } -public class DeleteQuotationProductEndpoint(QuotationProductsRepository quotationProductsRepository) : Endpoint +public class DeleteProductFromQuotationEndpoint(QuotationProductsRepository quotationProductsRepository) : Endpoint { public override void Configure() { - Delete("/quotationProducts/{@ProductId}/{@QuotationId}", x => new {x.ProductId, x.QuotationId}); - AllowAnonymous(); + Delete("/quotations/{@ProductId}/{@QuotationId}", x => new { x.ProductId, x.QuotationId }); + Roles("Admin"); } public override async Task HandleAsync(DeleteQuotationProductRequest req, CancellationToken ct) { QuotationProduct? quotationProduct = - await quotationProductsRepository.FirstOrDefaultAsync( - new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); + await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); - if (quotationProduct == null) + if (quotationProduct is null) { await Send.NotFoundAsync(ct); return; } - + await quotationProductsRepository.DeleteAsync(quotationProduct, ct); - await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs index 80df36c..e26b7ba 100644 --- a/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Quotations; @@ -11,33 +10,26 @@ public class DeleteQuotationRequest public int Id { get; set; } } -public class DeleteQuotationEndpoint( - QuotationsRepository quotationsRepository, - QuotationProductsRepository quotationProductsRepository) : Endpoint +public class DeleteQuotationEndpoint(QuotationsRepository quotationsRepository) : Endpoint { public override void Configure() { - Delete("/quotations/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Delete("/quotations/{@Id}", x => new { x.Id }); + Roles("Admin"); + } public override async Task HandleAsync(DeleteQuotationRequest req, CancellationToken ct) { - Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); + Quotation? quotation = await quotationsRepository.SingleOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); - if (quotation == null) + if (quotation is null) { await Send.NotFoundAsync(ct); return; } - - if (quotation.QuotationProducts != null && quotation.QuotationProducts.Any()) - { - await quotationProductsRepository.DeleteRangeAsync(quotation.QuotationProducts, ct); - } - + await quotationsRepository.DeleteAsync(quotation, ct); - await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs index b4674f3..d8a0f2d 100644 --- a/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs @@ -1,9 +1,7 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Response; -using PyroFetes.DTO.QuotationProduct.Response; -using PyroFetes.Models; using PyroFetes.Repositories; +using PyroFetes.Specifications.Quotations; namespace PyroFetes.Endpoints.Quotations; @@ -12,11 +10,11 @@ public class GetAllQuotationEndpoint(QuotationsRepository quotationsRepository) public override void Configure() { Get("/quotations"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) { - await Send.OkAsync(await quotationsRepository.ProjectToListAsync(ct), ct); + await Send.OkAsync(await quotationsRepository.ProjectToListAsync(new GetAllQuotationSpec(), ct), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs index bdc57c2..d22200e 100644 --- a/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs @@ -1,7 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Response; -using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Quotations; @@ -19,20 +17,20 @@ public class GetQuotationEndpoint( { public override void Configure() { - Get("/quotations/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/quotations/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } public override async Task HandleAsync(GetQuotationRequest req, CancellationToken ct) { - Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); + Quotation? quotation = await quotationsRepository.SingleOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); - if (quotation == null) + if (quotation is null) { await Send.NotFoundAsync(ct); return; } - + await Send.OkAsync(mapper.Map(quotation), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/GetQuotationPdfEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetQuotationPdfEndpoint.cs new file mode 100644 index 0000000..4b015d9 --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/GetQuotationPdfEndpoint.cs @@ -0,0 +1,44 @@ +using System.Net.Mime; +using FastEndpoints; +using PyroFetes.DTO.Quotation.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Services.Pdf; +using PyroFetes.Specifications.Quotations; + +namespace PyroFetes.Endpoints.Quotations; + +public class GetQuotationPdfEndpoint( + QuotationsRepository quotationRepository, + IQuotationPdfService quotationPdfService, + SettingsRepository settingsRepository) + : Endpoint +{ + public override void Configure() + { + Get("/quotations/{@Id}/pdf", x => new { x.Id }); + Roles("Admin","Employe"); + Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); + } + + public override async Task HandleAsync(GetQuotationPdfDto req, CancellationToken ct) + { + Quotation? quotation = await quotationRepository.SingleOrDefaultAsync(new GetQuotationByIdWithProductsSpec(req.Id), ct); + + if (quotation is null) + { + await Send.NotFoundAsync(ct); + return; + } + + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + byte[] bytes = quotationPdfService.Generate(quotation, quotation.QuotationProducts!, setting!); + + await Send.BytesAsync( + bytes: bytes, + contentType: "application/pdf", + fileName: $"devis-{quotation.Id}{DateOnly.FromDateTime(DateTime.Now)}.pdf", + cancellation: ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs b/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs index a21f60d..827e2fb 100644 --- a/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs @@ -1,8 +1,6 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Request; using PyroFetes.DTO.Quotation.Response; -using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Quotations; @@ -11,28 +9,27 @@ namespace PyroFetes.Endpoints.Quotations; public class PatchQuotationConditionsSaleEndpoint( QuotationsRepository quotationsRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Patch("/quotations/{@Id}/saleConditions", x => new { x.Id }); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchQuotationConditionsSaleDto req, CancellationToken ct) { - Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); - - if (quotation == null) + Quotation? quotation = await quotationsRepository.SingleOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); + + if (quotation is null) { await Send.NotFoundAsync(ct); return; } - - quotation.ConditionsSale = req.ConditionsSale; - await quotationsRepository.UpdateAsync(quotation, ct); - - await Send.OkAsync(mapper.Map(quotation), ct); + mapper.Map(req, quotation); + + await quotationsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/PatchQuotationMessageEndpoint.cs b/PyroFetes/Endpoints/Quotations/PatchQuotationMessageEndpoint.cs new file mode 100644 index 0000000..542a54e --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationMessageEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.DTO.Quotation.Request; +using PyroFetes.DTO.Quotation.Response; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Quotations; + +namespace PyroFetes.Endpoints.Quotations; + +public class PatchQuotationMessageEndpoint( + QuotationsRepository quotationsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Patch("/quotations/{@Id}/message", x => new { x.Id }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(PatchQuotationMessageDto req, CancellationToken ct) + { + Quotation? quotation = await quotationsRepository.SingleOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); + + if (quotation is null) + { + await Send.NotFoundAsync(ct); + return; + } + + mapper.Map(req, quotation); + + await quotationsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs b/PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs new file mode 100644 index 0000000..1f1cff6 --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.DTO.QuotationProduct.Request; +using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.QuotationProducts; + +namespace PyroFetes.Endpoints.Quotations; + +public class PatchQuotationProductQuantityEndpoint( + QuotationProductsRepository quotationProductsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Patch("/quotations/{@ProductId}/{@QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(PatchQuotationProductQuantityDto req, CancellationToken ct) + { + QuotationProduct? quotationProduct = + await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); + if (quotationProduct is null) + { + await Send.NotFoundAsync(ct); + return; + } + + mapper.Map(req, quotationProduct); + + await quotationProductsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs new file mode 100644 index 0000000..eb5b4a2 --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.DTO.Quotation.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Quotations; + +namespace PyroFetes.Endpoints.Quotations; + +public class UpdateQuotationEndpoint( + QuotationsRepository quotationsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Put("/quotations/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); + + } + + public override async Task HandleAsync(UpdateQuotationDto req, CancellationToken ct) + { + Quotation? quotation = await quotationsRepository.SingleOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct); + + if (quotation is null) + { + await Send.NotFoundAsync(ct); + return; + } + + mapper.Map(req, quotation); + + await quotationsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Refresh/RefreshTokenEndpoint.cs b/PyroFetes/Endpoints/Refresh/RefreshTokenEndpoint.cs new file mode 100644 index 0000000..b11b418 --- /dev/null +++ b/PyroFetes/Endpoints/Refresh/RefreshTokenEndpoint.cs @@ -0,0 +1,62 @@ +using System.IdentityModel.Tokens.Jwt; +using FastEndpoints; +using FastEndpoints.Security; +using PyroFetes.DTO.Refresh.Request; +using PyroFetes.DTO.Refresh.Response; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Users; + +namespace PyroFetes.Endpoints.Refresh; + +public class RefreshTokenEndpoint(UsersRepository usersRepository) : Endpoint +{ + public override void Configure() + { + Post("/refresh"); + AllowAnonymous(); + } + + public override async Task HandleAsync(RefreshTokenDto req, CancellationToken ct) + { + try + { + JwtSecurityTokenHandler handler = new(); + JwtSecurityToken? token = handler.ReadJwtToken(req.Token); + string? username = token.Claims.FirstOrDefault(c => c.Type == "Name")?.Value; + + if (string.IsNullOrWhiteSpace(username)) + { + await Send.UnauthorizedAsync(ct); + return; + } + + User? login = await usersRepository.SingleOrDefaultAsync(new GetUserByNameSpec(username), ct); + if (login == null) + { + await Send.UnauthorizedAsync(ct); + return; + } + + string jwtToken = JwtBearer.CreateToken(o => + { + o.SigningKey = "v9!Qx7#Lk2@pZ8$wR6!tN5%uF3&cD9^mH1*eY4"; + o.ExpireAt = DateTime.UtcNow.AddMinutes(15); + if (login.Fonction is not null) o.User.Roles.Add(login.Fonction); + o.User.Claims.Add(("Name", login.Name)!); + o.User.Claims.Add(("Id", login.Id.ToString())!); + }); + + GetRefreshTokenDto responseDto = new() + { + Token = jwtToken + }; + + await Send.OkAsync(responseDto, ct); + } + catch + { + await Send.UnauthorizedAsync(ct); + } + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs deleted file mode 100644 index 893996b..0000000 --- a/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs +++ /dev/null @@ -1,31 +0,0 @@ -using FastEndpoints; -using PyroFetes.DTO.SettingDTO.Request; -using PyroFetes.DTO.SettingDTO.Response; -using PyroFetes.Models; -using PyroFetes.Repositories; - -namespace PyroFetes.Endpoints.Settings; - -public class CreateSettingEndpoint( - SettingsRepository settingsRepository, - AutoMapper.IMapper mapper) : Endpoint -{ - public override void Configure() - { - Post("/settings"); - AllowAnonymous(); - } - - public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct) - { - Setting setting = new Setting() - { - ElectronicSignature = req.ElectronicSignature, - Logo = req.Logo - }; - - await settingsRepository.AddAsync(setting, ct); - - await Send.OkAsync(mapper.Map(setting), ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs deleted file mode 100644 index 2979b01..0000000 --- a/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs +++ /dev/null @@ -1,36 +0,0 @@ -using FastEndpoints; -using Microsoft.EntityFrameworkCore; -using PyroFetes.Models; -using PyroFetes.Repositories; -using PyroFetes.Specifications.Settings; - -namespace PyroFetes.Endpoints.Settings; - -public class DeleteSettingRequest -{ - public int Id { get; set; } -} - -public class DeleteSettingEndpoint(SettingsRepository settingsRepository) : Endpoint -{ - public override void Configure() - { - Delete("/settings/{@Id}", x => new {x.Id}); - AllowAnonymous(); - } - - public override async Task HandleAsync(DeleteSettingRequest req, CancellationToken ct) - { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - - if (setting == null) - { - await Send.NotFoundAsync(ct); - return; - } - - await settingsRepository.DeleteAsync(setting, ct); - - await Send.NoContentAsync(ct); - } -} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs index 1735008..fedd96c 100644 --- a/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs @@ -1,32 +1,23 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.Models; using PyroFetes.Repositories; -using PyroFetes.Specifications.Settings; namespace PyroFetes.Endpoints.Settings; -public class GetSettingRequest -{ - public int Id { get; set; } -} - -public class GetSettingEndpoint( - SettingsRepository settingsRepository, - AutoMapper.IMapper mapper) : Endpoint +public class GetSettingEndpoint(SettingsRepository settingsRepository, AutoMapper.IMapper mapper) : EndpointWithoutRequest { public override void Configure() { - Get("/settings/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/settings/"); + Roles("Admin","Employe"); } - - public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct) - { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - if (setting == null) + public override async Task HandleAsync(CancellationToken ct) + { + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + if (setting is null) { await Send.NotFoundAsync(ct); return; diff --git a/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs index ca73c8c..624f7d7 100644 --- a/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs @@ -1,36 +1,38 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Request; -using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.Models; using PyroFetes.Repositories; -using PyroFetes.Specifications.Settings; namespace PyroFetes.Endpoints.Settings; -public class PatchSettingElectronicSignatureEndpoint( - SettingsRepository settingsRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchSettingElectronicSignatureEndpoint(SettingsRepository settingsRepository) : Endpoint { public override void Configure() { - Patch("/settings/{@Id}/ElectronicSignature", x => new {x.Id}); - AllowAnonymous(); + Patch("/settings/electronicSignature"); + AllowFormData(); + Roles("Admin"); + } - + public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct) { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - - if (setting == null) + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + if (setting is null) { await Send.NotFoundAsync(ct); return; } - setting.ElectronicSignature = req.ElectronicSignature; - await settingsRepository.UpdateAsync(setting, ct); + // Encodage en base64 + using MemoryStream memoryStream = new(); + if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct); + byte[] signatureBytes = memoryStream.ToArray(); - await Send.OkAsync(mapper.Map(setting), ct); + setting.ElectronicSignature = Convert.ToBase64String(signatureBytes); + + await settingsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs b/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs index f180cbc..d4a10d1 100644 --- a/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs @@ -1,36 +1,37 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Request; -using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.Models; using PyroFetes.Repositories; -using PyroFetes.Specifications.Settings; namespace PyroFetes.Endpoints.Settings; -public class PatchSettingLogoEndpoint( - SettingsRepository settingsRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchSettingLogoEndpoint(SettingsRepository settingsRepository) : Endpoint { public override void Configure() { - Patch("/settings/{@Id}/logo", x => new {x.Id}); - AllowAnonymous(); + Patch("/settings/logo"); + AllowFormData(); + Roles("Admin"); } - + public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct) { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); - if (setting == null) + if (setting is null) { await Send.NotFoundAsync(ct); return; } - setting.Logo = req.Logo; - await settingsRepository.UpdateAsync(setting, ct); - - await Send.OkAsync(mapper.Map(setting), ct); + // Encodage en base64 + using MemoryStream memoryStream = new(); + if (req.Logo != null) await req.Logo.CopyToAsync(memoryStream, ct); + byte[] logoBytes = memoryStream.ToArray(); + + setting.Logo = Convert.ToBase64String(logoBytes); + + await settingsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/AddProductToSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/AddProductToSupplierEndpoint.cs new file mode 100644 index 0000000..90942e2 --- /dev/null +++ b/PyroFetes/Endpoints/Suppliers/AddProductToSupplierEndpoint.cs @@ -0,0 +1,43 @@ +using FastEndpoints; +using PyroFetes.DTO.Price.Request; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Prices; +using PyroFetes.Specifications.Products; +using PyroFetes.Specifications.Suppliers; + +namespace PyroFetes.Endpoints.Suppliers; + +public class AddProductToSupplierEndpoint( + SuppliersRepository suppliersRepository, + ProductsRepository productsRepository, + PricesRepository pricesRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/suppliers/{@SupplierId}/{@ProductId}/", x => new { x.SupplierId, x.ProductId }); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct) + { + Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct); + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); + if (supplier is null || product is null) + { + await Send.NotFoundAsync(ct); + return; + } + + Price? existingPrice = await pricesRepository.SingleOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); + if (existingPrice is not null) + { + await Send.StringAsync("Le fournisseur a déjà un prix pour ce produit.", 400, cancellation: ct); + return; + } + + await pricesRepository.AddAsync(mapper.Map(req), ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs index afd95f2..fa63a16 100644 --- a/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs @@ -1,36 +1,21 @@ using FastEndpoints; using PyroFetes.DTO.Supplier.Request; -using PyroFetes.DTO.Supplier.Response; using PyroFetes.Models; using PyroFetes.Repositories; namespace PyroFetes.Endpoints.Suppliers; -public class CreateSupplierEndpoint( - SuppliersRepository suppliersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class CreateSupplierEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Post("/suppliers"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct) { - Supplier? supplier = new Supplier() - { - Name = req.Name, - Email = req.Email, - Phone = req.Phone, - Address = req.Address, - City = req.City, - ZipCode = req.ZipCode, - DeliveryDelay = req.DeliveryDelay - }; - - await suppliersRepository.AddAsync(supplier, ct); - - await Send.OkAsync(mapper.Map(supplier), ct); + await suppliersRepository.AddAsync(mapper.Map(req), ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs new file mode 100644 index 0000000..8f70d79 --- /dev/null +++ b/PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.Prices; + +namespace PyroFetes.Endpoints.Suppliers; + +public class DeletePriceRequest +{ + public int ProductId { get; set; } + public int SupplierId { get; set; } +} + +public class DeleteProductToSupplierEndpoint(PricesRepository pricesRepository) : Endpoint +{ + public override void Configure() + { + Delete("/suppliers/{@SupplierId}/{@Product}", x => new { x.SupplierId, x.ProductId }); + Roles("Admin"); + } + + public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct) + { + Price? price = await pricesRepository.SingleOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); + + if (price is null) + { + await Send.NotFoundAsync(ct); + return; + } + + await pricesRepository.DeleteAsync(price, ct); + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/DeleteSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/DeleteSupplierEndpoint.cs index 6786015..163e42c 100644 --- a/PyroFetes/Endpoints/Suppliers/DeleteSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/DeleteSupplierEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Suppliers; @@ -15,22 +14,21 @@ public class DeleteSupplierEndpoint(SuppliersRepository suppliersRepository) : E { public override void Configure() { - Delete("/suppliers/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Delete("/suppliers/{@Id}", x => new { x.Id }); + Roles("Admin"); } - + public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct) { - Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); + Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); - if (supplier == null) + if (supplier is null) { await Send.NotFoundAsync(ct); return; } - - await suppliersRepository.DeleteAsync(supplier, ct); - + + await suppliersRepository.DeleteAsync(supplier, ct); await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs b/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs index 3c655f8..faa0473 100644 --- a/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Response; using PyroFetes.Repositories; @@ -10,7 +9,7 @@ public class GetAllSuppliersEndpoint(SuppliersRepository suppliersRepository) : public override void Configure() { Get("/suppliers"); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(CancellationToken ct) diff --git a/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs index 50fbb54..258e720 100644 --- a/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Response; using PyroFetes.Models; using PyroFetes.Repositories; @@ -12,21 +11,19 @@ public class GetSupplierRequest public int Id { get; set; } } -public class GetSupplierEndpoint( - SuppliersRepository suppliersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class GetSupplierEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Get("/suppliers/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/suppliers/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } - + public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct) { - Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); + Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); - if (supplier == null) + if (supplier is null) { await Send.NotFoundAsync(ct); return; diff --git a/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs b/PyroFetes/Endpoints/Suppliers/PatchPriceEndpoint.cs similarity index 56% rename from PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/PatchPriceEndpoint.cs index 23cb247..0b97a27 100644 --- a/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/PatchPriceEndpoint.cs @@ -1,36 +1,34 @@ using FastEndpoints; using PyroFetes.DTO.Price.Request; -using PyroFetes.DTO.Price.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Prices; -namespace PyroFetes.Endpoints.Prices; +namespace PyroFetes.Endpoints.Suppliers; public class PatchPriceEndpoint( PricesRepository pricesRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Patch("/prices/{@ProductId}/{@SupplierId}/SellingPrice", x => new { x.ProductId, x.SupplierId }); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchPriceSellingPriceDto req, CancellationToken ct) { - Price? price = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId),ct); - - if (price == null) + Price? price = await pricesRepository.SingleOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); + + if (price is null) { await Send.NotFoundAsync(ct); return; } - - price.SellingPrice = req.SellingPrice; - - await pricesRepository.UpdateAsync(price, ct); - - await Send.OkAsync(mapper.Map(price), ct); + + mapper.Map(req, price); + + await pricesRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/PatchSupplierDeliveryDelayEndpoint.cs b/PyroFetes/Endpoints/Suppliers/PatchSupplierDeliveryDelayEndpoint.cs index 0a83253..0f230b8 100644 --- a/PyroFetes/Endpoints/Suppliers/PatchSupplierDeliveryDelayEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/PatchSupplierDeliveryDelayEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Response; using PyroFetes.Models; @@ -8,29 +7,28 @@ using PyroFetes.Specifications.Suppliers; namespace PyroFetes.Endpoints.Suppliers; -public class PatchSupplierDeliveryDelayEndpoint( - SuppliersRepository suppliersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchSupplierDeliveryDelayEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Patch("/suppliers/{@Id}/deliveryDelay", x => new {x.Id}); - AllowAnonymous(); + Patch("/suppliers/{@Id}/deliveryDelay", x => new { x.Id }); + Roles("Admin","Employe"); + } - + public override async Task HandleAsync(PatchSupplierDeliveryDelayDto req, CancellationToken ct) { - Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); + Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); - if (supplier == null) + if (supplier is null) { await Send.NotFoundAsync(ct); return; } supplier.DeliveryDelay = req.DeliveryDelay; - await suppliersRepository.UpdateAsync(supplier, ct); - + await suppliersRepository.SaveChangesAsync(ct); + await Send.OkAsync(mapper.Map(supplier), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs index 79206ce..b55a8be 100644 --- a/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs @@ -1,43 +1,31 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Request; -using PyroFetes.DTO.Supplier.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Suppliers; namespace PyroFetes.Endpoints.Suppliers; -public class UpdateSupplierEndpoint( - SuppliersRepository suppliersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class UpdateSupplierEndpoint(SuppliersRepository suppliersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Put("/suppliers/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Put("/suppliers/{@Id}", x => new { x.Id }); + Roles("Admin","Employe"); } public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct) { Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct); - - if (supplier == null) + if (supplier is null) { await Send.NotFoundAsync(ct); return; } - supplier.Name = req.Name; - supplier.Email = req.Email; - supplier.Phone = req.Phone; - supplier.Address = req.Address; - supplier.City = req.City; - supplier.ZipCode = req.ZipCode; - supplier.DeliveryDelay = req.DeliveryDelay; - - await suppliersRepository.UpdateAsync(supplier, ct); - - await Send.OkAsync(mapper.Map(supplier), ct); + mapper.Map(req, supplier); + + await suppliersRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs b/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs index 07e6eaa..d7931fa 100644 --- a/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs @@ -19,31 +19,30 @@ public class ConnectUserEndpoint(UsersRepository usersRepository) : Endpoint - { - o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong"; - o.ExpireAt = DateTime.UtcNow.AddMinutes(15); - if (user.Fonction != null) o.User.Roles.Add(user.Fonction); - o.User.Claims.Add(("Name", user.Name)!); - o.User.Claims.Add(("Id", user.Id.ToString())!); - }); + string jwtToken = JwtBearer.CreateToken(o => + { + o.SigningKey = "v9!Qx7#Lk2@pZ8$wR6!tN5%uF3&cD9^mH1*eY4"; + o.ExpireAt = DateTime.UtcNow.AddMinutes(15); + if (user.Fonction is not null) o.User.Roles.Add(user.Fonction); + o.User.Claims.Add(("Name", user.Name)!); + o.User.Claims.Add(("Id", user.Id.ToString())!); + }); GetTokenDto responseDto = new() { Token = jwtToken }; - + await Send.OkAsync(responseDto, ct); } else await Send.UnauthorizedAsync(ct); diff --git a/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs index 1a014d9..517536b 100644 --- a/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs @@ -4,24 +4,31 @@ using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; using PyroFetes.Models; using PyroFetes.Repositories; +using PyroFetes.Specifications.Users; namespace PyroFetes.Endpoints.Users; -public class CreateUserEndpoint( - UsersRepository usersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class CreateUserEndpoint(UsersRepository usersRepository) : Endpoint { public override void Configure() { Post("/users"); - AllowAnonymous(); + Roles("Admin"); } public override async Task HandleAsync(CreateUserDto req, CancellationToken ct) { + User? ckeckName = await usersRepository.SingleOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct); + + if (ckeckName is not null) + { + await Send.StringAsync("Ce nom d'utilisateur existe déjà.", 400, cancellation: ct); + return; + } + string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next(); - - User user = new User() + + User user = new() { Name = req.Name, Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt), @@ -29,9 +36,8 @@ public class CreateUserEndpoint( Email = req.Email, Fonction = req.Fonction }; - + await usersRepository.AddAsync(user, ct); - - await Send.OkAsync(mapper.Map(user), ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/DeleteUserEndpoint.cs b/PyroFetes/Endpoints/Users/DeleteUserEndpoint.cs index 859d548..dcc09af 100644 --- a/PyroFetes/Endpoints/Users/DeleteUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/DeleteUserEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Users; @@ -15,22 +14,21 @@ public class DeleteUserEndpoint(UsersRepository usersRepository) : Endpoint new {x.Id}); - AllowAnonymous(); + Delete("/users/{@Id}", x => new { x.Id }); + Roles("Admin"); } public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct) { - User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); + User? user = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); - if (user == null) + if (user is null) { await Send.NotFoundAsync(ct); return; } - + await usersRepository.DeleteAsync(user, ct); - await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs b/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs index 6a36ca9..59731c3 100644 --- a/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs +++ b/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Response; using PyroFetes.Repositories; @@ -10,7 +9,7 @@ public class GetAllUsersEndpoint(UsersRepository usersRepository) : EndpointWith public override void Configure() { Get("/users"); - AllowAnonymous(); + Roles("Admin"); } public override async Task HandleAsync(CancellationToken ct) diff --git a/PyroFetes/Endpoints/Users/GetUserEndpoint.cs b/PyroFetes/Endpoints/Users/GetUserEndpoint.cs index a03e04f..2a93a5e 100644 --- a/PyroFetes/Endpoints/Users/GetUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/GetUserEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Response; using PyroFetes.Models; using PyroFetes.Repositories; @@ -7,31 +6,25 @@ using PyroFetes.Specifications.Users; namespace PyroFetes.Endpoints.Users; -public class GetUserRequest -{ - public int Id { get; set; } -} - -public class GetUserEndpoint( - UsersRepository usersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class GetUserEndpoint(UsersRepository usersRepository, AutoMapper.IMapper mapper) : EndpointWithoutRequest { public override void Configure() { - Get("/users/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Get("/user/"); + Roles("Admin","Employe"); } - public override async Task HandleAsync(GetUserRequest req, CancellationToken ct) + public override async Task HandleAsync(CancellationToken ct) { - User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); + int userId = int.Parse(User.FindFirst("Id")!.Value); + User? user = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(userId), ct); - if (user == null) + if (user is null) { await Send.NotFoundAsync(ct); return; } - + await Send.OkAsync(mapper.Map(user), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs b/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs index 1647bd4..5095ca0 100644 --- a/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs +++ b/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; using PyroFetes.Models; @@ -8,21 +7,19 @@ using PyroFetes.Specifications.Users; namespace PyroFetes.Endpoints.Users; -public class PatchUserPasswordEndpoint( - UsersRepository usersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class PatchUserPasswordEndpoint(UsersRepository usersRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Patch("/users/{@Id}/password", x => new { x.Id }); - AllowAnonymous(); + Roles("Admin"); } public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct) { - User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); - - if (user == null) + User? user = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); + + if (user is null) { await Send.NotFoundAsync(ct); return; @@ -30,7 +27,7 @@ public class PatchUserPasswordEndpoint( user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + user.Salt); await usersRepository.UpdateAsync(user, ct); - - await Send.OkAsync(mapper.Map(user), ct); + + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs index b50439d..7d5ae39 100644 --- a/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PasswordGenerator; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; @@ -9,43 +8,41 @@ using PyroFetes.Specifications.Users; namespace PyroFetes.Endpoints.Users; -public class UpdateUserEndpoint( - UsersRepository usersRepository, - AutoMapper.IMapper mapper) : Endpoint +public class UpdateUserEndpoint(UsersRepository usersRepository) : Endpoint { public override void Configure() { - Put("/users/{@Id}", x => new {x.Id}); - AllowAnonymous(); + Put("/users/{@Id}", x => new { x.Id }); + Roles("Admin"); } public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct) { - User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); - User? ckeckName = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct); + User? user = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(req.Id), ct); + User? ckeckName = await usersRepository.SingleOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct); - if (user == null) + if (user is null) { await Send.NotFoundAsync(ct); return; } - - if (ckeckName != null) + + if (ckeckName is not null && ckeckName.Id != user.Id) { - await Send.StringAsync("Ce nom d'utilisateur existe déjà.",409, cancellation: ct); + await Send.StringAsync("Ce nom d'utilisateur existe déjà.", 400, cancellation: ct); return; } string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next(); - + user.Name = req.Name; user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt); user.Salt = salt; user.Email = req.Email; user.Fonction = req.Fonction; - + await usersRepository.UpdateAsync(user, ct); - - await Send.OkAsync(mapper.Map(user), ct); + + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/WareHouse/GetAllWarehouseEndpoint.cs b/PyroFetes/Endpoints/WareHouse/GetAllWarehouseEndpoint.cs new file mode 100644 index 0000000..4cef069 --- /dev/null +++ b/PyroFetes/Endpoints/WareHouse/GetAllWarehouseEndpoint.cs @@ -0,0 +1,19 @@ +using FastEndpoints; +using PyroFetes.DTO.WareHouse.Response; +using PyroFetes.Repositories; + +namespace PyroFetes.Endpoints.WareHouse; + +public class GetAllWarehouseEndpoint(WareHouseRepository wareHouseRepository, AutoMapper.IMapper mapper) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/wareHouses/"); + Roles("Admin","Employe"); + } + + public override async Task HandleAsync(CancellationToken ct) + { + await Send.OkAsync(await wareHouseRepository.ProjectToListAsync(ct), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs index 6df7fd9..473480f 100644 --- a/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs @@ -1,7 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.WareHouseProduct.Response; -using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.WarehouseProducts; @@ -18,22 +16,22 @@ public class GetTotalQuantityEndpoint( public override void Configure() { Get("/wareHouseProducts/{@ProductId}", x => new { x.ProductId }); - AllowAnonymous(); + Roles("Admin","Employe"); } - + public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct) { - bool exists = await warehouseProductsRepository.AnyAsync(new GetWarehouseProductByProductIdSpec(req.ProductId), ct); + bool exists = await warehouseProductsRepository.AnyAsync(new GetWarehouseProductByProductIdSpec(req.ProductId, null), ct); if (!exists) { await Send.NotFoundAsync(ct); return; } - - int totalQuantity = - await warehouseProductsRepository.SumAsync(new GetProductTotalQuantitySpec(req.ProductId), - wp => wp.Quantity, ct); + + int? totalQuantityNullable = await warehouseProductsRepository.SumAsync(new GetProductTotalQuantitySpec(req.ProductId), wp => wp.Quantity, ct); + + int totalQuantity = totalQuantityNullable ?? 0; GetTotalQuantityDto responseDto = new() { diff --git a/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs index 93a4e07..2e1246f 100644 --- a/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs @@ -1,41 +1,39 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.WareHouseProduct.Request; using PyroFetes.DTO.WareHouseProduct.Response; using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.WareHouse; +using PyroFetes.Specifications.WarehouseProducts; namespace PyroFetes.Endpoints.WareHouseProducts; -public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) - : Endpoint +public class PatchWareHouseProductQuantityEndpoint(WarehouseProductsRepository warehouseProductsRepository, WareHouseRepository wareHouseRepository , AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { Patch("/wareHouseProducts/{@ProductId}/{@WareHouseId}/quantity", x => new { x.ProductId, x.WareHouseId }); - AllowAnonymous(); + Roles("Admin","Employe"); } public override async Task HandleAsync(PatchWareHouseProductQuantityDto req, CancellationToken ct) { - WarehouseProduct? wareHouseProduct = - await database.WarehouseProducts.SingleOrDefaultAsync( - wp => wp.ProductId == req.ProductId && wp.WarehouseId == req.WareHouseId, ct); - - if (wareHouseProduct == null) + WarehouseProduct? wareHouseProduct = await warehouseProductsRepository.FirstOrDefaultAsync(new GetWarehouseProductByProductIdSpec(req.ProductId, req.WareHouseId), ct); + Warehouse? warehouse = await wareHouseRepository.SingleOrDefaultAsync(new GetWareHouseByIdSpec(req.WareHouseId), ct); + + if (warehouse is null) { await Send.NotFoundAsync(ct); return; } - - wareHouseProduct.Quantity = req.Quantity; - await database.SaveChangesAsync(ct); - - GetWareHouseProductDto responseDto = new() + + if (wareHouseProduct is null) await warehouseProductsRepository.AddAsync(mapper.Map(req), ct); + else { - ProductId = wareHouseProduct.ProductId, - WareHouseId = wareHouseProduct.WarehouseId, - Quantity = wareHouseProduct.Quantity - }; - await Send.OkAsync(responseDto, ct); + wareHouseProduct.Quantity += req.Quantity; + await warehouseProductsRepository.SaveChangesAsync(ct); + } + + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/MappingProfiles/DtoToEntityMappings.cs b/PyroFetes/MappingProfiles/DtoToEntityMappings.cs index d1a1db8..689f5ae 100644 --- a/PyroFetes/MappingProfiles/DtoToEntityMappings.cs +++ b/PyroFetes/MappingProfiles/DtoToEntityMappings.cs @@ -3,7 +3,6 @@ using PyroFetes.DTO.Deliverer.Request; using PyroFetes.DTO.DeliveryNote.Request; using PyroFetes.DTO.Price.Request; using PyroFetes.DTO.Product.Request; -using PyroFetes.DTO.ProductDelivery.Request; using PyroFetes.DTO.PurchaseOrder.Request; using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.Quotation.Request; @@ -21,47 +20,66 @@ public class DtoToEntityMappings : Profile public DtoToEntityMappings() { CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.SupplierId, opt => opt.Ignore()); - CreateMap(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + + CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.PurchaseOrderId, opt => opt.Ignore()); + + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap(); + CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + + CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.QuotationId, opt => opt.Ignore()); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap(); - CreateMap(); - CreateMap(); - + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); } diff --git a/PyroFetes/MappingProfiles/EntityToDtoMappings.cs b/PyroFetes/MappingProfiles/EntityToDtoMappings.cs index 0fbbffe..3e5ea84 100644 --- a/PyroFetes/MappingProfiles/EntityToDtoMappings.cs +++ b/PyroFetes/MappingProfiles/EntityToDtoMappings.cs @@ -1,4 +1,5 @@ using AutoMapper; +using PyroFetes.DTO.Customer.Response; using PyroFetes.DTO.Deliverer.Response; using PyroFetes.DTO.DeliveryNote.Response; using PyroFetes.DTO.Price.Response; @@ -9,7 +10,9 @@ using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.SettingDTO.Response; +using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.User.Response; +using PyroFetes.DTO.WareHouse.Response; using PyroFetes.DTO.WareHouseProduct.Response; using PyroFetes.Models; @@ -20,27 +23,44 @@ public class EntityToDtoMappings : Profile public EntityToDtoMappings() { CreateMap(); - - CreateMap(); - + + CreateMap(); + + CreateMap() + .ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.ProductDeliveries)); + CreateMap(); - - CreateMap(); - + + CreateMap() + .ForMember(dest => dest.References, opt => opt.MapFrom(src => src.Reference)); + CreateMap(); - - CreateMap(); - - CreateMap(); - - CreateMap(); - - CreateMap(); + + CreateMap() + .ForMember(dest => dest.SupplierName, opt => opt.MapFrom(src => src.Supplier!.Name)) + .ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.PurchaseProducts)); + + CreateMap() + .ForMember(dest => dest.ProductPrice, + opt => opt.MapFrom(src => + src.Product!.Prices.Where(x => x.SupplierId == src.PurchaseOrder!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault())); + + CreateMap() + .ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.QuotationProducts)); + + CreateMap() + .ForMember(dest => dest.ProductPrice, + opt => opt.MapFrom(src => + src.Product!.Prices.Where(x => x.SupplierId == src.Quotation!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault())); CreateMap(); - + CreateMap(); CreateMap(); + + CreateMap(); + + CreateMap(); } } \ No newline at end of file diff --git a/PyroFetes/Migrations/20251008103414_InitialDatabase.Designer.cs b/PyroFetes/Migrations/20251008103414_InitialDatabase.Designer.cs deleted file mode 100644 index 8e971b2..0000000 --- a/PyroFetes/Migrations/20251008103414_InitialDatabase.Designer.cs +++ /dev/null @@ -1,1951 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PyroFetes; - -#nullable disable - -namespace PyroFetes.Migrations -{ - [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251008103414_InitialDatabase")] - partial class InitialDatabase - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.20") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AvailabilityDate") - .HasColumnType("date"); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.Property("RenewallDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("Availabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ProductId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Brands"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Classifications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Colors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Calling") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Meeting") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.HasIndex("ContactId"); - - b.ToTable("Communications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Role") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Contacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("ContactServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.Property("TermsAndConditions") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ShowId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("Contract"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CustomerTypeId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerTypeId"); - - b.ToTable("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("CustomerTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Transporter") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Deliverers"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DelivererId") - .HasColumnType("int"); - - b.Property("EstimateDeliveryDate") - .HasColumnType("date"); - - b.Property("ExpeditionDate") - .HasColumnType("date"); - - b.Property("RealDeliveryDate") - .HasColumnType("date"); - - b.Property("TrackingNumber") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("DelivererId"); - - b.ToTable("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.ToTable("Effects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("ExperienceLevels"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("HistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WarehouseId"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.Property("MaterialId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("MaterialId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("MaterialWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Arrival") - .HasColumnType("datetime2"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("DestinationWarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("SourceWarehouseId") - .HasColumnType("int"); - - b.Property("Start") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("DestinationWarehouseId"); - - b.HasIndex("SourceWarehouseId"); - - b.ToTable("Movements"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.Property("SellingPrice") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "SupplierId"); - - b.HasIndex("SupplierId"); - - b.ToTable("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ApprovalNumber") - .HasColumnType("int"); - - b.Property("Caliber") - .HasColumnType("decimal(18,2)"); - - b.Property("ClassificationId") - .HasColumnType("int"); - - b.Property("Duration") - .HasColumnType("decimal(18,2)"); - - b.Property("Image") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Link") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("MinimalQuantity") - .HasColumnType("int"); - - b.Property("MovementId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Nec") - .HasColumnType("decimal(18,2)"); - - b.Property("ProductCategoryId") - .HasColumnType("int"); - - b.Property("References") - .HasColumnType("int"); - - b.Property("SellingPrice") - .HasColumnType("decimal(18,2)"); - - b.Property("Weight") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ClassificationId"); - - b.HasIndex("MovementId"); - - b.HasIndex("ProductCategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProductCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ColorId") - .HasColumnType("int"); - - b.HasKey("ProductId", "ColorId"); - - b.HasIndex("ColorId"); - - b.ToTable("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("DeliveryNoteId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "DeliveryNoteId"); - - b.HasIndex("DeliveryNoteId"); - - b.ToTable("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("EffectId") - .HasColumnType("int"); - - b.HasKey("ProductId", "EffectId"); - - b.HasIndex("EffectId"); - - b.ToTable("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ProductTimecode"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ProviderId"); - - b.HasIndex("ProviderId"); - - b.ToTable("ProviderContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProviderTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PurchaseConditions") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("PurchaseOrders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("PurchaseOrderId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "PurchaseOrderId"); - - b.HasIndex("PurchaseOrderId"); - - b.ToTable("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ConditionsSale") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("QuotationId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "QuotationId"); - - b.HasIndex("QuotationId"); - - b.ToTable("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("ProviderTypeId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProviderTypeId"); - - b.ToTable("Providers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Setting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ElectronicSignature") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Logo") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Settings"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CityId") - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("date"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Place") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("PyrotechnicImplementationPlan") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("MaterialId") - .HasColumnType("int"); - - b.HasKey("ShowId", "MaterialId"); - - b.HasIndex("MaterialId"); - - b.ToTable("ShowMaterial"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.Property("StaffId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.HasKey("StaffId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ShowStaff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("TruckId") - .HasColumnType("int"); - - b.HasKey("ShowId", "TruckId"); - - b.HasIndex("TruckId"); - - b.ToTable("ShowTruck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Artist") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("Duration") - .IsRequired() - .HasColumnType("int"); - - b.Property("Format") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Kind") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("SoundCategoryId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.HasIndex("SoundCategoryId"); - - b.ToTable("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("SoundCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("SoundId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ShowId", "SoundId"); - - b.HasIndex("SoundId"); - - b.ToTable("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("F4T2ExpirationDate") - .HasColumnType("date"); - - b.Property("F4T2NumberApproval") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("Profession") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.Property("AvailabilityId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("AvailabilityId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("ContactId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.Property("HistoryOfApprovalId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("HistoryOfApprovalId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DeliveryDelay") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Suppliers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("MaxExplosiveCapacity") - .IsRequired() - .HasColumnType("float"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("nvarchar(80)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.HasKey("Id"); - - b.ToTable("Trucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Fonction") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Salt") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Current") - .HasColumnType("int"); - - b.Property("MaxWeight") - .HasColumnType("int"); - - b.Property("MinWeight") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Warehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Brands") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("Communications") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Contacts") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("ContactServiceProviders") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("ContactServiceProviders") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("ServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("Contracts") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("Contracts") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ServiceProvider"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.HasOne("PyroFetes.Models.CustomerType", "CustomerType") - .WithMany("Customers") - .HasForeignKey("CustomerTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CustomerType"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.HasOne("PyroFetes.Models.Deliverer", "Deliverer") - .WithMany("DeliveryNotes") - .HasForeignKey("DelivererId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Deliverer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ExperienceLevels") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany() - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("MaterialWarehouses") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("MaterialWarehouses") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "DestinationWarehouse") - .WithMany("MovementsDestination") - .HasForeignKey("DestinationWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("PyroFetes.Models.Warehouse", "SourceWarehouse") - .WithMany("MovementsSource") - .HasForeignKey("SourceWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("DestinationWarehouse"); - - b.Navigation("SourceWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Prices") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Supplier", "Supplier") - .WithMany("Prices") - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Supplier"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.HasOne("PyroFetes.Models.Classification", "Classification") - .WithMany("Products") - .HasForeignKey("ClassificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Movement", "Movement") - .WithMany("Products") - .HasForeignKey("MovementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ProductCategory", "ProductCategory") - .WithMany("Products") - .HasForeignKey("ProductCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Classification"); - - b.Navigation("Movement"); - - b.Navigation("ProductCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.HasOne("PyroFetes.Models.Color", "Color") - .WithMany("ProductColors") - .HasForeignKey("ColorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductColors") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Color"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.HasOne("PyroFetes.Models.DeliveryNote", "DeliveryNote") - .WithMany("ProductDeliveries") - .HasForeignKey("DeliveryNoteId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductDeliveries") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("DeliveryNote"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.HasOne("PyroFetes.Models.Effect", "Effect") - .WithMany("ProductEffects") - .HasForeignKey("EffectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductEffects") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Effect"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductTimecodes") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ProductTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany() - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "Provider") - .WithMany() - .HasForeignKey("ProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("PurchaseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.PurchaseOrder", "PurchaseOrder") - .WithMany("PurchaseProducts") - .HasForeignKey("PurchaseOrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("PurchaseOrder"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Quotations") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("QuotationProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Quotation", "Quotation") - .WithMany("QuotationProducts") - .HasForeignKey("QuotationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Quotation"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.HasOne("PyroFetes.Models.ProviderType", "ProviderType") - .WithMany("ServiceProviders") - .HasForeignKey("ProviderTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ProviderType"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.HasOne("PyroFetes.Models.City", "City") - .WithMany("Shows") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("ShowMaterials") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowMaterials") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowStaffs") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ShowStaffs") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowTrucks") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Truck", "Truck") - .WithMany("ShowTrucks") - .HasForeignKey("TruckId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Truck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.HasOne("PyroFetes.Models.SoundCategory", "SoundCategory") - .WithMany("Sounds") - .HasForeignKey("SoundCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SoundCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("SoundTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Sound", "Sound") - .WithMany("SoundTimecodes") - .HasForeignKey("SoundId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Sound"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.HasOne("PyroFetes.Models.Availability", "Availability") - .WithMany("StaffAvailabilities") - .HasForeignKey("AvailabilityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffAvailabilities") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Availability"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("StaffContacts") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffContacts") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.HasOne("PyroFetes.Models.HistoryOfApproval", "HistoryOfApproval") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("HistoryOfApprovalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("HistoryOfApproval"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("WarehouseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("WarehouseProducts") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Navigation("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Navigation("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Navigation("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Navigation("Communications"); - - b.Navigation("ContactServiceProviders"); - - b.Navigation("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Navigation("Contacts"); - - b.Navigation("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Navigation("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Navigation("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Navigation("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Navigation("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Navigation("Brands"); - - b.Navigation("Prices"); - - b.Navigation("ProductColors"); - - b.Navigation("ProductDeliveries"); - - b.Navigation("ProductEffects"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("PurchaseProducts"); - - b.Navigation("QuotationProducts"); - - b.Navigation("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Navigation("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Navigation("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Navigation("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Navigation("ContactServiceProviders"); - - b.Navigation("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Navigation("Contracts"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("ShowMaterials"); - - b.Navigation("ShowStaffs"); - - b.Navigation("ShowTrucks"); - - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Navigation("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Navigation("ExperienceLevels"); - - b.Navigation("ShowStaffs"); - - b.Navigation("StaffAvailabilities"); - - b.Navigation("StaffContacts"); - - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Navigation("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Navigation("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("MovementsDestination"); - - b.Navigation("MovementsSource"); - - b.Navigation("WarehouseProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PyroFetes/Migrations/20251010083620_FixingDatabase.Designer.cs b/PyroFetes/Migrations/20251010083620_FixingDatabase.Designer.cs deleted file mode 100644 index 7fcc4e0..0000000 --- a/PyroFetes/Migrations/20251010083620_FixingDatabase.Designer.cs +++ /dev/null @@ -1,1950 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PyroFetes; - -#nullable disable - -namespace PyroFetes.Migrations -{ - [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251010083620_FixingDatabase")] - partial class FixingDatabase - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.20") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AvailabilityDate") - .HasColumnType("date"); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.Property("RenewallDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("Availabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ProductId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Brands"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Classifications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Colors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Calling") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Meeting") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.HasIndex("ContactId"); - - b.ToTable("Communications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Role") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Contacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("ContactServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.Property("TermsAndConditions") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ShowId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("Contract"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CustomerTypeId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerTypeId"); - - b.ToTable("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("CustomerTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Transporter") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Deliverers"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DelivererId") - .HasColumnType("int"); - - b.Property("EstimateDeliveryDate") - .HasColumnType("date"); - - b.Property("ExpeditionDate") - .HasColumnType("date"); - - b.Property("RealDeliveryDate") - .HasColumnType("date"); - - b.Property("TrackingNumber") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("DelivererId"); - - b.ToTable("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.ToTable("Effects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("ExperienceLevels"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("HistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WarehouseId"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.Property("MaterialId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("MaterialId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("MaterialWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Arrival") - .HasColumnType("datetime2"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("DestinationWarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("SourceWarehouseId") - .HasColumnType("int"); - - b.Property("Start") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("DestinationWarehouseId"); - - b.HasIndex("SourceWarehouseId"); - - b.ToTable("Movements"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.Property("SellingPrice") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "SupplierId"); - - b.HasIndex("SupplierId"); - - b.ToTable("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ApprovalNumber") - .HasColumnType("int"); - - b.Property("Caliber") - .HasColumnType("decimal(18,2)"); - - b.Property("ClassificationId") - .HasColumnType("int"); - - b.Property("Duration") - .HasColumnType("decimal(18,2)"); - - b.Property("Image") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Link") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("MinimalQuantity") - .HasColumnType("int"); - - b.Property("MovementId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Nec") - .HasColumnType("decimal(18,2)"); - - b.Property("ProductCategoryId") - .HasColumnType("int"); - - b.Property("Reference") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("Weight") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ClassificationId"); - - b.HasIndex("MovementId"); - - b.HasIndex("ProductCategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProductCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ColorId") - .HasColumnType("int"); - - b.HasKey("ProductId", "ColorId"); - - b.HasIndex("ColorId"); - - b.ToTable("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("DeliveryNoteId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "DeliveryNoteId"); - - b.HasIndex("DeliveryNoteId"); - - b.ToTable("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("EffectId") - .HasColumnType("int"); - - b.HasKey("ProductId", "EffectId"); - - b.HasIndex("EffectId"); - - b.ToTable("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ProductTimecode"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ProviderId"); - - b.HasIndex("ProviderId"); - - b.ToTable("ProviderContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProviderTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PurchaseConditions") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("PurchaseOrders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("PurchaseOrderId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "PurchaseOrderId"); - - b.HasIndex("PurchaseOrderId"); - - b.ToTable("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ConditionsSale") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("QuotationId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "QuotationId"); - - b.HasIndex("QuotationId"); - - b.ToTable("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("ProviderTypeId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProviderTypeId"); - - b.ToTable("Providers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Setting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ElectronicSignature") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Logo") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Settings"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CityId") - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("date"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Place") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("PyrotechnicImplementationPlan") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("MaterialId") - .HasColumnType("int"); - - b.HasKey("ShowId", "MaterialId"); - - b.HasIndex("MaterialId"); - - b.ToTable("ShowMaterial"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.Property("StaffId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.HasKey("StaffId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ShowStaff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("TruckId") - .HasColumnType("int"); - - b.HasKey("ShowId", "TruckId"); - - b.HasIndex("TruckId"); - - b.ToTable("ShowTruck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Artist") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("Duration") - .IsRequired() - .HasColumnType("int"); - - b.Property("Format") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Kind") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("SoundCategoryId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.HasIndex("SoundCategoryId"); - - b.ToTable("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("SoundCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("SoundId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ShowId", "SoundId"); - - b.HasIndex("SoundId"); - - b.ToTable("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("F4T2ExpirationDate") - .HasColumnType("date"); - - b.Property("F4T2NumberApproval") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("Profession") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.Property("AvailabilityId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("AvailabilityId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("ContactId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.Property("HistoryOfApprovalId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("HistoryOfApprovalId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DeliveryDelay") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Suppliers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("MaxExplosiveCapacity") - .IsRequired() - .HasColumnType("float"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("nvarchar(80)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.HasKey("Id"); - - b.ToTable("Trucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Fonction") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Salt") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Current") - .HasColumnType("int"); - - b.Property("MaxWeight") - .HasColumnType("int"); - - b.Property("MinWeight") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Warehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Brands") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("Communications") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Contacts") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("ContactServiceProviders") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("ContactServiceProviders") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("ServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("Contracts") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("Contracts") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ServiceProvider"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.HasOne("PyroFetes.Models.CustomerType", "CustomerType") - .WithMany("Customers") - .HasForeignKey("CustomerTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CustomerType"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.HasOne("PyroFetes.Models.Deliverer", "Deliverer") - .WithMany("DeliveryNotes") - .HasForeignKey("DelivererId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Deliverer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ExperienceLevels") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany() - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("MaterialWarehouses") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("MaterialWarehouses") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "DestinationWarehouse") - .WithMany("MovementsDestination") - .HasForeignKey("DestinationWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("PyroFetes.Models.Warehouse", "SourceWarehouse") - .WithMany("MovementsSource") - .HasForeignKey("SourceWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("DestinationWarehouse"); - - b.Navigation("SourceWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Prices") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Supplier", "Supplier") - .WithMany("Prices") - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Supplier"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.HasOne("PyroFetes.Models.Classification", "Classification") - .WithMany("Products") - .HasForeignKey("ClassificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Movement", "Movement") - .WithMany("Products") - .HasForeignKey("MovementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ProductCategory", "ProductCategory") - .WithMany("Products") - .HasForeignKey("ProductCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Classification"); - - b.Navigation("Movement"); - - b.Navigation("ProductCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.HasOne("PyroFetes.Models.Color", "Color") - .WithMany("ProductColors") - .HasForeignKey("ColorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductColors") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Color"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.HasOne("PyroFetes.Models.DeliveryNote", "DeliveryNote") - .WithMany("ProductDeliveries") - .HasForeignKey("DeliveryNoteId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductDeliveries") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("DeliveryNote"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.HasOne("PyroFetes.Models.Effect", "Effect") - .WithMany("ProductEffects") - .HasForeignKey("EffectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductEffects") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Effect"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductTimecodes") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ProductTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany() - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "Provider") - .WithMany() - .HasForeignKey("ProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("PurchaseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.PurchaseOrder", "PurchaseOrder") - .WithMany("PurchaseProducts") - .HasForeignKey("PurchaseOrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("PurchaseOrder"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Quotations") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("QuotationProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Quotation", "Quotation") - .WithMany("QuotationProducts") - .HasForeignKey("QuotationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Quotation"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.HasOne("PyroFetes.Models.ProviderType", "ProviderType") - .WithMany("ServiceProviders") - .HasForeignKey("ProviderTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ProviderType"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.HasOne("PyroFetes.Models.City", "City") - .WithMany("Shows") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("ShowMaterials") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowMaterials") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowStaffs") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ShowStaffs") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowTrucks") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Truck", "Truck") - .WithMany("ShowTrucks") - .HasForeignKey("TruckId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Truck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.HasOne("PyroFetes.Models.SoundCategory", "SoundCategory") - .WithMany("Sounds") - .HasForeignKey("SoundCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SoundCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("SoundTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Sound", "Sound") - .WithMany("SoundTimecodes") - .HasForeignKey("SoundId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Sound"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.HasOne("PyroFetes.Models.Availability", "Availability") - .WithMany("StaffAvailabilities") - .HasForeignKey("AvailabilityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffAvailabilities") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Availability"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("StaffContacts") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffContacts") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.HasOne("PyroFetes.Models.HistoryOfApproval", "HistoryOfApproval") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("HistoryOfApprovalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("HistoryOfApproval"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("WarehouseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("WarehouseProducts") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Navigation("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Navigation("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Navigation("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Navigation("Communications"); - - b.Navigation("ContactServiceProviders"); - - b.Navigation("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Navigation("Contacts"); - - b.Navigation("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Navigation("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Navigation("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Navigation("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Navigation("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Navigation("Brands"); - - b.Navigation("Prices"); - - b.Navigation("ProductColors"); - - b.Navigation("ProductDeliveries"); - - b.Navigation("ProductEffects"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("PurchaseProducts"); - - b.Navigation("QuotationProducts"); - - b.Navigation("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Navigation("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Navigation("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Navigation("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Navigation("ContactServiceProviders"); - - b.Navigation("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Navigation("Contracts"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("ShowMaterials"); - - b.Navigation("ShowStaffs"); - - b.Navigation("ShowTrucks"); - - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Navigation("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Navigation("ExperienceLevels"); - - b.Navigation("ShowStaffs"); - - b.Navigation("StaffAvailabilities"); - - b.Navigation("StaffContacts"); - - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Navigation("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Navigation("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("MovementsDestination"); - - b.Navigation("MovementsSource"); - - b.Navigation("WarehouseProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PyroFetes/Migrations/20251010083620_FixingDatabase.cs b/PyroFetes/Migrations/20251010083620_FixingDatabase.cs deleted file mode 100644 index 1073d64..0000000 --- a/PyroFetes/Migrations/20251010083620_FixingDatabase.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class FixingDatabase : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "References", - table: "Products"); - - migrationBuilder.DropColumn( - name: "SellingPrice", - table: "Products"); - - migrationBuilder.AddColumn( - name: "Reference", - table: "Products", - type: "nvarchar(20)", - maxLength: 20, - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Reference", - table: "Products"); - - migrationBuilder.AddColumn( - name: "References", - table: "Products", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SellingPrice", - table: "Products", - type: "decimal(18,2)", - nullable: false, - defaultValue: 0m); - } - } -} diff --git a/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.Designer.cs b/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.Designer.cs deleted file mode 100644 index e65403c..0000000 --- a/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.Designer.cs +++ /dev/null @@ -1,1963 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PyroFetes; - -#nullable disable - -namespace PyroFetes.Migrations -{ - [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251013175653_AddingEntitiesInDatabase")] - partial class AddingEntitiesInDatabase - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.20") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AvailabilityDate") - .HasColumnType("date"); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.Property("RenewallDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("Availabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ProductId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Brands"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Cities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Classifications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Colors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Calling") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Meeting") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.HasIndex("ContactId"); - - b.ToTable("Communications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Role") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Contacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("ContactServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.Property("TermsAndConditions") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ShowId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CustomerTypeId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerTypeId"); - - b.ToTable("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("CustomerTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Transporter") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Deliverers"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DelivererId") - .HasColumnType("int"); - - b.Property("EstimateDeliveryDate") - .HasColumnType("date"); - - b.Property("ExpeditionDate") - .HasColumnType("date"); - - b.Property("RealDeliveryDate") - .HasColumnType("date"); - - b.Property("TrackingNumber") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("DelivererId"); - - b.ToTable("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.ToTable("Effects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("ExperienceLevels"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("HistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WarehouseId"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.Property("MaterialId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("MaterialId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("MaterialWarehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Arrival") - .HasColumnType("datetime2"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("DestinationWarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("SourceWarehouseId") - .HasColumnType("int"); - - b.Property("Start") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("DestinationWarehouseId"); - - b.HasIndex("SourceWarehouseId"); - - b.ToTable("Movements"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.Property("SellingPrice") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "SupplierId"); - - b.HasIndex("SupplierId"); - - b.ToTable("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ApprovalNumber") - .HasColumnType("int"); - - b.Property("Caliber") - .HasColumnType("decimal(18,2)"); - - b.Property("ClassificationId") - .HasColumnType("int"); - - b.Property("Duration") - .HasColumnType("decimal(18,2)"); - - b.Property("Image") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Link") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("MinimalQuantity") - .HasColumnType("int"); - - b.Property("MovementId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Nec") - .HasColumnType("decimal(18,2)"); - - b.Property("ProductCategoryId") - .HasColumnType("int"); - - b.Property("Reference") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("Weight") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ClassificationId"); - - b.HasIndex("MovementId"); - - b.HasIndex("ProductCategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProductCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ColorId") - .HasColumnType("int"); - - b.HasKey("ProductId", "ColorId"); - - b.HasIndex("ColorId"); - - b.ToTable("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("DeliveryNoteId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "DeliveryNoteId"); - - b.HasIndex("DeliveryNoteId"); - - b.ToTable("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("EffectId") - .HasColumnType("int"); - - b.HasKey("ProductId", "EffectId"); - - b.HasIndex("EffectId"); - - b.ToTable("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ProductTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ProviderId"); - - b.HasIndex("ProviderId"); - - b.ToTable("ProviderContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProviderTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PurchaseConditions") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("PurchaseOrders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("PurchaseOrderId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "PurchaseOrderId"); - - b.HasIndex("PurchaseOrderId"); - - b.ToTable("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ConditionsSale") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("QuotationId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "QuotationId"); - - b.HasIndex("QuotationId"); - - b.ToTable("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("ProviderTypeId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProviderTypeId"); - - b.ToTable("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.Setting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ElectronicSignature") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Logo") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Settings"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CityId") - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("date"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Place") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("PyrotechnicImplementationPlan") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("MaterialId") - .HasColumnType("int"); - - b.HasKey("ShowId", "MaterialId"); - - b.HasIndex("MaterialId"); - - b.ToTable("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("Id"); - - b.ToTable("ShowServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.Property("StaffId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.HasKey("StaffId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ShowStaffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("TruckId") - .HasColumnType("int"); - - b.HasKey("ShowId", "TruckId"); - - b.HasIndex("TruckId"); - - b.ToTable("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Artist") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("Duration") - .IsRequired() - .HasColumnType("int"); - - b.Property("Format") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Kind") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("SoundCategoryId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.HasIndex("SoundCategoryId"); - - b.ToTable("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("SoundCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("SoundId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ShowId", "SoundId"); - - b.HasIndex("SoundId"); - - b.ToTable("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("F4T2ExpirationDate") - .HasColumnType("date"); - - b.Property("F4T2NumberApproval") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("Profession") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.Property("AvailabilityId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("AvailabilityId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("ContactId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.Property("HistoryOfApprovalId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("HistoryOfApprovalId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DeliveryDelay") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Suppliers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("MaxExplosiveCapacity") - .IsRequired() - .HasColumnType("float"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("nvarchar(80)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.HasKey("Id"); - - b.ToTable("Trucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Fonction") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Salt") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Current") - .HasColumnType("int"); - - b.Property("MaxWeight") - .HasColumnType("int"); - - b.Property("MinWeight") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Warehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Brands") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("Communications") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Contacts") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("ContactServiceProviders") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("ContactServiceProviders") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("ServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("Contracts") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("Contracts") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ServiceProvider"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.HasOne("PyroFetes.Models.CustomerType", "CustomerType") - .WithMany("Customers") - .HasForeignKey("CustomerTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CustomerType"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.HasOne("PyroFetes.Models.Deliverer", "Deliverer") - .WithMany("DeliveryNotes") - .HasForeignKey("DelivererId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Deliverer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ExperienceLevels") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany() - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("MaterialWarehouses") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("MaterialWarehouses") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "DestinationWarehouse") - .WithMany("MovementsDestination") - .HasForeignKey("DestinationWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("PyroFetes.Models.Warehouse", "SourceWarehouse") - .WithMany("MovementsSource") - .HasForeignKey("SourceWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("DestinationWarehouse"); - - b.Navigation("SourceWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Prices") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Supplier", "Supplier") - .WithMany("Prices") - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Supplier"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.HasOne("PyroFetes.Models.Classification", "Classification") - .WithMany("Products") - .HasForeignKey("ClassificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Movement", "Movement") - .WithMany("Products") - .HasForeignKey("MovementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ProductCategory", "ProductCategory") - .WithMany("Products") - .HasForeignKey("ProductCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Classification"); - - b.Navigation("Movement"); - - b.Navigation("ProductCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.HasOne("PyroFetes.Models.Color", "Color") - .WithMany("ProductColors") - .HasForeignKey("ColorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductColors") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Color"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.HasOne("PyroFetes.Models.DeliveryNote", "DeliveryNote") - .WithMany("ProductDeliveries") - .HasForeignKey("DeliveryNoteId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductDeliveries") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("DeliveryNote"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.HasOne("PyroFetes.Models.Effect", "Effect") - .WithMany("ProductEffects") - .HasForeignKey("EffectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductEffects") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Effect"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductTimecodes") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ProductTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany() - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "Provider") - .WithMany() - .HasForeignKey("ProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("PurchaseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.PurchaseOrder", "PurchaseOrder") - .WithMany("PurchaseProducts") - .HasForeignKey("PurchaseOrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("PurchaseOrder"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Quotations") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("QuotationProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Quotation", "Quotation") - .WithMany("QuotationProducts") - .HasForeignKey("QuotationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Quotation"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.HasOne("PyroFetes.Models.ProviderType", "ProviderType") - .WithMany("ServiceProviders") - .HasForeignKey("ProviderTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ProviderType"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.HasOne("PyroFetes.Models.City", "City") - .WithMany("Shows") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("ShowMaterials") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowMaterials") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowStaffs") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ShowStaffs") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowTrucks") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Truck", "Truck") - .WithMany("ShowTrucks") - .HasForeignKey("TruckId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Truck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.HasOne("PyroFetes.Models.SoundCategory", "SoundCategory") - .WithMany("Sounds") - .HasForeignKey("SoundCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SoundCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("SoundTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Sound", "Sound") - .WithMany("SoundTimecodes") - .HasForeignKey("SoundId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Sound"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.HasOne("PyroFetes.Models.Availability", "Availability") - .WithMany("StaffAvailabilities") - .HasForeignKey("AvailabilityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffAvailabilities") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Availability"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("StaffContacts") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffContacts") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.HasOne("PyroFetes.Models.HistoryOfApproval", "HistoryOfApproval") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("HistoryOfApprovalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("HistoryOfApproval"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("WarehouseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("WarehouseProducts") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Navigation("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Navigation("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Navigation("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Navigation("Communications"); - - b.Navigation("ContactServiceProviders"); - - b.Navigation("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Navigation("Contacts"); - - b.Navigation("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Navigation("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Navigation("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Navigation("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Navigation("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Navigation("Brands"); - - b.Navigation("Prices"); - - b.Navigation("ProductColors"); - - b.Navigation("ProductDeliveries"); - - b.Navigation("ProductEffects"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("PurchaseProducts"); - - b.Navigation("QuotationProducts"); - - b.Navigation("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Navigation("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Navigation("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Navigation("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Navigation("ContactServiceProviders"); - - b.Navigation("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Navigation("Contracts"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("ShowMaterials"); - - b.Navigation("ShowStaffs"); - - b.Navigation("ShowTrucks"); - - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Navigation("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Navigation("ExperienceLevels"); - - b.Navigation("ShowStaffs"); - - b.Navigation("StaffAvailabilities"); - - b.Navigation("StaffContacts"); - - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Navigation("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Navigation("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("MovementsDestination"); - - b.Navigation("MovementsSource"); - - b.Navigation("WarehouseProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.cs b/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.cs deleted file mode 100644 index bad3dff..0000000 --- a/PyroFetes/Migrations/20251013175653_AddingEntitiesInDatabase.cs +++ /dev/null @@ -1,755 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class AddingEntitiesInDatabase : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ContactServiceProvider_Contacts_ContactId", - table: "ContactServiceProvider"); - - migrationBuilder.DropForeignKey( - name: "FK_ContactServiceProvider_Providers_ServiceProviderId", - table: "ContactServiceProvider"); - - migrationBuilder.DropForeignKey( - name: "FK_Contract_Providers_ServiceProviderId", - table: "Contract"); - - migrationBuilder.DropForeignKey( - name: "FK_Contract_Shows_ShowId", - table: "Contract"); - - migrationBuilder.DropForeignKey( - name: "FK_MaterialWarehouse_Materials_MaterialId", - table: "MaterialWarehouse"); - - migrationBuilder.DropForeignKey( - name: "FK_MaterialWarehouse_Warehouses_WarehouseId", - table: "MaterialWarehouse"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductTimecode_Products_ProductId", - table: "ProductTimecode"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductTimecode_Shows_ShowId", - table: "ProductTimecode"); - - migrationBuilder.DropForeignKey( - name: "FK_ProviderContacts_Providers_ProviderId", - table: "ProviderContacts"); - - migrationBuilder.DropForeignKey( - name: "FK_Providers_ProviderTypes_ProviderTypeId", - table: "Providers"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowMaterial_Materials_MaterialId", - table: "ShowMaterial"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowMaterial_Shows_ShowId", - table: "ShowMaterial"); - - migrationBuilder.DropForeignKey( - name: "FK_Shows_City_CityId", - table: "Shows"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowStaff_Shows_ShowId", - table: "ShowStaff"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowStaff_Staffs_StaffId", - table: "ShowStaff"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowTruck_Shows_ShowId", - table: "ShowTruck"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowTruck_Trucks_TruckId", - table: "ShowTruck"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowTruck", - table: "ShowTruck"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowStaff", - table: "ShowStaff"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowMaterial", - table: "ShowMaterial"); - - migrationBuilder.DropPrimaryKey( - name: "PK_Providers", - table: "Providers"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ProductTimecode", - table: "ProductTimecode"); - - migrationBuilder.DropPrimaryKey( - name: "PK_MaterialWarehouse", - table: "MaterialWarehouse"); - - migrationBuilder.DropPrimaryKey( - name: "PK_Contract", - table: "Contract"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ContactServiceProvider", - table: "ContactServiceProvider"); - - migrationBuilder.DropPrimaryKey( - name: "PK_City", - table: "City"); - - migrationBuilder.RenameTable( - name: "ShowTruck", - newName: "ShowTrucks"); - - migrationBuilder.RenameTable( - name: "ShowStaff", - newName: "ShowStaffs"); - - migrationBuilder.RenameTable( - name: "ShowMaterial", - newName: "ShowMaterials"); - - migrationBuilder.RenameTable( - name: "Providers", - newName: "ServiceProviders"); - - migrationBuilder.RenameTable( - name: "ProductTimecode", - newName: "ProductTimecodes"); - - migrationBuilder.RenameTable( - name: "MaterialWarehouse", - newName: "MaterialWarehouses"); - - migrationBuilder.RenameTable( - name: "Contract", - newName: "Contracts"); - - migrationBuilder.RenameTable( - name: "ContactServiceProvider", - newName: "ContactServiceProviders"); - - migrationBuilder.RenameTable( - name: "City", - newName: "Cities"); - - migrationBuilder.RenameIndex( - name: "IX_ShowTruck_TruckId", - table: "ShowTrucks", - newName: "IX_ShowTrucks_TruckId"); - - migrationBuilder.RenameIndex( - name: "IX_ShowStaff_ShowId", - table: "ShowStaffs", - newName: "IX_ShowStaffs_ShowId"); - - migrationBuilder.RenameIndex( - name: "IX_ShowMaterial_MaterialId", - table: "ShowMaterials", - newName: "IX_ShowMaterials_MaterialId"); - - migrationBuilder.RenameIndex( - name: "IX_Providers_ProviderTypeId", - table: "ServiceProviders", - newName: "IX_ServiceProviders_ProviderTypeId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductTimecode_ShowId", - table: "ProductTimecodes", - newName: "IX_ProductTimecodes_ShowId"); - - migrationBuilder.RenameIndex( - name: "IX_MaterialWarehouse_WarehouseId", - table: "MaterialWarehouses", - newName: "IX_MaterialWarehouses_WarehouseId"); - - migrationBuilder.RenameIndex( - name: "IX_Contract_ServiceProviderId", - table: "Contracts", - newName: "IX_Contracts_ServiceProviderId"); - - migrationBuilder.RenameIndex( - name: "IX_ContactServiceProvider_ServiceProviderId", - table: "ContactServiceProviders", - newName: "IX_ContactServiceProviders_ServiceProviderId"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowTrucks", - table: "ShowTrucks", - columns: new[] { "ShowId", "TruckId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowStaffs", - table: "ShowStaffs", - columns: new[] { "StaffId", "ShowId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowMaterials", - table: "ShowMaterials", - columns: new[] { "ShowId", "MaterialId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ServiceProviders", - table: "ServiceProviders", - column: "Id"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProductTimecodes", - table: "ProductTimecodes", - columns: new[] { "ProductId", "ShowId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_MaterialWarehouses", - table: "MaterialWarehouses", - columns: new[] { "MaterialId", "WarehouseId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_Contracts", - table: "Contracts", - columns: new[] { "ShowId", "ServiceProviderId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ContactServiceProviders", - table: "ContactServiceProviders", - columns: new[] { "ContactId", "ServiceProviderId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_Cities", - table: "Cities", - column: "Id"); - - migrationBuilder.CreateTable( - name: "ShowServiceProviders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1") - }, - constraints: table => - { - table.PrimaryKey("PK_ShowServiceProviders", x => x.Id); - }); - - migrationBuilder.AddForeignKey( - name: "FK_ContactServiceProviders_Contacts_ContactId", - table: "ContactServiceProviders", - column: "ContactId", - principalTable: "Contacts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ContactServiceProviders_ServiceProviders_ServiceProviderId", - table: "ContactServiceProviders", - column: "ServiceProviderId", - principalTable: "ServiceProviders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Contracts_ServiceProviders_ServiceProviderId", - table: "Contracts", - column: "ServiceProviderId", - principalTable: "ServiceProviders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Contracts_Shows_ShowId", - table: "Contracts", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_MaterialWarehouses_Materials_MaterialId", - table: "MaterialWarehouses", - column: "MaterialId", - principalTable: "Materials", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_MaterialWarehouses_Warehouses_WarehouseId", - table: "MaterialWarehouses", - column: "WarehouseId", - principalTable: "Warehouses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_ProductTimecodes_Products_ProductId", - table: "ProductTimecodes", - column: "ProductId", - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ProductTimecodes_Shows_ShowId", - table: "ProductTimecodes", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ProviderContacts_ServiceProviders_ProviderId", - table: "ProviderContacts", - column: "ProviderId", - principalTable: "ServiceProviders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId", - table: "ServiceProviders", - column: "ProviderTypeId", - principalTable: "ProviderTypes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowMaterials_Materials_MaterialId", - table: "ShowMaterials", - column: "MaterialId", - principalTable: "Materials", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowMaterials_Shows_ShowId", - table: "ShowMaterials", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Shows_Cities_CityId", - table: "Shows", - column: "CityId", - principalTable: "Cities", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowStaffs_Shows_ShowId", - table: "ShowStaffs", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowStaffs_Staffs_StaffId", - table: "ShowStaffs", - column: "StaffId", - principalTable: "Staffs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowTrucks_Shows_ShowId", - table: "ShowTrucks", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowTrucks_Trucks_TruckId", - table: "ShowTrucks", - column: "TruckId", - principalTable: "Trucks", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ContactServiceProviders_Contacts_ContactId", - table: "ContactServiceProviders"); - - migrationBuilder.DropForeignKey( - name: "FK_ContactServiceProviders_ServiceProviders_ServiceProviderId", - table: "ContactServiceProviders"); - - migrationBuilder.DropForeignKey( - name: "FK_Contracts_ServiceProviders_ServiceProviderId", - table: "Contracts"); - - migrationBuilder.DropForeignKey( - name: "FK_Contracts_Shows_ShowId", - table: "Contracts"); - - migrationBuilder.DropForeignKey( - name: "FK_MaterialWarehouses_Materials_MaterialId", - table: "MaterialWarehouses"); - - migrationBuilder.DropForeignKey( - name: "FK_MaterialWarehouses_Warehouses_WarehouseId", - table: "MaterialWarehouses"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductTimecodes_Products_ProductId", - table: "ProductTimecodes"); - - migrationBuilder.DropForeignKey( - name: "FK_ProductTimecodes_Shows_ShowId", - table: "ProductTimecodes"); - - migrationBuilder.DropForeignKey( - name: "FK_ProviderContacts_ServiceProviders_ProviderId", - table: "ProviderContacts"); - - migrationBuilder.DropForeignKey( - name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId", - table: "ServiceProviders"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowMaterials_Materials_MaterialId", - table: "ShowMaterials"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowMaterials_Shows_ShowId", - table: "ShowMaterials"); - - migrationBuilder.DropForeignKey( - name: "FK_Shows_Cities_CityId", - table: "Shows"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowStaffs_Shows_ShowId", - table: "ShowStaffs"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowStaffs_Staffs_StaffId", - table: "ShowStaffs"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowTrucks_Shows_ShowId", - table: "ShowTrucks"); - - migrationBuilder.DropForeignKey( - name: "FK_ShowTrucks_Trucks_TruckId", - table: "ShowTrucks"); - - migrationBuilder.DropTable( - name: "ShowServiceProviders"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowTrucks", - table: "ShowTrucks"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowStaffs", - table: "ShowStaffs"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ShowMaterials", - table: "ShowMaterials"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ServiceProviders", - table: "ServiceProviders"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ProductTimecodes", - table: "ProductTimecodes"); - - migrationBuilder.DropPrimaryKey( - name: "PK_MaterialWarehouses", - table: "MaterialWarehouses"); - - migrationBuilder.DropPrimaryKey( - name: "PK_Contracts", - table: "Contracts"); - - migrationBuilder.DropPrimaryKey( - name: "PK_ContactServiceProviders", - table: "ContactServiceProviders"); - - migrationBuilder.DropPrimaryKey( - name: "PK_Cities", - table: "Cities"); - - migrationBuilder.RenameTable( - name: "ShowTrucks", - newName: "ShowTruck"); - - migrationBuilder.RenameTable( - name: "ShowStaffs", - newName: "ShowStaff"); - - migrationBuilder.RenameTable( - name: "ShowMaterials", - newName: "ShowMaterial"); - - migrationBuilder.RenameTable( - name: "ServiceProviders", - newName: "Providers"); - - migrationBuilder.RenameTable( - name: "ProductTimecodes", - newName: "ProductTimecode"); - - migrationBuilder.RenameTable( - name: "MaterialWarehouses", - newName: "MaterialWarehouse"); - - migrationBuilder.RenameTable( - name: "Contracts", - newName: "Contract"); - - migrationBuilder.RenameTable( - name: "ContactServiceProviders", - newName: "ContactServiceProvider"); - - migrationBuilder.RenameTable( - name: "Cities", - newName: "City"); - - migrationBuilder.RenameIndex( - name: "IX_ShowTrucks_TruckId", - table: "ShowTruck", - newName: "IX_ShowTruck_TruckId"); - - migrationBuilder.RenameIndex( - name: "IX_ShowStaffs_ShowId", - table: "ShowStaff", - newName: "IX_ShowStaff_ShowId"); - - migrationBuilder.RenameIndex( - name: "IX_ShowMaterials_MaterialId", - table: "ShowMaterial", - newName: "IX_ShowMaterial_MaterialId"); - - migrationBuilder.RenameIndex( - name: "IX_ServiceProviders_ProviderTypeId", - table: "Providers", - newName: "IX_Providers_ProviderTypeId"); - - migrationBuilder.RenameIndex( - name: "IX_ProductTimecodes_ShowId", - table: "ProductTimecode", - newName: "IX_ProductTimecode_ShowId"); - - migrationBuilder.RenameIndex( - name: "IX_MaterialWarehouses_WarehouseId", - table: "MaterialWarehouse", - newName: "IX_MaterialWarehouse_WarehouseId"); - - migrationBuilder.RenameIndex( - name: "IX_Contracts_ServiceProviderId", - table: "Contract", - newName: "IX_Contract_ServiceProviderId"); - - migrationBuilder.RenameIndex( - name: "IX_ContactServiceProviders_ServiceProviderId", - table: "ContactServiceProvider", - newName: "IX_ContactServiceProvider_ServiceProviderId"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowTruck", - table: "ShowTruck", - columns: new[] { "ShowId", "TruckId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowStaff", - table: "ShowStaff", - columns: new[] { "StaffId", "ShowId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ShowMaterial", - table: "ShowMaterial", - columns: new[] { "ShowId", "MaterialId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_Providers", - table: "Providers", - column: "Id"); - - migrationBuilder.AddPrimaryKey( - name: "PK_ProductTimecode", - table: "ProductTimecode", - columns: new[] { "ProductId", "ShowId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_MaterialWarehouse", - table: "MaterialWarehouse", - columns: new[] { "MaterialId", "WarehouseId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_Contract", - table: "Contract", - columns: new[] { "ShowId", "ServiceProviderId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_ContactServiceProvider", - table: "ContactServiceProvider", - columns: new[] { "ContactId", "ServiceProviderId" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_City", - table: "City", - column: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_ContactServiceProvider_Contacts_ContactId", - table: "ContactServiceProvider", - column: "ContactId", - principalTable: "Contacts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ContactServiceProvider_Providers_ServiceProviderId", - table: "ContactServiceProvider", - column: "ServiceProviderId", - principalTable: "Providers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Contract_Providers_ServiceProviderId", - table: "Contract", - column: "ServiceProviderId", - principalTable: "Providers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Contract_Shows_ShowId", - table: "Contract", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_MaterialWarehouse_Materials_MaterialId", - table: "MaterialWarehouse", - column: "MaterialId", - principalTable: "Materials", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_MaterialWarehouse_Warehouses_WarehouseId", - table: "MaterialWarehouse", - column: "WarehouseId", - principalTable: "Warehouses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_ProductTimecode_Products_ProductId", - table: "ProductTimecode", - column: "ProductId", - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ProductTimecode_Shows_ShowId", - table: "ProductTimecode", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ProviderContacts_Providers_ProviderId", - table: "ProviderContacts", - column: "ProviderId", - principalTable: "Providers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Providers_ProviderTypes_ProviderTypeId", - table: "Providers", - column: "ProviderTypeId", - principalTable: "ProviderTypes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowMaterial_Materials_MaterialId", - table: "ShowMaterial", - column: "MaterialId", - principalTable: "Materials", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowMaterial_Shows_ShowId", - table: "ShowMaterial", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_Shows_City_CityId", - table: "Shows", - column: "CityId", - principalTable: "City", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowStaff_Shows_ShowId", - table: "ShowStaff", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowStaff_Staffs_StaffId", - table: "ShowStaff", - column: "StaffId", - principalTable: "Staffs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowTruck_Shows_ShowId", - table: "ShowTruck", - column: "ShowId", - principalTable: "Shows", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_ShowTruck_Trucks_TruckId", - table: "ShowTruck", - column: "TruckId", - principalTable: "Trucks", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/PyroFetes/Migrations/20251113162655_FixedNullableValue.Designer.cs b/PyroFetes/Migrations/20251113162655_FixedNullableValue.Designer.cs deleted file mode 100644 index 131aa6e..0000000 --- a/PyroFetes/Migrations/20251113162655_FixedNullableValue.Designer.cs +++ /dev/null @@ -1,1963 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using PyroFetes; - -#nullable disable - -namespace PyroFetes.Migrations -{ - [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251113162655_FixedNullableValue")] - partial class FixedNullableValue - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.20") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AvailabilityDate") - .HasColumnType("date"); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.Property("RenewallDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("Availabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ProductId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProductId"); - - b.ToTable("Brands"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Cities"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Classifications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Colors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Calling") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Meeting") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.HasIndex("ContactId"); - - b.ToTable("Communications"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Role") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Contacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("ContactServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("ServiceProviderId") - .HasColumnType("int"); - - b.Property("TermsAndConditions") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ShowId", "ServiceProviderId"); - - b.HasIndex("ServiceProviderId"); - - b.ToTable("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CustomerTypeId") - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerTypeId"); - - b.ToTable("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("CustomerTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Transporter") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Deliverers"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DelivererId") - .HasColumnType("int"); - - b.Property("EstimateDeliveryDate") - .HasColumnType("date"); - - b.Property("ExpeditionDate") - .HasColumnType("date"); - - b.Property("RealDeliveryDate") - .HasColumnType("date"); - - b.Property("TrackingNumber") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("DelivererId"); - - b.ToTable("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.ToTable("Effects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("ExperienceLevels"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeliveryDate") - .HasColumnType("date"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Id"); - - b.ToTable("HistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WarehouseId"); - - b.ToTable("Materials"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.Property("MaterialId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.HasKey("MaterialId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("MaterialWarehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Arrival") - .HasColumnType("datetime2"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("DestinationWarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("SourceWarehouseId") - .HasColumnType("int"); - - b.Property("Start") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("DestinationWarehouseId"); - - b.HasIndex("SourceWarehouseId"); - - b.ToTable("Movements"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.Property("SellingPrice") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "SupplierId"); - - b.HasIndex("SupplierId"); - - b.ToTable("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ApprovalNumber") - .HasColumnType("int"); - - b.Property("Caliber") - .HasColumnType("decimal(18,2)"); - - b.Property("ClassificationId") - .HasColumnType("int"); - - b.Property("Duration") - .HasColumnType("decimal(18,2)"); - - b.Property("Image") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Link") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("MinimalQuantity") - .HasColumnType("int"); - - b.Property("MovementId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Nec") - .HasColumnType("decimal(18,2)"); - - b.Property("ProductCategoryId") - .HasColumnType("int"); - - b.Property("Reference") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("Weight") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ClassificationId"); - - b.HasIndex("MovementId"); - - b.HasIndex("ProductCategoryId"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProductCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ColorId") - .HasColumnType("int"); - - b.HasKey("ProductId", "ColorId"); - - b.HasIndex("ColorId"); - - b.ToTable("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("DeliveryNoteId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "DeliveryNoteId"); - - b.HasIndex("DeliveryNoteId"); - - b.ToTable("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("EffectId") - .HasColumnType("int"); - - b.HasKey("ProductId", "EffectId"); - - b.HasIndex("EffectId"); - - b.ToTable("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ProductId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ProductTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("ProviderId") - .HasColumnType("int"); - - b.HasKey("ContactId", "ProviderId"); - - b.HasIndex("ProviderId"); - - b.ToTable("ProviderContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Label") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("ProviderTypes"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PurchaseConditions") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("PurchaseOrders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("PurchaseOrderId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "PurchaseOrderId"); - - b.HasIndex("PurchaseOrderId"); - - b.ToTable("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ConditionsSale") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("CustomerId") - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("CustomerId"); - - b.ToTable("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("QuotationId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "QuotationId"); - - b.HasIndex("QuotationId"); - - b.ToTable("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("ProviderTypeId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ProviderTypeId"); - - b.ToTable("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.Setting", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ElectronicSignature") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Logo") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Settings"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CityId") - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("date"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Place") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("PyrotechnicImplementationPlan") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("MaterialId") - .HasColumnType("int"); - - b.HasKey("ShowId", "MaterialId"); - - b.HasIndex("MaterialId"); - - b.ToTable("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowServiceProvider", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.HasKey("Id"); - - b.ToTable("ShowServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.Property("StaffId") - .HasColumnType("int"); - - b.Property("ShowId") - .HasColumnType("int"); - - b.HasKey("StaffId", "ShowId"); - - b.HasIndex("ShowId"); - - b.ToTable("ShowStaffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("TruckId") - .HasColumnType("int"); - - b.HasKey("ShowId", "TruckId"); - - b.HasIndex("TruckId"); - - b.ToTable("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Artist") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("Duration") - .IsRequired() - .HasColumnType("int"); - - b.Property("Format") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Kind") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("SoundCategoryId") - .HasColumnType("int"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.HasKey("Id"); - - b.HasIndex("SoundCategoryId"); - - b.ToTable("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("SoundCategories"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.Property("ShowId") - .HasColumnType("int"); - - b.Property("SoundId") - .HasColumnType("int"); - - b.Property("End") - .HasColumnType("decimal(18,2)"); - - b.Property("Start") - .HasColumnType("decimal(18,2)"); - - b.HasKey("ShowId", "SoundId"); - - b.HasIndex("SoundId"); - - b.ToTable("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(120) - .HasColumnType("nvarchar(120)"); - - b.Property("F4T2ExpirationDate") - .HasColumnType("date"); - - b.Property("F4T2NumberApproval") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(60) - .HasColumnType("nvarchar(60)"); - - b.Property("Profession") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.Property("AvailabilityId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("AvailabilityId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.Property("ContactId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("ContactId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.Property("HistoryOfApprovalId") - .HasColumnType("int"); - - b.Property("StaffId") - .HasColumnType("int"); - - b.HasKey("HistoryOfApprovalId", "StaffId"); - - b.HasIndex("StaffId"); - - b.ToTable("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DeliveryDelay") - .HasColumnType("int"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Phone") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Suppliers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("MaxExplosiveCapacity") - .IsRequired() - .HasColumnType("float"); - - b.Property("Sizes") - .IsRequired() - .HasMaxLength(80) - .HasColumnType("nvarchar(80)"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(40) - .HasColumnType("nvarchar(40)"); - - b.HasKey("Id"); - - b.ToTable("Trucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Fonction") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Password") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Salt") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Current") - .HasColumnType("int"); - - b.Property("MaxWeight") - .HasColumnType("int"); - - b.Property("MinWeight") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ZipCode") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Warehouses"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.Property("ProductId") - .HasColumnType("int"); - - b.Property("WarehouseId") - .HasColumnType("int"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.HasKey("ProductId", "WarehouseId"); - - b.HasIndex("WarehouseId"); - - b.ToTable("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Brand", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Brands") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.Communication", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("Communications") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Contacts") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("ContactServiceProviders") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("ContactServiceProviders") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("ServiceProvider"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contract", b => - { - b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") - .WithMany("Contracts") - .HasForeignKey("ServiceProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("Contracts") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ServiceProvider"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.HasOne("PyroFetes.Models.CustomerType", "CustomerType") - .WithMany("Customers") - .HasForeignKey("CustomerTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CustomerType"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.HasOne("PyroFetes.Models.Deliverer", "Deliverer") - .WithMany("DeliveryNotes") - .HasForeignKey("DelivererId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Deliverer"); - }); - - modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => - { - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ExperienceLevels") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany() - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("MaterialWarehouses") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("MaterialWarehouses") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.HasOne("PyroFetes.Models.Warehouse", "DestinationWarehouse") - .WithMany("MovementsDestination") - .HasForeignKey("DestinationWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("PyroFetes.Models.Warehouse", "SourceWarehouse") - .WithMany("MovementsSource") - .HasForeignKey("SourceWarehouseId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("DestinationWarehouse"); - - b.Navigation("SourceWarehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Price", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("Prices") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Supplier", "Supplier") - .WithMany("Prices") - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Supplier"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.HasOne("PyroFetes.Models.Classification", "Classification") - .WithMany("Products") - .HasForeignKey("ClassificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Movement", "Movement") - .WithMany("Products") - .HasForeignKey("MovementId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ProductCategory", "ProductCategory") - .WithMany("Products") - .HasForeignKey("ProductCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Classification"); - - b.Navigation("Movement"); - - b.Navigation("ProductCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductColor", b => - { - b.HasOne("PyroFetes.Models.Color", "Color") - .WithMany("ProductColors") - .HasForeignKey("ColorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductColors") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Color"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => - { - b.HasOne("PyroFetes.Models.DeliveryNote", "DeliveryNote") - .WithMany("ProductDeliveries") - .HasForeignKey("DeliveryNoteId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductDeliveries") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("DeliveryNote"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => - { - b.HasOne("PyroFetes.Models.Effect", "Effect") - .WithMany("ProductEffects") - .HasForeignKey("EffectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductEffects") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Effect"); - - b.Navigation("Product"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("ProductTimecodes") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ProductTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany() - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.ServiceProvider", "Provider") - .WithMany() - .HasForeignKey("ProviderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Provider"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("PurchaseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.PurchaseOrder", "PurchaseOrder") - .WithMany("PurchaseProducts") - .HasForeignKey("PurchaseOrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("PurchaseOrder"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.HasOne("PyroFetes.Models.Customer", "Customer") - .WithMany("Quotations") - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Customer"); - }); - - modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("QuotationProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Quotation", "Quotation") - .WithMany("QuotationProducts") - .HasForeignKey("QuotationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Quotation"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.HasOne("PyroFetes.Models.ProviderType", "ProviderType") - .WithMany("ServiceProviders") - .HasForeignKey("ProviderTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ProviderType"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.HasOne("PyroFetes.Models.City", "City") - .WithMany("Shows") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => - { - b.HasOne("PyroFetes.Models.Material", "Material") - .WithMany("ShowMaterials") - .HasForeignKey("MaterialId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowMaterials") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Material"); - - b.Navigation("Show"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowStaffs") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ShowStaffs") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("ShowTrucks") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Truck", "Truck") - .WithMany("ShowTrucks") - .HasForeignKey("TruckId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Truck"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.HasOne("PyroFetes.Models.SoundCategory", "SoundCategory") - .WithMany("Sounds") - .HasForeignKey("SoundCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("SoundCategory"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => - { - b.HasOne("PyroFetes.Models.Show", "Show") - .WithMany("SoundTimecodes") - .HasForeignKey("ShowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Sound", "Sound") - .WithMany("SoundTimecodes") - .HasForeignKey("SoundId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Show"); - - b.Navigation("Sound"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => - { - b.HasOne("PyroFetes.Models.Availability", "Availability") - .WithMany("StaffAvailabilities") - .HasForeignKey("AvailabilityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffAvailabilities") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Availability"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffContact", b => - { - b.HasOne("PyroFetes.Models.Contact", "Contact") - .WithMany("StaffContacts") - .HasForeignKey("ContactId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffContacts") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Contact"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => - { - b.HasOne("PyroFetes.Models.HistoryOfApproval", "HistoryOfApproval") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("HistoryOfApprovalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("StaffHistoryOfApprovals") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("HistoryOfApproval"); - - b.Navigation("Staff"); - }); - - modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => - { - b.HasOne("PyroFetes.Models.Product", "Product") - .WithMany("WarehouseProducts") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") - .WithMany("WarehouseProducts") - .HasForeignKey("WarehouseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Warehouse"); - }); - - modelBuilder.Entity("PyroFetes.Models.Availability", b => - { - b.Navigation("StaffAvailabilities"); - }); - - modelBuilder.Entity("PyroFetes.Models.City", b => - { - b.Navigation("Shows"); - }); - - modelBuilder.Entity("PyroFetes.Models.Classification", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Color", b => - { - b.Navigation("ProductColors"); - }); - - modelBuilder.Entity("PyroFetes.Models.Contact", b => - { - b.Navigation("Communications"); - - b.Navigation("ContactServiceProviders"); - - b.Navigation("StaffContacts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Customer", b => - { - b.Navigation("Contacts"); - - b.Navigation("Quotations"); - }); - - modelBuilder.Entity("PyroFetes.Models.CustomerType", b => - { - b.Navigation("Customers"); - }); - - modelBuilder.Entity("PyroFetes.Models.Deliverer", b => - { - b.Navigation("DeliveryNotes"); - }); - - modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => - { - b.Navigation("ProductDeliveries"); - }); - - modelBuilder.Entity("PyroFetes.Models.Effect", b => - { - b.Navigation("ProductEffects"); - }); - - modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => - { - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Material", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("ShowMaterials"); - }); - - modelBuilder.Entity("PyroFetes.Models.Movement", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.Product", b => - { - b.Navigation("Brands"); - - b.Navigation("Prices"); - - b.Navigation("ProductColors"); - - b.Navigation("ProductDeliveries"); - - b.Navigation("ProductEffects"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("PurchaseProducts"); - - b.Navigation("QuotationProducts"); - - b.Navigation("WarehouseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => - { - b.Navigation("Products"); - }); - - modelBuilder.Entity("PyroFetes.Models.ProviderType", b => - { - b.Navigation("ServiceProviders"); - }); - - modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => - { - b.Navigation("PurchaseProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Quotation", b => - { - b.Navigation("QuotationProducts"); - }); - - modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => - { - b.Navigation("ContactServiceProviders"); - - b.Navigation("Contracts"); - }); - - modelBuilder.Entity("PyroFetes.Models.Show", b => - { - b.Navigation("Contracts"); - - b.Navigation("ProductTimecodes"); - - b.Navigation("ShowMaterials"); - - b.Navigation("ShowStaffs"); - - b.Navigation("ShowTrucks"); - - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.Sound", b => - { - b.Navigation("SoundTimecodes"); - }); - - modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => - { - b.Navigation("Sounds"); - }); - - modelBuilder.Entity("PyroFetes.Models.Staff", b => - { - b.Navigation("ExperienceLevels"); - - b.Navigation("ShowStaffs"); - - b.Navigation("StaffAvailabilities"); - - b.Navigation("StaffContacts"); - - b.Navigation("StaffHistoryOfApprovals"); - }); - - modelBuilder.Entity("PyroFetes.Models.Supplier", b => - { - b.Navigation("Prices"); - }); - - modelBuilder.Entity("PyroFetes.Models.Truck", b => - { - b.Navigation("ShowTrucks"); - }); - - modelBuilder.Entity("PyroFetes.Models.Warehouse", b => - { - b.Navigation("MaterialWarehouses"); - - b.Navigation("MovementsDestination"); - - b.Navigation("MovementsSource"); - - b.Navigation("WarehouseProducts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PyroFetes/Migrations/20251113162655_FixedNullableValue.cs b/PyroFetes/Migrations/20251113162655_FixedNullableValue.cs deleted file mode 100644 index 0fe6098..0000000 --- a/PyroFetes/Migrations/20251113162655_FixedNullableValue.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class FixedNullableValue : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "RealDeliveryDate", - table: "DeliveryNotes", - type: "date", - nullable: true, - oldClrType: typeof(DateOnly), - oldType: "date"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "RealDeliveryDate", - table: "DeliveryNotes", - type: "date", - nullable: false, - defaultValue: new DateOnly(1, 1, 1), - oldClrType: typeof(DateOnly), - oldType: "date", - oldNullable: true); - } - } -} diff --git a/PyroFetes/Migrations/20251120154429_FixTypeErrors.cs b/PyroFetes/Migrations/20251120154429_FixTypeErrors.cs deleted file mode 100644 index b8c2f9c..0000000 --- a/PyroFetes/Migrations/20251120154429_FixTypeErrors.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class FixTypeErrors : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Suppliers", - type: "nvarchar(5)", - maxLength: 5, - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "Caliber", - table: "Products", - type: "int", - nullable: false, - oldClrType: typeof(decimal), - oldType: "decimal(18,2)"); - - migrationBuilder.AlterColumn( - name: "ApprovalNumber", - table: "Products", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Suppliers", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(5)", - oldMaxLength: 5); - - migrationBuilder.AlterColumn( - name: "Caliber", - table: "Products", - type: "decimal(18,2)", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "ApprovalNumber", - table: "Products", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - } -} diff --git a/PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.cs b/PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.cs deleted file mode 100644 index ee74644..0000000 --- a/PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class UpdatedDatabaseProductType : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ApprovalNumber", - table: "Products", - type: "nvarchar(100)", - maxLength: 100, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ApprovalNumber", - table: "Products", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(100)", - oldMaxLength: 100); - } - } -} diff --git a/PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.cs b/PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.cs deleted file mode 100644 index 23930f4..0000000 --- a/PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class UpdatedLengthOfPassword : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Password", - table: "Users", - type: "nvarchar(60)", - maxLength: 60, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Password", - table: "Users", - type: "nvarchar(50)", - maxLength: 50, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(60)", - oldMaxLength: 60); - } - } -} diff --git a/PyroFetes/Migrations/20251127133430_FixZipCode.cs b/PyroFetes/Migrations/20251127133430_FixZipCode.cs deleted file mode 100644 index 64c68f2..0000000 --- a/PyroFetes/Migrations/20251127133430_FixZipCode.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PyroFetes.Migrations -{ - /// - public partial class FixZipCode : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Warehouses", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Suppliers", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(5)", - oldMaxLength: 5); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Warehouses", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "ZipCode", - table: "Suppliers", - type: "nvarchar(5)", - maxLength: 5, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - } -} diff --git a/PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.Designer.cs b/PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.Designer.cs similarity index 98% rename from PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.Designer.cs rename to PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.Designer.cs index 1cc2af1..64f7315 100644 --- a/PyroFetes/Migrations/20251127124107_UpdatedLengthOfPassword.Designer.cs +++ b/PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.Designer.cs @@ -12,8 +12,8 @@ using PyroFetes; namespace PyroFetes.Migrations { [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251127124107_UpdatedLengthOfPassword")] - partial class UpdatedLengthOfPassword + [Migration("20260326145104_AddSupplierToPurchaseOrder")] + partial class AddSupplierToPurchaseOrder { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -698,8 +698,13 @@ namespace PyroFetes.Migrations .HasMaxLength(300) .HasColumnType("nvarchar(300)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); + b.HasIndex("SupplierId"); + b.ToTable("PurchaseOrders"); }); @@ -1120,8 +1125,7 @@ namespace PyroFetes.Migrations b.Property("ZipCode") .IsRequired() - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1230,8 +1234,9 @@ namespace PyroFetes.Migrations .HasMaxLength(100) .HasColumnType("nvarchar(100)"); - b.Property("ZipCode") - .HasColumnType("int"); + b.Property("ZipCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1548,6 +1553,17 @@ namespace PyroFetes.Migrations b.Navigation("Provider"); }); + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => { b.HasOne("PyroFetes.Models.Product", "Product") diff --git a/PyroFetes/Migrations/20251008103414_InitialDatabase.cs b/PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.cs similarity index 91% rename from PyroFetes/Migrations/20251008103414_InitialDatabase.cs rename to PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.cs index 5c5dbc7..fa6d143 100644 --- a/PyroFetes/Migrations/20251008103414_InitialDatabase.cs +++ b/PyroFetes/Migrations/20260326145104_AddSupplierToPurchaseOrder.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace PyroFetes.Migrations { /// - public partial class InitialDatabase : Migration + public partial class AddSupplierToPurchaseOrder : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -28,7 +28,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "City", + name: "Cities", columns: table => new { Id = table.Column(type: "int", nullable: false) @@ -38,7 +38,7 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_City", x => x.Id); + table.PrimaryKey("PK_Cities", x => x.Id); }); migrationBuilder.CreateTable( @@ -146,19 +146,6 @@ namespace PyroFetes.Migrations table.PrimaryKey("PK_ProviderTypes", x => x.Id); }); - migrationBuilder.CreateTable( - name: "PurchaseOrders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PurchaseConditions = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PurchaseOrders", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Settings", columns: table => new @@ -173,6 +160,18 @@ namespace PyroFetes.Migrations table.PrimaryKey("PK_Settings", x => x.Id); }); + migrationBuilder.CreateTable( + name: "ShowServiceProviders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1") + }, + constraints: table => + { + table.PrimaryKey("PK_ShowServiceProviders", x => x.Id); + }); + migrationBuilder.CreateTable( name: "SoundCategories", columns: table => new @@ -214,7 +213,7 @@ namespace PyroFetes.Migrations Email = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Phone = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), Address = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - ZipCode = table.Column(type: "int", nullable: false), + ZipCode = table.Column(type: "nvarchar(max)", nullable: false), City = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), DeliveryDelay = table.Column(type: "int", nullable: false) }, @@ -246,7 +245,7 @@ namespace PyroFetes.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - Password = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Password = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), Salt = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Email = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Fonction = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false) @@ -267,7 +266,7 @@ namespace PyroFetes.Migrations Current = table.Column(type: "int", nullable: false), MinWeight = table.Column(type: "int", nullable: false), Address = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), - ZipCode = table.Column(type: "int", nullable: false), + ZipCode = table.Column(type: "nvarchar(max)", nullable: false), City = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false) }, constraints: table => @@ -292,9 +291,9 @@ namespace PyroFetes.Migrations { table.PrimaryKey("PK_Shows", x => x.Id); table.ForeignKey( - name: "FK_Shows_City_CityId", + name: "FK_Shows_Cities_CityId", column: x => x.CityId, - principalTable: "City", + principalTable: "Cities", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -329,7 +328,7 @@ namespace PyroFetes.Migrations DelivererId = table.Column(type: "int", nullable: false), EstimateDeliveryDate = table.Column(type: "date", nullable: false), ExpeditionDate = table.Column(type: "date", nullable: false), - RealDeliveryDate = table.Column(type: "date", nullable: false) + RealDeliveryDate = table.Column(type: "date", nullable: true) }, constraints: table => { @@ -343,7 +342,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "Providers", + name: "ServiceProviders", columns: table => new { Id = table.Column(type: "int", nullable: false) @@ -353,9 +352,9 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_Providers", x => x.Id); + table.PrimaryKey("PK_ServiceProviders", x => x.Id); table.ForeignKey( - name: "FK_Providers_ProviderTypes_ProviderTypeId", + name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId", column: x => x.ProviderTypeId, principalTable: "ProviderTypes", principalColumn: "Id", @@ -456,6 +455,26 @@ namespace PyroFetes.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "PurchaseOrders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PurchaseConditions = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), + SupplierId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PurchaseOrders", x => x.Id); + table.ForeignKey( + name: "FK_PurchaseOrders_Suppliers_SupplierId", + column: x => x.SupplierId, + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Materials", columns: table => new @@ -508,7 +527,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "ShowStaff", + name: "ShowStaffs", columns: table => new { StaffId = table.Column(type: "int", nullable: false), @@ -516,15 +535,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_ShowStaff", x => new { x.StaffId, x.ShowId }); + table.PrimaryKey("PK_ShowStaffs", x => new { x.StaffId, x.ShowId }); table.ForeignKey( - name: "FK_ShowStaff_Shows_ShowId", + name: "FK_ShowStaffs_Shows_ShowId", column: x => x.ShowId, principalTable: "Shows", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ShowStaff_Staffs_StaffId", + name: "FK_ShowStaffs_Staffs_StaffId", column: x => x.StaffId, principalTable: "Staffs", principalColumn: "Id", @@ -532,7 +551,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "ShowTruck", + name: "ShowTrucks", columns: table => new { ShowId = table.Column(type: "int", nullable: false), @@ -540,15 +559,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_ShowTruck", x => new { x.ShowId, x.TruckId }); + table.PrimaryKey("PK_ShowTrucks", x => new { x.ShowId, x.TruckId }); table.ForeignKey( - name: "FK_ShowTruck_Shows_ShowId", + name: "FK_ShowTrucks_Shows_ShowId", column: x => x.ShowId, principalTable: "Shows", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ShowTruck_Trucks_TruckId", + name: "FK_ShowTrucks_Trucks_TruckId", column: x => x.TruckId, principalTable: "Trucks", principalColumn: "Id", @@ -604,7 +623,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "Contract", + name: "Contracts", columns: table => new { ShowId = table.Column(type: "int", nullable: false), @@ -613,15 +632,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_Contract", x => new { x.ShowId, x.ServiceProviderId }); + table.PrimaryKey("PK_Contracts", x => new { x.ShowId, x.ServiceProviderId }); table.ForeignKey( - name: "FK_Contract_Providers_ServiceProviderId", + name: "FK_Contracts_ServiceProviders_ServiceProviderId", column: x => x.ServiceProviderId, - principalTable: "Providers", + principalTable: "ServiceProviders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_Contract_Shows_ShowId", + name: "FK_Contracts_Shows_ShowId", column: x => x.ShowId, principalTable: "Shows", principalColumn: "Id", @@ -655,7 +674,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "MaterialWarehouse", + name: "MaterialWarehouses", columns: table => new { MaterialId = table.Column(type: "int", nullable: false), @@ -663,15 +682,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_MaterialWarehouse", x => new { x.MaterialId, x.WarehouseId }); + table.PrimaryKey("PK_MaterialWarehouses", x => new { x.MaterialId, x.WarehouseId }); table.ForeignKey( - name: "FK_MaterialWarehouse_Materials_MaterialId", + name: "FK_MaterialWarehouses_Materials_MaterialId", column: x => x.MaterialId, principalTable: "Materials", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_MaterialWarehouse_Warehouses_WarehouseId", + name: "FK_MaterialWarehouses_Warehouses_WarehouseId", column: x => x.WarehouseId, principalTable: "Warehouses", principalColumn: "Id", @@ -679,7 +698,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "ShowMaterial", + name: "ShowMaterials", columns: table => new { ShowId = table.Column(type: "int", nullable: false), @@ -687,15 +706,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_ShowMaterial", x => new { x.ShowId, x.MaterialId }); + table.PrimaryKey("PK_ShowMaterials", x => new { x.ShowId, x.MaterialId }); table.ForeignKey( - name: "FK_ShowMaterial_Materials_MaterialId", + name: "FK_ShowMaterials_Materials_MaterialId", column: x => x.MaterialId, principalTable: "Materials", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ShowMaterial_Shows_ShowId", + name: "FK_ShowMaterials_Shows_ShowId", column: x => x.ShowId, principalTable: "Shows", principalColumn: "Id", @@ -708,14 +727,13 @@ namespace PyroFetes.Migrations { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - References = table.Column(type: "int", nullable: false), + Reference = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Duration = table.Column(type: "decimal(18,2)", nullable: false), - Caliber = table.Column(type: "decimal(18,2)", nullable: false), - ApprovalNumber = table.Column(type: "int", nullable: false), + Caliber = table.Column(type: "int", nullable: false), + ApprovalNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Weight = table.Column(type: "decimal(18,2)", nullable: false), Nec = table.Column(type: "decimal(18,2)", nullable: false), - SellingPrice = table.Column(type: "decimal(18,2)", nullable: false), Image = table.Column(type: "nvarchar(max)", nullable: false), Link = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), MinimalQuantity = table.Column(type: "int", nullable: false), @@ -769,7 +787,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "ContactServiceProvider", + name: "ContactServiceProviders", columns: table => new { ContactId = table.Column(type: "int", nullable: false), @@ -777,17 +795,17 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_ContactServiceProvider", x => new { x.ContactId, x.ServiceProviderId }); + table.PrimaryKey("PK_ContactServiceProviders", x => new { x.ContactId, x.ServiceProviderId }); table.ForeignKey( - name: "FK_ContactServiceProvider_Contacts_ContactId", + name: "FK_ContactServiceProviders_Contacts_ContactId", column: x => x.ContactId, principalTable: "Contacts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ContactServiceProvider_Providers_ServiceProviderId", + name: "FK_ContactServiceProviders_ServiceProviders_ServiceProviderId", column: x => x.ServiceProviderId, - principalTable: "Providers", + principalTable: "ServiceProviders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -809,9 +827,9 @@ namespace PyroFetes.Migrations principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ProviderContacts_Providers_ProviderId", + name: "FK_ProviderContacts_ServiceProviders_ProviderId", column: x => x.ProviderId, - principalTable: "Providers", + principalTable: "ServiceProviders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -959,7 +977,7 @@ namespace PyroFetes.Migrations }); migrationBuilder.CreateTable( - name: "ProductTimecode", + name: "ProductTimecodes", columns: table => new { ProductId = table.Column(type: "int", nullable: false), @@ -969,15 +987,15 @@ namespace PyroFetes.Migrations }, constraints: table => { - table.PrimaryKey("PK_ProductTimecode", x => new { x.ProductId, x.ShowId }); + table.PrimaryKey("PK_ProductTimecodes", x => new { x.ProductId, x.ShowId }); table.ForeignKey( - name: "FK_ProductTimecode_Products_ProductId", + name: "FK_ProductTimecodes_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ProductTimecode_Shows_ShowId", + name: "FK_ProductTimecodes_Shows_ShowId", column: x => x.ShowId, principalTable: "Shows", principalColumn: "Id", @@ -1075,13 +1093,13 @@ namespace PyroFetes.Migrations column: "CustomerId"); migrationBuilder.CreateIndex( - name: "IX_ContactServiceProvider_ServiceProviderId", - table: "ContactServiceProvider", + name: "IX_ContactServiceProviders_ServiceProviderId", + table: "ContactServiceProviders", column: "ServiceProviderId"); migrationBuilder.CreateIndex( - name: "IX_Contract_ServiceProviderId", - table: "Contract", + name: "IX_Contracts_ServiceProviderId", + table: "Contracts", column: "ServiceProviderId"); migrationBuilder.CreateIndex( @@ -1105,8 +1123,8 @@ namespace PyroFetes.Migrations column: "WarehouseId"); migrationBuilder.CreateIndex( - name: "IX_MaterialWarehouse_WarehouseId", - table: "MaterialWarehouse", + name: "IX_MaterialWarehouses_WarehouseId", + table: "MaterialWarehouses", column: "WarehouseId"); migrationBuilder.CreateIndex( @@ -1155,8 +1173,8 @@ namespace PyroFetes.Migrations column: "ProductCategoryId"); migrationBuilder.CreateIndex( - name: "IX_ProductTimecode_ShowId", - table: "ProductTimecode", + name: "IX_ProductTimecodes_ShowId", + table: "ProductTimecodes", column: "ShowId"); migrationBuilder.CreateIndex( @@ -1165,9 +1183,9 @@ namespace PyroFetes.Migrations column: "ProviderId"); migrationBuilder.CreateIndex( - name: "IX_Providers_ProviderTypeId", - table: "Providers", - column: "ProviderTypeId"); + name: "IX_PurchaseOrders_SupplierId", + table: "PurchaseOrders", + column: "SupplierId"); migrationBuilder.CreateIndex( name: "IX_PurchaseProducts_PurchaseOrderId", @@ -1185,8 +1203,13 @@ namespace PyroFetes.Migrations column: "CustomerId"); migrationBuilder.CreateIndex( - name: "IX_ShowMaterial_MaterialId", - table: "ShowMaterial", + name: "IX_ServiceProviders_ProviderTypeId", + table: "ServiceProviders", + column: "ProviderTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_ShowMaterials_MaterialId", + table: "ShowMaterials", column: "MaterialId"); migrationBuilder.CreateIndex( @@ -1195,13 +1218,13 @@ namespace PyroFetes.Migrations column: "CityId"); migrationBuilder.CreateIndex( - name: "IX_ShowStaff_ShowId", - table: "ShowStaff", + name: "IX_ShowStaffs_ShowId", + table: "ShowStaffs", column: "ShowId"); migrationBuilder.CreateIndex( - name: "IX_ShowTruck_TruckId", - table: "ShowTruck", + name: "IX_ShowTrucks_TruckId", + table: "ShowTrucks", column: "TruckId"); migrationBuilder.CreateIndex( @@ -1245,16 +1268,16 @@ namespace PyroFetes.Migrations name: "Communications"); migrationBuilder.DropTable( - name: "ContactServiceProvider"); + name: "ContactServiceProviders"); migrationBuilder.DropTable( - name: "Contract"); + name: "Contracts"); migrationBuilder.DropTable( name: "ExperienceLevels"); migrationBuilder.DropTable( - name: "MaterialWarehouse"); + name: "MaterialWarehouses"); migrationBuilder.DropTable( name: "Prices"); @@ -1269,7 +1292,7 @@ namespace PyroFetes.Migrations name: "ProductEffects"); migrationBuilder.DropTable( - name: "ProductTimecode"); + name: "ProductTimecodes"); migrationBuilder.DropTable( name: "ProviderContacts"); @@ -1284,13 +1307,16 @@ namespace PyroFetes.Migrations name: "Settings"); migrationBuilder.DropTable( - name: "ShowMaterial"); + name: "ShowMaterials"); migrationBuilder.DropTable( - name: "ShowStaff"); + name: "ShowServiceProviders"); migrationBuilder.DropTable( - name: "ShowTruck"); + name: "ShowStaffs"); + + migrationBuilder.DropTable( + name: "ShowTrucks"); migrationBuilder.DropTable( name: "SoundTimecodes"); @@ -1310,9 +1336,6 @@ namespace PyroFetes.Migrations migrationBuilder.DropTable( name: "WarehouseProducts"); - migrationBuilder.DropTable( - name: "Suppliers"); - migrationBuilder.DropTable( name: "Colors"); @@ -1323,7 +1346,7 @@ namespace PyroFetes.Migrations name: "Effects"); migrationBuilder.DropTable( - name: "Providers"); + name: "ServiceProviders"); migrationBuilder.DropTable( name: "PurchaseOrders"); @@ -1365,7 +1388,10 @@ namespace PyroFetes.Migrations name: "ProviderTypes"); migrationBuilder.DropTable( - name: "City"); + name: "Suppliers"); + + migrationBuilder.DropTable( + name: "Cities"); migrationBuilder.DropTable( name: "SoundCategories"); diff --git a/PyroFetes/Migrations/20251127133430_FixZipCode.Designer.cs b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs similarity index 99% rename from PyroFetes/Migrations/20251127133430_FixZipCode.Designer.cs rename to PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs index adea6e9..e644ca2 100644 --- a/PyroFetes/Migrations/20251127133430_FixZipCode.Designer.cs +++ b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs @@ -12,8 +12,8 @@ using PyroFetes; namespace PyroFetes.Migrations { [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251127133430_FixZipCode")] - partial class FixZipCode + [Migration("20260524095820_ChangeDatabaseName")] + partial class ChangeDatabaseName { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -698,8 +698,13 @@ namespace PyroFetes.Migrations .HasMaxLength(300) .HasColumnType("nvarchar(300)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); + b.HasIndex("SupplierId"); + b.ToTable("PurchaseOrders"); }); @@ -1548,6 +1553,17 @@ namespace PyroFetes.Migrations b.Navigation("Provider"); }); + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany() + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => { b.HasOne("PyroFetes.Models.Product", "Product") diff --git a/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.cs b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.cs new file mode 100644 index 0000000..727fd05 --- /dev/null +++ b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PyroFetes.Migrations +{ + /// + public partial class ChangeDatabaseName : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.Designer.cs b/PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.Designer.cs similarity index 97% rename from PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.Designer.cs rename to PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.Designer.cs index 51757cb..12daab0 100644 --- a/PyroFetes/Migrations/20251126193437_UpdatedDatabaseProductType.Designer.cs +++ b/PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.Designer.cs @@ -12,8 +12,8 @@ using PyroFetes; namespace PyroFetes.Migrations { [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251126193437_UpdatedDatabaseProductType")] - partial class UpdatedDatabaseProductType + [Migration("20260525103910_AddedMissingFieldForSupplierInDocuments")] + partial class AddedMissingFieldForSupplierInDocuments { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -698,8 +698,13 @@ namespace PyroFetes.Migrations .HasMaxLength(300) .HasColumnType("nvarchar(300)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); + b.HasIndex("SupplierId"); + b.ToTable("PurchaseOrders"); }); @@ -742,10 +747,15 @@ namespace PyroFetes.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("CustomerId"); + b.HasIndex("SupplierId"); + b.ToTable("Quotations"); }); @@ -1120,8 +1130,7 @@ namespace PyroFetes.Migrations b.Property("ZipCode") .IsRequired() - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1185,8 +1194,8 @@ namespace PyroFetes.Migrations b.Property("Password") .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); b.Property("Salt") .IsRequired() @@ -1230,8 +1239,9 @@ namespace PyroFetes.Migrations .HasMaxLength(100) .HasColumnType("nvarchar(100)"); - b.Property("ZipCode") - .HasColumnType("int"); + b.Property("ZipCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1548,6 +1558,17 @@ namespace PyroFetes.Migrations b.Navigation("Provider"); }); + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("PurchaseOrders") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => { b.HasOne("PyroFetes.Models.Product", "Product") @@ -1575,7 +1596,15 @@ namespace PyroFetes.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("Quotations") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Customer"); + + b.Navigation("Supplier"); }); modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => @@ -1944,6 +1973,10 @@ namespace PyroFetes.Migrations modelBuilder.Entity("PyroFetes.Models.Supplier", b => { b.Navigation("Prices"); + + b.Navigation("PurchaseOrders"); + + b.Navigation("Quotations"); }); modelBuilder.Entity("PyroFetes.Models.Truck", b => diff --git a/PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.cs b/PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.cs new file mode 100644 index 0000000..297a91a --- /dev/null +++ b/PyroFetes/Migrations/20260525103910_AddedMissingFieldForSupplierInDocuments.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PyroFetes.Migrations +{ + /// + public partial class AddedMissingFieldForSupplierInDocuments : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SupplierId", + table: "Quotations", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_Quotations_SupplierId", + table: "Quotations", + column: "SupplierId"); + + migrationBuilder.AddForeignKey( + name: "FK_Quotations_Suppliers_SupplierId", + table: "Quotations", + column: "SupplierId", + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Quotations_Suppliers_SupplierId", + table: "Quotations"); + + migrationBuilder.DropIndex( + name: "IX_Quotations_SupplierId", + table: "Quotations"); + + migrationBuilder.DropColumn( + name: "SupplierId", + table: "Quotations"); + } + } +} diff --git a/PyroFetes/Migrations/20251120154429_FixTypeErrors.Designer.cs b/PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.Designer.cs similarity index 97% rename from PyroFetes/Migrations/20251120154429_FixTypeErrors.Designer.cs rename to PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.Designer.cs index 323012e..5dfebd7 100644 --- a/PyroFetes/Migrations/20251120154429_FixTypeErrors.Designer.cs +++ b/PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.Designer.cs @@ -12,8 +12,8 @@ using PyroFetes; namespace PyroFetes.Migrations { [DbContext(typeof(PyroFetesDbContext))] - [Migration("20251120154429_FixTypeErrors")] - partial class FixTypeErrors + [Migration("20260525152029_AddedMissingFieldForSupplierInDeliveryNote")] + partial class AddedMissingFieldForSupplierInDeliveryNote { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -332,6 +332,9 @@ namespace PyroFetes.Migrations b.Property("RealDeliveryDate") .HasColumnType("date"); + b.Property("SupplierId") + .HasColumnType("int"); + b.Property("TrackingNumber") .IsRequired() .HasMaxLength(100) @@ -341,6 +344,8 @@ namespace PyroFetes.Migrations b.HasIndex("DelivererId"); + b.HasIndex("SupplierId"); + b.ToTable("DeliveryNotes"); }); @@ -508,7 +513,8 @@ namespace PyroFetes.Migrations b.Property("ApprovalNumber") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); b.Property("Caliber") .HasColumnType("int"); @@ -697,8 +703,13 @@ namespace PyroFetes.Migrations .HasMaxLength(300) .HasColumnType("nvarchar(300)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); + b.HasIndex("SupplierId"); + b.ToTable("PurchaseOrders"); }); @@ -741,10 +752,15 @@ namespace PyroFetes.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("CustomerId"); + b.HasIndex("SupplierId"); + b.ToTable("Quotations"); }); @@ -1119,8 +1135,7 @@ namespace PyroFetes.Migrations b.Property("ZipCode") .IsRequired() - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1184,8 +1199,8 @@ namespace PyroFetes.Migrations b.Property("Password") .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); b.Property("Salt") .IsRequired() @@ -1229,8 +1244,9 @@ namespace PyroFetes.Migrations .HasMaxLength(100) .HasColumnType("nvarchar(100)"); - b.Property("ZipCode") - .HasColumnType("int"); + b.Property("ZipCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1345,7 +1361,15 @@ namespace PyroFetes.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("DeliveryNotes") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Deliverer"); + + b.Navigation("Supplier"); }); modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => @@ -1547,6 +1571,17 @@ namespace PyroFetes.Migrations b.Navigation("Provider"); }); + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("PurchaseOrders") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => { b.HasOne("PyroFetes.Models.Product", "Product") @@ -1574,7 +1609,15 @@ namespace PyroFetes.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("Quotations") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Customer"); + + b.Navigation("Supplier"); }); modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => @@ -1942,7 +1985,13 @@ namespace PyroFetes.Migrations modelBuilder.Entity("PyroFetes.Models.Supplier", b => { + b.Navigation("DeliveryNotes"); + b.Navigation("Prices"); + + b.Navigation("PurchaseOrders"); + + b.Navigation("Quotations"); }); modelBuilder.Entity("PyroFetes.Models.Truck", b => diff --git a/PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.cs b/PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.cs new file mode 100644 index 0000000..d278e36 --- /dev/null +++ b/PyroFetes/Migrations/20260525152029_AddedMissingFieldForSupplierInDeliveryNote.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PyroFetes.Migrations +{ + /// + public partial class AddedMissingFieldForSupplierInDeliveryNote : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SupplierId", + table: "DeliveryNotes", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_DeliveryNotes_SupplierId", + table: "DeliveryNotes", + column: "SupplierId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeliveryNotes_Suppliers_SupplierId", + table: "DeliveryNotes", + column: "SupplierId", + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeliveryNotes_Suppliers_SupplierId", + table: "DeliveryNotes"); + + migrationBuilder.DropIndex( + name: "IX_DeliveryNotes_SupplierId", + table: "DeliveryNotes"); + + migrationBuilder.DropColumn( + name: "SupplierId", + table: "DeliveryNotes"); + } + } +} diff --git a/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs index 4c11f87..53f3b23 100644 --- a/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs +++ b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs @@ -329,6 +329,9 @@ namespace PyroFetes.Migrations b.Property("RealDeliveryDate") .HasColumnType("date"); + b.Property("SupplierId") + .HasColumnType("int"); + b.Property("TrackingNumber") .IsRequired() .HasMaxLength(100) @@ -338,6 +341,8 @@ namespace PyroFetes.Migrations b.HasIndex("DelivererId"); + b.HasIndex("SupplierId"); + b.ToTable("DeliveryNotes"); }); @@ -695,8 +700,13 @@ namespace PyroFetes.Migrations .HasMaxLength(300) .HasColumnType("nvarchar(300)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); + b.HasIndex("SupplierId"); + b.ToTable("PurchaseOrders"); }); @@ -739,10 +749,15 @@ namespace PyroFetes.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); + b.Property("SupplierId") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("CustomerId"); + b.HasIndex("SupplierId"); + b.ToTable("Quotations"); }); @@ -1343,7 +1358,15 @@ namespace PyroFetes.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("DeliveryNotes") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Deliverer"); + + b.Navigation("Supplier"); }); modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => @@ -1545,6 +1568,17 @@ namespace PyroFetes.Migrations b.Navigation("Provider"); }); + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("PurchaseOrders") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => { b.HasOne("PyroFetes.Models.Product", "Product") @@ -1572,7 +1606,15 @@ namespace PyroFetes.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("Quotations") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Customer"); + + b.Navigation("Supplier"); }); modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => @@ -1940,7 +1982,13 @@ namespace PyroFetes.Migrations modelBuilder.Entity("PyroFetes.Models.Supplier", b => { + b.Navigation("DeliveryNotes"); + b.Navigation("Prices"); + + b.Navigation("PurchaseOrders"); + + b.Navigation("Quotations"); }); modelBuilder.Entity("PyroFetes.Models.Truck", b => diff --git a/PyroFetes/Models/Availability.cs b/PyroFetes/Models/Availability.cs index 47b0f1c..9fb6043 100644 --- a/PyroFetes/Models/Availability.cs +++ b/PyroFetes/Models/Availability.cs @@ -9,6 +9,6 @@ public class Availability [Required] public DateOnly DeliveryDate { get; set; } [Required] public DateOnly ExpirationDate { get; set; } [Required] public DateOnly RenewallDate { get; set; } - + public List? StaffAvailabilities { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Brand.cs b/PyroFetes/Models/Brand.cs index 49016ca..8d4050c 100644 --- a/PyroFetes/Models/Brand.cs +++ b/PyroFetes/Models/Brand.cs @@ -4,9 +4,9 @@ namespace PyroFetes.Models; public class Brand { - [Key] public int Id { get; set; } - [Required, MaxLength(100)] public string? Name { get; set; } - + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { 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/City.cs b/PyroFetes/Models/City.cs index 04dc24e..caeb683 100644 --- a/PyroFetes/Models/City.cs +++ b/PyroFetes/Models/City.cs @@ -4,9 +4,9 @@ namespace PyroFetes.Models; public class City { - [Key] public int Id { get; set; } - [Required, MaxLength(100)] public string? Name { get; set; } + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } [Required] public int ZipCode { get; set; } - + public List? Shows { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Classification.cs b/PyroFetes/Models/Classification.cs index bd3685b..c58c344 100644 --- a/PyroFetes/Models/Classification.cs +++ b/PyroFetes/Models/Classification.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class Classification { - [Key] public int Id { get; set; } - [Required, MaxLength(100)] public string? Label { get; set; } - + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Color.cs b/PyroFetes/Models/Color.cs index acfe830..6ab01d7 100644 --- a/PyroFetes/Models/Color.cs +++ b/PyroFetes/Models/Color.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class Color { - [Key] public int Id { get; set; } - [Required, MaxLength(100)] public string? Label { get; set; } - + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + public List? ProductColors { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Communication.cs b/PyroFetes/Models/Communication.cs index a3dd0d2..1483100 100644 --- a/PyroFetes/Models/Communication.cs +++ b/PyroFetes/Models/Communication.cs @@ -4,11 +4,11 @@ namespace PyroFetes.Models; public class Communication { - [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? Email { get; set; } [Required, MaxLength(300)] public string? Meeting { get; set; } - + [Required] public int ContactId { get; set; } public Contact? Contact { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Contact.cs b/PyroFetes/Models/Contact.cs index e1573ad..e693559 100644 --- a/PyroFetes/Models/Contact.cs +++ b/PyroFetes/Models/Contact.cs @@ -13,10 +13,10 @@ public class Contact [Required] public int ZipCode { get; set; } [Required, MaxLength(100)] public string? City { get; set; } [Required, MaxLength(100)] public string? Role { get; set; } - + public Customer? Customer { get; set; } [Required] public int CustomerId { get; set; } - + public List? Communications { get; set; } public List? StaffContacts { get; set; } public List? ContactServiceProviders { get; set; } diff --git a/PyroFetes/Models/ContactServiceProvider.cs b/PyroFetes/Models/ContactServiceProvider.cs index cc9cd1b..f936ba6 100644 --- a/PyroFetes/Models/ContactServiceProvider.cs +++ b/PyroFetes/Models/ContactServiceProvider.cs @@ -8,7 +8,7 @@ public class ContactServiceProvider { [Required] public int ContactId { get; set; } [Required] public int ServiceProviderId { get; set; } - + public Contact? Contact { get; set; } public ServiceProvider? ServiceProvider { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Customer.cs b/PyroFetes/Models/Customer.cs index da6dbba..03a1092 100644 --- a/PyroFetes/Models/Customer.cs +++ b/PyroFetes/Models/Customer.cs @@ -6,11 +6,11 @@ public class Customer { [Key] public int Id { get; set; } [Required, MaxLength(200)] public string? Note { get; set; } - + //Relations [Required] public int CustomerTypeId { get; set; } public CustomerType? CustomerType { get; set; } - + public List? Contacts { get; set; } public List? Quotations { get; set; } -} +} \ No newline at end of file diff --git a/PyroFetes/Models/CustomerType.cs b/PyroFetes/Models/CustomerType.cs index 197ad09..2f6aec9 100644 --- a/PyroFetes/Models/CustomerType.cs +++ b/PyroFetes/Models/CustomerType.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class CustomerType { - [Key] public int Id { get; set; } + [Key] public int Id { get; set; } [Required, MaxLength(100)] public string? Label { get; set; } - + public List? Customers { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Deliverer.cs b/PyroFetes/Models/Deliverer.cs index 34e708c..3ba10e8 100644 --- a/PyroFetes/Models/Deliverer.cs +++ b/PyroFetes/Models/Deliverer.cs @@ -6,6 +6,6 @@ public class Deliverer { [Key] public int Id { get; set; } [Required, MaxLength(100)] public string? Transporter { get; set; } - + public List? DeliveryNotes { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/DeliveryNote.cs b/PyroFetes/Models/DeliveryNote.cs index e94792f..6497767 100644 --- a/PyroFetes/Models/DeliveryNote.cs +++ b/PyroFetes/Models/DeliveryNote.cs @@ -7,10 +7,12 @@ public class DeliveryNote [Key] public int Id { get; set; } [Required, MaxLength(100)] public string? TrackingNumber { get; set; } public int DelivererId { get; set; } + public int SupplierId { get; set; } [Required] public DateOnly EstimateDeliveryDate { get; set; } [Required] public DateOnly ExpeditionDate { get; set; } public DateOnly? RealDeliveryDate { get; set; } - + public Deliverer? Deliverer { get; set; } + public Supplier? Supplier { get; set; } public List? ProductDeliveries { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Effect.cs b/PyroFetes/Models/Effect.cs index 0dcb87c..4f50922 100644 --- a/PyroFetes/Models/Effect.cs +++ b/PyroFetes/Models/Effect.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class Effect { - [Key] public int Id { get; set; } - [Required, MaxLength(200)] public string? Label { get; set; } - + [Key] public int Id { get; set; } + [Required, MaxLength(200)] public string? Label { get; set; } + public List? ProductEffects { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ExperienceLevel.cs b/PyroFetes/Models/ExperienceLevel.cs index 923f757..a1014b8 100644 --- a/PyroFetes/Models/ExperienceLevel.cs +++ b/PyroFetes/Models/ExperienceLevel.cs @@ -6,7 +6,7 @@ public class ExperienceLevel { [Key] public int Id { get; set; } [Required, MaxLength(100)] public string? Label { get; set; } - + public Staff? Staff { get; set; } [Required] public int StaffId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/HistoryOfApproval.cs b/PyroFetes/Models/HistoryOfApproval.cs index c8fd073..039a63e 100644 --- a/PyroFetes/Models/HistoryOfApproval.cs +++ b/PyroFetes/Models/HistoryOfApproval.cs @@ -4,9 +4,9 @@ namespace PyroFetes.Models; public class HistoryOfApproval { - [Key] public int Id { get; set; } + [Key] public int Id { get; set; } [Required] public DateOnly DeliveryDate { get; set; } [Required] public DateOnly ExpirationDate { get; set; } - + public List? StaffHistoryOfApprovals { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Material.cs b/PyroFetes/Models/Material.cs index 224e5d5..b833090 100644 --- a/PyroFetes/Models/Material.cs +++ b/PyroFetes/Models/Material.cs @@ -4,13 +4,13 @@ namespace PyroFetes.Models; public class Material { - [Key] public int Id {get; set;} - [Required, MaxLength(100)] public string? Name {get; set;} - [Required] public int Quantity {get; set;} - - [Required] public int WarehouseId {get; set;} - public Warehouse? Warehouse {get; set;} - - public List? ShowMaterials {get; set;} - public List? MaterialWarehouses {get; set;} + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required] public int Quantity { get; set; } + + [Required] public int WarehouseId { get; set; } + public Warehouse? Warehouse { get; set; } + + public List? ShowMaterials { get; set; } + public List? MaterialWarehouses { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/MaterialWarehouse.cs b/PyroFetes/Models/MaterialWarehouse.cs index 4f49ba9..983188e 100644 --- a/PyroFetes/Models/MaterialWarehouse.cs +++ b/PyroFetes/Models/MaterialWarehouse.cs @@ -8,7 +8,7 @@ public class MaterialWarehouse { [Required] public int MaterialId { get; set; } [Required] public int WarehouseId { get; set; } - + public Material? Material { get; set; } public Warehouse? Warehouse { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Movement.cs b/PyroFetes/Models/Movement.cs index fe26f18..f5a39f0 100644 --- a/PyroFetes/Models/Movement.cs +++ b/PyroFetes/Models/Movement.cs @@ -4,16 +4,16 @@ namespace PyroFetes.Models; public class Movement { - [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;} - + [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 List? Products { get; set; } - - public int? SourceWarehouseId {get; set;} - public Warehouse? SourceWarehouse {get; set;} - public int? DestinationWarehouseId {get; set;} - public Warehouse? DestinationWarehouse {get; set;} + + public int? SourceWarehouseId { get; set; } + public Warehouse? SourceWarehouse { get; set; } + public int? DestinationWarehouseId { get; set; } + public Warehouse? DestinationWarehouse { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Price.cs b/PyroFetes/Models/Price.cs index 2ee597e..0facca4 100644 --- a/PyroFetes/Models/Price.cs +++ b/PyroFetes/Models/Price.cs @@ -10,7 +10,7 @@ public class Price [Required] public int ProductId { get; set; } [Required] public int SupplierId { get; set; } [Required] public decimal SellingPrice { get; set; } - + public Product? Product { get; set; } public Supplier? Supplier { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Product.cs b/PyroFetes/Models/Product.cs index 88f52e4..b53cb03 100644 --- a/PyroFetes/Models/Product.cs +++ b/PyroFetes/Models/Product.cs @@ -7,7 +7,7 @@ namespace PyroFetes.Models [Key] public int Id { get; set; } [Required, MaxLength(20)] public string? Reference { get; set; } [Required, MaxLength(100)] public string? Name { get; set; } - [Required] public decimal Duration {get; set;} + [Required] public decimal Duration { get; set; } [Required] public int Caliber { get; set; } [Required, MaxLength(100)] public string? ApprovalNumber { get; set; } [Required] public decimal Weight { get; set; } @@ -22,9 +22,9 @@ namespace PyroFetes.Models [Required] public int ProductCategoryId { get; set; } public ProductCategory? ProductCategory { get; set; } - - [Required] public int MovementId {get; set;} - public Movement? Movement {get; set;} + + [Required] public int MovementId { get; set; } + public Movement? Movement { get; set; } public List? ProductDeliveries { get; set; } public List? Brands { get; set; } @@ -35,7 +35,5 @@ namespace PyroFetes.Models public List? QuotationProducts { get; set; } public List? WarehouseProducts { get; set; } public List? ProductTimecodes { get; set; } - - } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductCategory.cs b/PyroFetes/Models/ProductCategory.cs index 79bd67f..d809d02 100644 --- a/PyroFetes/Models/ProductCategory.cs +++ b/PyroFetes/Models/ProductCategory.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class ProductCategory { - [Key] public int Id { get; set; } - [Required, MaxLength(100)] public string? Label { get; set; } - + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductColor.cs b/PyroFetes/Models/ProductColor.cs index f93d964..14291d8 100644 --- a/PyroFetes/Models/ProductColor.cs +++ b/PyroFetes/Models/ProductColor.cs @@ -8,7 +8,7 @@ public class ProductColor { public Product? Product { get; set; } [Required] public int ProductId { get; set; } - + public Color? Color { get; set; } [Required] public int ColorId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductDelivery.cs b/PyroFetes/Models/ProductDelivery.cs index bfbae68..03d7c36 100644 --- a/PyroFetes/Models/ProductDelivery.cs +++ b/PyroFetes/Models/ProductDelivery.cs @@ -9,7 +9,7 @@ public class ProductDelivery [Required] public int ProductId { get; set; } [Required] public int DeliveryNoteId { get; set; } [Required] public int Quantity { get; set; } - + public Product? Product { get; set; } public DeliveryNote? DeliveryNote { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProductEffect.cs b/PyroFetes/Models/ProductEffect.cs index 3f269d6..d81e952 100644 --- a/PyroFetes/Models/ProductEffect.cs +++ b/PyroFetes/Models/ProductEffect.cs @@ -11,5 +11,4 @@ public class ProductEffect public Effect? Effect { get; set; } [Required] public int EffectId { get; set; } - } \ No newline at end of file diff --git a/PyroFetes/Models/ProductTimecode.cs b/PyroFetes/Models/ProductTimecode.cs index a4ad826..b9979af 100644 --- a/PyroFetes/Models/ProductTimecode.cs +++ b/PyroFetes/Models/ProductTimecode.cs @@ -8,10 +8,10 @@ public class ProductTimecode { public Product? Product { get; set; } [Required] public int ProductId { get; set; } - + public Show? Show { get; set; } [Required] public int ShowId { get; set; } - + [Required] public decimal Start { get; set; } [Required] public decimal End { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ProviderType.cs b/PyroFetes/Models/ProviderType.cs index 0871b8a..0fb7821 100644 --- a/PyroFetes/Models/ProviderType.cs +++ b/PyroFetes/Models/ProviderType.cs @@ -4,8 +4,8 @@ namespace PyroFetes.Models; public class ProviderType { - [Key] public int Id { get; set; } + [Key] public int Id { get; set; } [Required, MaxLength(100)] public string? Label { get; set; } - + public List? ServiceProviders { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/PurchaseOrder.cs b/PyroFetes/Models/PurchaseOrder.cs index 815f5a0..0f54419 100644 --- a/PyroFetes/Models/PurchaseOrder.cs +++ b/PyroFetes/Models/PurchaseOrder.cs @@ -6,6 +6,8 @@ public class PurchaseOrder { [Key] public int Id { get; set; } [Required, MaxLength(300)] public string? PurchaseConditions { get; set; } - + + [Required] public int SupplierId { get; set; } + public Supplier? Supplier { get; set; } public List? PurchaseProducts { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Quotation.cs b/PyroFetes/Models/Quotation.cs index 569c271..e8b9915 100644 --- a/PyroFetes/Models/Quotation.cs +++ b/PyroFetes/Models/Quotation.cs @@ -7,9 +7,12 @@ public class Quotation [Key] public int Id { get; set; } [Required, MaxLength(200)] public string? Message { get; set; } [Required, MaxLength(300)] public string? ConditionsSale { get; set; } - + [Required] public int CustomerId { get; set; } public Customer? Customer { get; set; } + [Required] public int SupplierId { get; set; } + public Supplier? Supplier { get; set; } + public List? QuotationProducts { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/QuotationProduct.cs b/PyroFetes/Models/QuotationProduct.cs index 8e2f3bb..db88e63 100644 --- a/PyroFetes/Models/QuotationProduct.cs +++ b/PyroFetes/Models/QuotationProduct.cs @@ -8,8 +8,8 @@ public class QuotationProduct { [Required] public int ProductId { get; set; } [Required] public int QuotationId { get; set; } - [Required] public int Quantity { get; set; } - + [Required] public int Quantity { get; set; } + public Product? Product { get; set; } public Quotation? Quotation { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/ServiceProvider.cs b/PyroFetes/Models/ServiceProvider.cs index b91e0d7..64e6272 100644 --- a/PyroFetes/Models/ServiceProvider.cs +++ b/PyroFetes/Models/ServiceProvider.cs @@ -4,13 +4,13 @@ namespace PyroFetes.Models; public class ServiceProvider { - [Key] public int Id { get; set; } + [Key] public int Id { get; set; } [Required] public decimal Price { get; set; } - + //Relations [Required] public int ProviderTypeId { get; set; } public ProviderType? ProviderType { get; set; } - + public List? Contracts { get; set; } public List? ContactServiceProviders { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Show.cs b/PyroFetes/Models/Show.cs index bc425dd..33ae713 100644 --- a/PyroFetes/Models/Show.cs +++ b/PyroFetes/Models/Show.cs @@ -9,13 +9,13 @@ public class Show [Required, MaxLength(120)] public string? Place { get; set; } [MaxLength(500)] public string? Description { get; set; } public DateOnly? Date { get; set; } - + // Link (path/URL/file name) to the pyrotechnic implementation plan [Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; } - + [Required] public int CityId { get; set; } public City? City { get; set; } - + public List? ShowStaffs { get; set; } public List? ShowTrucks { get; set; } public List? SoundTimecodes { get; set; } diff --git a/PyroFetes/Models/ShowMaterial.cs b/PyroFetes/Models/ShowMaterial.cs index 81cc82a..b28de28 100644 --- a/PyroFetes/Models/ShowMaterial.cs +++ b/PyroFetes/Models/ShowMaterial.cs @@ -11,5 +11,4 @@ public class ShowMaterial public Material? Material { get; set; } [Required] public int MaterialId { get; set; } - } \ No newline at end of file diff --git a/PyroFetes/Models/ShowServiceProvider.cs b/PyroFetes/Models/ShowServiceProvider.cs index 351c9fc..3580426 100644 --- a/PyroFetes/Models/ShowServiceProvider.cs +++ b/PyroFetes/Models/ShowServiceProvider.cs @@ -4,6 +4,5 @@ namespace PyroFetes.Models; public class ShowServiceProvider { - [Key] public int Id { get; set; } - + [Key] public int Id { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Sound.cs b/PyroFetes/Models/Sound.cs index 3ddee3e..71e16c2 100644 --- a/PyroFetes/Models/Sound.cs +++ b/PyroFetes/Models/Sound.cs @@ -12,9 +12,9 @@ public class Sound [Required, MaxLength(40)] public string? Kind { get; set; } [Required, MaxLength(40)] public string? Format { get; set; } public DateTime? CreationDate { get; set; } - + [Required] public int SoundCategoryId { get; set; } public SoundCategory? SoundCategory { get; set; } - + public List? SoundTimecodes { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/SoundCategory.cs b/PyroFetes/Models/SoundCategory.cs index 52caeaf..b73b8cc 100644 --- a/PyroFetes/Models/SoundCategory.cs +++ b/PyroFetes/Models/SoundCategory.cs @@ -6,6 +6,6 @@ public class SoundCategory { [Key] public int Id { get; set; } [Required, MaxLength(100)] public string Name { get; set; } = null!; - + public List? Sounds { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/SoundTimecode.cs b/PyroFetes/Models/SoundTimecode.cs index 3411e0c..8ab47c3 100644 --- a/PyroFetes/Models/SoundTimecode.cs +++ b/PyroFetes/Models/SoundTimecode.cs @@ -10,7 +10,7 @@ public class SoundTimecode public Show? Show { get; set; } [Required] public int SoundId { get; set; } public Sound? Sound { get; set; } - + [Required] public decimal Start { get; set; } [Required] public decimal End { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs index a95c455..b50df53 100644 --- a/PyroFetes/Models/Staff.cs +++ b/PyroFetes/Models/Staff.cs @@ -11,7 +11,7 @@ public class Staff [Required, MaxLength(120)] public string? Email { get; set; } [Required, MaxLength(100)] public string? F4T2NumberApproval { get; set; } [Required] public DateOnly F4T2ExpirationDate { get; set; } - + public List? ShowStaffs { get; set; } public List? ExperienceLevels { get; set; } public List? StaffAvailabilities { get; set; } diff --git a/PyroFetes/Models/Supplier.cs b/PyroFetes/Models/Supplier.cs index 539b1b4..0820812 100644 --- a/PyroFetes/Models/Supplier.cs +++ b/PyroFetes/Models/Supplier.cs @@ -9,9 +9,12 @@ public class Supplier [Required, MaxLength(100)] public string? Email { get; set; } [Required, MaxLength(30)] public string? Phone { get; set; } [Required, MaxLength(100)] public string? Address { get; set; } - [Required,Length(5,5)] public string? ZipCode { get; set; } + [Required, Length(5, 5)] public string? ZipCode { get; set; } [Required, MaxLength(100)] public string? City { get; set; } [Required] public int DeliveryDelay { get; set; } - - public List? Prices { get; set; } + + public List? Prices { get; set; } + public List? Quotations { get; set; } + public List? DeliveryNotes { get; set; } + public List? PurchaseOrders { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Truck.cs b/PyroFetes/Models/Truck.cs index 91794a9..8a11b07 100644 --- a/PyroFetes/Models/Truck.cs +++ b/PyroFetes/Models/Truck.cs @@ -9,6 +9,6 @@ public class Truck [Required] public double? MaxExplosiveCapacity { get; set; } [Required, MaxLength(80)] public string? Sizes { get; set; } [Required, MaxLength(40)] public string? Status { get; set; } - + public List? ShowTrucks { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Warehouse.cs b/PyroFetes/Models/Warehouse.cs index d1e6420..0de0a12 100644 --- a/PyroFetes/Models/Warehouse.cs +++ b/PyroFetes/Models/Warehouse.cs @@ -4,19 +4,19 @@ namespace PyroFetes.Models; public class Warehouse { - [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;} + [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, MaxLength(100)] public string? Address { get; set; } - [Required, Length(5,5)] public string? ZipCode { get; set; } + [Required, Length(5, 5)] public string? ZipCode { get; set; } [Required, MaxLength(100)] public string? City { get; set; } - + public List? WarehouseProducts { get; set; } - - public List? MaterialWarehouses {get; set;} - + + public List? MaterialWarehouses { get; set; } + public List? MovementsSource { get; set; } public List? MovementsDestination { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/WarehouseProduct.cs b/PyroFetes/Models/WarehouseProduct.cs index fe89d36..cabc07c 100644 --- a/PyroFetes/Models/WarehouseProduct.cs +++ b/PyroFetes/Models/WarehouseProduct.cs @@ -10,6 +10,6 @@ public class WarehouseProduct public Product? Product { get; set; } [Required] public int WarehouseId { get; set; } public Warehouse? Warehouse { get; set; } - + [Required] public int Quantity { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index e1a719b..e78ef20 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -4,20 +4,23 @@ using PyroFetes; using FastEndpoints; using FastEndpoints.Swagger; using FastEndpoints.Security; +using Microsoft.Net.Http.Headers; using PyroFetes.MappingProfiles; using PyroFetes.Repositories; +using PyroFetes.Services.Pdf; +using QuestPDF.Infrastructure; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); +// Configurer la licence QuestPDF +QuestPDF.Settings.License = LicenseType.Community; + // On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet builder.Services - .AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong") + .AddAuthenticationJwtBearer(s => s.SigningKey = "v9!Qx7#Lk2@pZ8$wR6!tN5%uF3&cD9^mH1*eY4") .AddAuthorization() .AddFastEndpoints() - .SwaggerDocument(options => - { - options.ShortSchemaNames = true; - }) + .SwaggerDocument(options => { options.ShortSchemaNames = true; }) .AddCors(options => { options.AddDefaultPolicy(policyBuilder => @@ -25,7 +28,8 @@ builder.Services policyBuilder .WithOrigins("http://localhost:4200") .WithMethods("GET", "POST", "PUT", "DELETE", "PATCH") - .AllowAnyHeader(); + .AllowAnyHeader() + .WithExposedHeaders(HeaderNames.ContentDisposition); }); }); @@ -45,6 +49,13 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Ajout des services +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); MapperConfiguration mappingConfig = new(mc => { @@ -68,7 +79,7 @@ app.UseAuthentication() }) .UseSwaggerGen(); -app.UseHttpsRedirection(); +// app.UseHttpsRedirection(); app.UseCors(); diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index cd211f5..27aed3d 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -23,7 +23,16 @@ + + + <_ContentIncludedByDefault Remove="wwwroot\Images\logo.jpg" /> + + + + + + diff --git a/PyroFetes/PyroFetesDbContext.cs b/PyroFetes/PyroFetesDbContext.cs index 2a5f711..9a278ac 100644 --- a/PyroFetes/PyroFetesDbContext.cs +++ b/PyroFetes/PyroFetesDbContext.cs @@ -63,15 +63,15 @@ public class PyroFetesDbContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connectionString = - "Server=romaric-thibault.fr;" + - "Database=PyroFetes;" + + "Server=romaric-thibault.fr;" + + "Database=PyroFetes-Sujet2;" + "User Id=pyrofetes;" + "Password=Crablike8-Fringe-Swimmable;" + "TrustServerCertificate=true;"; optionsBuilder.UseSqlServer(connectionString); } - + // Models customization protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -80,13 +80,13 @@ public class PyroFetesDbContext : DbContext .WithMany(w => w.MovementsSource) .HasForeignKey(m => m.SourceWarehouseId) .OnDelete(DeleteBehavior.Restrict); - + modelBuilder.Entity() .HasOne(m => m.DestinationWarehouse) .WithMany(w => w.MovementsDestination) .HasForeignKey(m => m.DestinationWarehouseId) .OnDelete(DeleteBehavior.Restrict); - + modelBuilder.Entity() .HasOne(mw => mw.Material) .WithMany(m => m.MaterialWarehouses) diff --git a/PyroFetes/Repositories/CustomersRepository.cs b/PyroFetes/Repositories/CustomersRepository.cs new file mode 100644 index 0000000..ba29a90 --- /dev/null +++ b/PyroFetes/Repositories/CustomersRepository.cs @@ -0,0 +1,5 @@ +using PyroFetes.Models; + +namespace PyroFetes.Repositories; + +public class CustomersRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); \ No newline at end of file diff --git a/PyroFetes/Repositories/DeliverersRepository.cs b/PyroFetes/Repositories/DeliverersRepository.cs index 0bf8c2e..6d1ff5e 100644 --- a/PyroFetes/Repositories/DeliverersRepository.cs +++ b/PyroFetes/Repositories/DeliverersRepository.cs @@ -2,4 +2,4 @@ using PyroFetes.Models; namespace PyroFetes.Repositories; -public class DeliverersRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); +public class DeliverersRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); \ No newline at end of file diff --git a/PyroFetes/Repositories/QuotationProductsRepository.cs b/PyroFetes/Repositories/QuotationProductsRepository.cs index 0d42cdc..4bae3f0 100644 --- a/PyroFetes/Repositories/QuotationProductsRepository.cs +++ b/PyroFetes/Repositories/QuotationProductsRepository.cs @@ -2,4 +2,4 @@ using PyroFetes.Models; namespace PyroFetes.Repositories; -public class QuotationProductsRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); +public class QuotationProductsRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); \ No newline at end of file diff --git a/PyroFetes/Repositories/WareHouseRepository.cs b/PyroFetes/Repositories/WareHouseRepository.cs new file mode 100644 index 0000000..c393c28 --- /dev/null +++ b/PyroFetes/Repositories/WareHouseRepository.cs @@ -0,0 +1,5 @@ +using PyroFetes.Models; + +namespace PyroFetes.Repositories; + +public class WareHouseRepository(PyroFetesDbContext pyrofetesContext, AutoMapper.IMapper mapper) : PyrofetesRepository(pyrofetesContext, mapper); \ No newline at end of file diff --git a/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs b/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs new file mode 100644 index 0000000..9c20eff --- /dev/null +++ b/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs @@ -0,0 +1,134 @@ +using PyroFetes.Models; +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; + +namespace PyroFetes.Services.Pdf; + +public interface IDeliveryNotePdfService +{ + byte[] Generate(DeliveryNote deliveryNote, List lignes, Setting setting); +} + +public class DeliveryNotePdfService : IDeliveryNotePdfService +{ + public byte[] Generate(DeliveryNote deliveryNote, List lignes, Setting setting) + { + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); + decimal total = 0; + int totalQuantity = 0; + Document document = Document.Create(container => + { + container.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(30); + page.DefaultTextStyle(x => x.FontSize(11)); + + page.Header().Row(row => + { + // Client à gauche + row.RelativeItem().Column(col => + { + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text("Transporteur").SemiBold().FontSize(12); + col.Item().Text($"{deliveryNote.Deliverer?.Transporter}"); + col.Item().Height(5); + col.Item().AlignLeft().Text($"Expédiée le {deliveryNote.ExpeditionDate}"); + col.Item().Height(5); + col.Item().AlignLeft().Text($"Estimée au {deliveryNote.EstimateDeliveryDate}"); + col.Item().Height(5); + col.Item().AlignLeft().Text(deliveryNote.RealDeliveryDate is null ? "Pas encore arrivée à destination" : $"Reçu le {deliveryNote.RealDeliveryDate}"); + }); + + // Logo + société à droite + row.ConstantItem(200).Column(col => + { + col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea); + col.Item().Height(20); + col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold(); + col.Item().Height(5); + col.Item().AlignRight().Text("24, rue La Fosse Mardeau\n41700 Le Controis-en-Sologne"); + col.Item().Height(5); + col.Item().AlignRight().Text("Téléphone: 02 54 78 77 66"); + col.Item().Height(5); + col.Item().AlignRight().Text("SIRET: 82031463100012"); + col.Item().Height(40); + }); + }); + + page.Content().Column(col => + { + // Titre + date + col.Item().Row(row => + { + row.RelativeItem().Text($"Bon de livraison n° {deliveryNote.TrackingNumber}") + .FontSize(16).SemiBold(); + }); + col.Item().Height(20); + + col.Item().LineHorizontal(1); + + // Tableau des lignes + col.Item().Table(table => + { + table.ColumnsDefinition(columns => + { + columns.RelativeColumn(4); // Produit + columns.RelativeColumn(2); // Qté + columns.RelativeColumn(2); // PU + columns.RelativeColumn(2); // Total + }); + + // En-têtes + table.Header(header => + { + header.Cell().Element(CellHeader).Text("Produit"); + header.Cell().Element(CellHeader).AlignRight().Text("Qté"); + header.Cell().Element(CellHeader).AlignRight().Text("PU"); + header.Cell().Element(CellHeader).AlignRight().Text("Total"); + }); + + foreach (ProductDelivery l in lignes) + { + decimal price = l.Product!.Prices! + .FirstOrDefault(x => x.SupplierId == l.DeliveryNote!.SupplierId && x.ProductId == l.ProductId) + ?.SellingPrice ?? 0; + + table.Cell().Element(CellBody).Text(l.Product?.Name); + table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString()); + table.Cell().Element(CellBody).AlignRight().Text($"{price:n2} €"); + table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity * price:n2} €"); + + totalQuantity += l.Quantity; + total += l.Quantity * price; + } + + IContainer CellHeader(IContainer c) => + c.BorderBottom(1).PaddingVertical(5).DefaultTextStyle(x => x.SemiBold()); + + IContainer CellBody(IContainer c) => + c.PaddingVertical(2); + }); + + col.Item().LineHorizontal(1); + col.Item().Height(30); + + col.Item().AlignRight().Text($"Total: {totalQuantity} produits"); + col.Item().AlignRight().Text($"Total HT: {total:n2} €"); + col.Item().AlignRight().Text("Taxe : 20 %"); + col.Item().AlignRight().Text($"Total TTC: {total * (decimal)1.2:n2} €"); + }); + + // Signature en bas à droite + page.Footer().AlignRight().Column(col => { col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); + }); + }); + + return document.GeneratePdf(); + } +} \ No newline at end of file diff --git a/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs b/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs new file mode 100644 index 0000000..56ef881 --- /dev/null +++ b/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs @@ -0,0 +1,150 @@ +using PyroFetes.Models; +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; + +namespace PyroFetes.Services.Pdf; + +public interface IPurchaseOrderPdfService +{ + byte[] Generate(PurchaseOrder purchaseOrder, List lignes, Setting setting); +} + +public class PurchaseOrderPdfService : IPurchaseOrderPdfService +{ + public byte[] Generate(PurchaseOrder purchaseOrder, List lignes, Setting setting) + { + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); + int totalQuantity = 0; + decimal total = 0; + Document document = Document.Create(container => + { + container.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(30); + page.DefaultTextStyle(x => x.FontSize(11)); + + page.Header().Row(row => + { + // Client à gauche + row.RelativeItem().Column(col => + { + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text("Fournisseur :").SemiBold().FontSize(12); + col.Item().Text($"{purchaseOrder.Supplier?.Name}"); + col.Item().Text($"{purchaseOrder.Supplier?.Address}"); + col.Item().Text($"{purchaseOrder.Supplier?.ZipCode} {purchaseOrder.Supplier?.City}"); + col.Item().Text($"{purchaseOrder.Supplier?.DeliveryDelay} jours de délai moyen de livraison"); + }); + + // Logo + société à droite + row.ConstantItem(200).Column(col => + { + col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea); + col.Item().Height(20); + col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold(); + col.Item().Height(5); + col.Item().AlignRight().Text("24, rue La Fosse Mardeau\n41700 Le Controis-en-Sologne"); + col.Item().Height(5); + col.Item().AlignRight().Text("Téléphone: 02 54 78 77 66"); + col.Item().Height(5); + col.Item().AlignRight().Text("SIRET: 82031463100012"); + col.Item().Height(40); + }); + }); + + page.Content().Column(col => + { + // Titre + date + col.Item().Row(row => + { + row.RelativeItem().Text($"Bon de commande n° {purchaseOrder.Id}") + .FontSize(16).SemiBold(); + + row.ConstantItem(200).AlignRight().Text( + $"Le {DateTime.Now:dd/MM/yyyy}"); + }); + col.Item().Height(20); + + col.Item().LineHorizontal(1); + + // Tableau des lignes + col.Item().Table(table => + { + table.ColumnsDefinition(columns => + { + columns.RelativeColumn(4); // Produit + columns.RelativeColumn(1); // Qté + columns.RelativeColumn(2); // PU + columns.RelativeColumn(2); // Total + }); + + // En-têtes + table.Header(header => + { + header.Cell().Element(CellHeader).Text("Produit"); + header.Cell().Element(CellHeader).AlignRight().Text("Qté"); + header.Cell().Element(CellHeader).AlignRight().Text("PU"); + header.Cell().Element(CellHeader).AlignRight().Text("Total"); + }); + + foreach (PurchaseProduct l in lignes) + { + decimal price = l.Product!.Prices! + .FirstOrDefault(x => x.SupplierId == l.PurchaseOrder!.SupplierId && x.ProductId == l.ProductId) + ?.SellingPrice ?? 0; + + table.Cell().Element(CellBody).Text(l.Product?.Name); + table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString()); + table.Cell().Element(CellBody).AlignRight().Text($"{price:n2} €"); + table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity * price:n2} €"); + + totalQuantity += l.Quantity; + total += l.Quantity * price; + } + + IContainer CellHeader(IContainer c) => + c.BorderBottom(1).PaddingVertical(5).DefaultTextStyle(x => x.SemiBold()); + + IContainer CellBody(IContainer c) => + c.PaddingVertical(2); + }); + + col.Item().LineHorizontal(1); + col.Item().Height(30); + + col.Item().Row(row => + { + // Colonne gauche : conditions de vente + row.RelativeItem().Column(left => + { + left.Item().Text("Conditions de vente") + .SemiBold().FontSize(12); + left.Item().Text(purchaseOrder.PurchaseConditions) + .FontSize(9); + }); + + // Colonne droite : totaux + row.ConstantItem(180).Column(right => + { + right.Item().AlignRight().Text($"Total: {totalQuantity} produits"); + right.Item().AlignRight().Text($"Total HT: {total:n2} €"); + right.Item().AlignRight().Text("Taxe: 20 %"); + right.Item().AlignRight().Text($"Total TTC: {total * (decimal)1.2:n2} €"); + }); + }); + }); + + // Signature en bas à droite + page.Footer().AlignRight().Column(col => { col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); + }); + }); + + return document.GeneratePdf(); + } +} \ No newline at end of file diff --git a/PyroFetes/Services/Pdf/QuotationPdfService.cs b/PyroFetes/Services/Pdf/QuotationPdfService.cs new file mode 100644 index 0000000..9456932 --- /dev/null +++ b/PyroFetes/Services/Pdf/QuotationPdfService.cs @@ -0,0 +1,146 @@ +using PyroFetes.Models; +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; + +namespace PyroFetes.Services.Pdf; + +public interface IQuotationPdfService +{ + byte[] Generate(Quotation quotation, List lignes, Setting setting); +} + +public class QuotationPdfService : IQuotationPdfService +{ + public byte[] Generate(Quotation quotation, List lignes, Setting setting) + { + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); + decimal total = 0; + Document document = Document.Create(container => + { + container.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(30); + page.DefaultTextStyle(x => x.FontSize(11)); + + page.Header().Row(row => + { + // Client à gauche + row.RelativeItem().Column(col => + { + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text(""); + col.Item().Text("Client").SemiBold().FontSize(12); + col.Item().Text($"{quotation.Customer?.Note}"); + col.Item().Text($"{quotation.Customer?.CustomerType?.Label}"); + }); + + // Logo + société à droite + row.ConstantItem(200).Column(col => + { + col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea); + col.Item().Height(20); + col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold(); + col.Item().Height(5); + col.Item().AlignRight().Text("24, rue La Fosse Mardeau\n41700 Le Controis-en-Sologne"); + col.Item().Height(5); + col.Item().AlignRight().Text("Téléphone: 02 54 78 77 66"); + col.Item().Height(5); + col.Item().AlignRight().Text("SIRET: 82031463100012"); + col.Item().Height(40); + }); + }); + + page.Content().Column(col => + { + // Titre + date + col.Item().Row(row => + { + row.RelativeItem().Text($"Devis n° {quotation.Id}") + .FontSize(16).SemiBold(); + + row.ConstantItem(200).AlignRight().Text( + $"Le {DateTime.Now:dd/MM/yyyy}"); + }); + col.Item().Height(20); + + col.Item().LineHorizontal(1); + + // Tableau des lignes + col.Item().Table(table => + { + table.ColumnsDefinition(columns => + { + columns.RelativeColumn(10); // Produit + columns.RelativeColumn(2); // Qté + columns.RelativeColumn(3); // PU + columns.RelativeColumn(3); // Total + }); + + // En-têtes + table.Header(header => + { + header.Cell().Element(CellHeader).Text("Produit"); + header.Cell().Element(CellHeader).AlignRight().Text("Qté"); + header.Cell().Element(CellHeader).AlignRight().Text("PU"); + header.Cell().Element(CellHeader).AlignRight().Text("Total"); + }); + + foreach (QuotationProduct l in lignes) + { + decimal price = l.Product!.Prices! + .FirstOrDefault(x => x.SupplierId == l.Quotation!.SupplierId && x.ProductId == l.ProductId) + ?.SellingPrice ?? 0; + + table.Cell().Element(CellBody).Text(l.Product?.Name); + table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString()); + table.Cell().Element(CellBody).AlignRight().Text($"{price:n2} €"); + table.Cell().Element(CellBody).AlignRight().Text($"{price * l.Quantity:n2} €"); + + total += l.Quantity * price; + } + + IContainer CellHeader(IContainer c) => c.BorderBottom(1).PaddingVertical(5).DefaultTextStyle(x => x.SemiBold()); + + IContainer CellBody(IContainer c) => c.PaddingVertical(2); + }); + + col.Item().LineHorizontal(1); + col.Item().Height(30); + + col.Item().Row(row => + { + // Colonne gauche : conditions de vente + row.RelativeItem().Column(left => + { + left.Item().Text("Conditions de vente") + .SemiBold().FontSize(12); + left.Item().Text(quotation.ConditionsSale) + .FontSize(9); + }); + + // Colonne droite : totaux + row.ConstantItem(180).Column(right => + { + right.Item().AlignRight().Text($"Total HT : {total:n2} €"); + right.Item().AlignRight().Text("Taxe : 20 %"); + right.Item().AlignRight().Text($"Total TTC : {total * (decimal)1.2:n2} €"); + }); + }); + }); + + // Signature en bas à droite + page.Footer().AlignRight().Column(col => { col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); + }); + }); + + // Pour avoir la vue du PDF en temps réel + // document.ShowInCompanion(); + + return document.GeneratePdf(); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs b/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs index 6376381..8477c0c 100644 --- a/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs +++ b/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Deliverers; -public sealed class GetDelivererByIdSpec : Specification +public sealed class GetDelivererByIdSpec : SingleResultSpecification { public GetDelivererByIdSpec(int delivererId) { diff --git a/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs new file mode 100644 index 0000000..83b85ec --- /dev/null +++ b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs @@ -0,0 +1,17 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.DeliveryNotes; + +public class GetAllDeliveryNoteSpec : Specification +{ + public GetAllDeliveryNoteSpec() + { + Query + .Include(x => x.Deliverer) + .Include(x => x.ProductDeliveries)! + .ThenInclude(x => x.Product) + .OrderBy(x => x.RealDeliveryDate) + .ThenByDescending(x => x.ExpeditionDate); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs new file mode 100644 index 0000000..46feb4c --- /dev/null +++ b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs @@ -0,0 +1,17 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.DeliveryNotes; + +public class GetAllDeliveryNotesByRealDateSpec : Specification +{ + public GetAllDeliveryNotesByRealDateSpec() + { + Query + .Include(x => x.Deliverer) + .Include(x => x.ProductDeliveries)! + .ThenInclude(x => x.Product) + .Where(x => x.RealDeliveryDate == null) + .OrderByDescending(x => x.ExpeditionDate); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs index 2fc0494..e37a904 100644 --- a/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs +++ b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs @@ -3,11 +3,14 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.DeliveryNotes; -public sealed class GetDeliveryNoteByIdSpec : Specification +public sealed class GetDeliveryNoteByIdSpec : SingleResultSpecification { public GetDeliveryNoteByIdSpec(int deliveryNoteId) { Query + .Include(x => x.Deliverer) + .Include(x => x.ProductDeliveries!) + .ThenInclude(x => x.Product) .Where(x => x.Id == deliveryNoteId); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdWithProductsSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdWithProductsSpec.cs new file mode 100644 index 0000000..3ba5fbd --- /dev/null +++ b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdWithProductsSpec.cs @@ -0,0 +1,18 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.DeliveryNotes; + +public class GetDeliveryNoteByIdWithProductsSpec : SingleResultSpecification +{ + public GetDeliveryNoteByIdWithProductsSpec(int deliveryNoteId) + { + Query + .Include(x => x.ProductDeliveries!) + .ThenInclude(p => p.Product) + .ThenInclude(x => x!.Prices) + .Include(x => x.Deliverer) + .Include(x => x.Supplier) + .Where(x => x.Id == deliveryNoteId); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs b/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs index 5f74c13..42a883b 100644 --- a/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs +++ b/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs @@ -3,11 +3,11 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Prices; -public sealed class GetPriceByProductIdAndSupplierIdSpec : Specification +public sealed class GetPriceByProductIdAndSupplierIdSpec : SingleResultSpecification { public GetPriceByProductIdAndSupplierIdSpec(int? productId, int? supplierId) { Query - .Where(p => p.ProductId == productId && p.SupplierId == supplierId); + .Where(x => x.ProductId == productId && x.SupplierId == supplierId); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Products/GetProductByIdSpec.cs b/PyroFetes/Specifications/Products/GetProductByIdSpec.cs index fb7322c..24fb16f 100644 --- a/PyroFetes/Specifications/Products/GetProductByIdSpec.cs +++ b/PyroFetes/Specifications/Products/GetProductByIdSpec.cs @@ -3,11 +3,12 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Products; -public sealed class GetProductByIdSpec : Specification +public sealed class GetProductByIdSpec : SingleResultSpecification { - public GetProductByIdSpec(int? productId) + public GetProductByIdSpec(int productId) { Query - .Where(p => p.Id == productId); + .Where(p => p.Id == productId) + .Include(p => p.Prices); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs new file mode 100644 index 0000000..df57b0c --- /dev/null +++ b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs @@ -0,0 +1,15 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.Products; + +public sealed class GetProductsUnderLimitSpec : Specification +{ + public GetProductsUnderLimitSpec() + { + Query + .Include(x => x.WarehouseProducts) + .Where(x => x.WarehouseProducts != null && x.WarehouseProducts.Sum(p => p.Quantity) < x.MinimalQuantity + && !x.ProductDeliveries!.Any(d => d.DeliveryNote!.RealDeliveryDate == null)); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs b/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs new file mode 100644 index 0000000..827d952 --- /dev/null +++ b/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs @@ -0,0 +1,14 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.PurchaseOrders; + +public class GetAllPurchaseOrderSpec : Specification +{ + public GetAllPurchaseOrderSpec() + { + Query + .Where(x => true) + .OrderByDescending(x => x.Id); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs index 272ad75..b903686 100644 --- a/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs +++ b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs @@ -3,12 +3,13 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.PurchaseOrders; -public sealed class GetPurchaseOrderByIdSpec : Specification +public sealed class GetPurchaseOrderByIdSpec : SingleResultSpecification { public GetPurchaseOrderByIdSpec(int purchaseOrderId) { Query - .Include(po => po.PurchaseProducts) - .Where(po => po.Id == purchaseOrderId); + .Include(x => x.PurchaseProducts!) + .ThenInclude(x => x.Product) + .Where(x => x.Id == purchaseOrderId); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdWithProductsSpec.cs b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdWithProductsSpec.cs new file mode 100644 index 0000000..fbd3c38 --- /dev/null +++ b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdWithProductsSpec.cs @@ -0,0 +1,17 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.PurchaseOrders; + +public class GetPurchaseOrderByIdWithProductsSpec : SingleResultSpecification +{ + public GetPurchaseOrderByIdWithProductsSpec(int purchaseOrderId) + { + Query + .Where(x => x.Id == purchaseOrderId) + .Include(x => x.PurchaseProducts!) + .ThenInclude(p => p.Product) + .ThenInclude(p => p!.Prices) + .Include(x => x.Supplier); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs b/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs index 5d35c62..45e4f6e 100644 --- a/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs +++ b/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs @@ -3,9 +3,9 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.PurchaseProducts; -public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : Specification +public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : SingleResultSpecification { - public GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(int productId, int purchaseOrderId) + public GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(int productId, int purchaseOrderId) { Query .Where(p => p.ProductId == productId && p.PurchaseOrderId == purchaseOrderId); diff --git a/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs b/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs index 9c3b65a..f0fb536 100644 --- a/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs +++ b/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.QuotationProducts; -public sealed class GetQuotationProductByProductIdAndQuotationIdSpec : Specification +public sealed class GetQuotationProductByProductIdAndQuotationIdSpec : SingleResultSpecification { public GetQuotationProductByProductIdAndQuotationIdSpec(int productId, int quotationId) { diff --git a/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs b/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs new file mode 100644 index 0000000..e386950 --- /dev/null +++ b/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs @@ -0,0 +1,14 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.Quotations; + +public class GetAllQuotationSpec : Specification +{ + public GetAllQuotationSpec() + { + Query + .Where(x => true) + .OrderByDescending(x => x.Id); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/Quotations/GetQuotationByIdSpec.cs b/PyroFetes/Specifications/Quotations/GetQuotationByIdSpec.cs index 37424e9..57cb7b7 100644 --- a/PyroFetes/Specifications/Quotations/GetQuotationByIdSpec.cs +++ b/PyroFetes/Specifications/Quotations/GetQuotationByIdSpec.cs @@ -3,12 +3,13 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Quotations; -public sealed class GetQuotationByIdSpec : Specification +public sealed class GetQuotationByIdSpec : SingleResultSpecification { public GetQuotationByIdSpec(int quotationId) { Query - .Include(q => q.QuotationProducts) + .Include(x => x.QuotationProducts!) + .ThenInclude(x => x.Product) .Where(x => x.Id == quotationId); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Quotations/GetQuotationByIdWithProductsSpec.cs b/PyroFetes/Specifications/Quotations/GetQuotationByIdWithProductsSpec.cs new file mode 100644 index 0000000..b689f14 --- /dev/null +++ b/PyroFetes/Specifications/Quotations/GetQuotationByIdWithProductsSpec.cs @@ -0,0 +1,18 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.Quotations; + +public class GetQuotationByIdWithProductsSpec : SingleResultSpecification +{ + public GetQuotationByIdWithProductsSpec(int quotationId) + { + Query + .Where(x => x.Id == quotationId) + .Include(x => x.QuotationProducts!) + .ThenInclude(x => x.Product) + .ThenInclude(x => x!.Prices) + .Include(x => x.Customer) + .ThenInclude(x => x!.CustomerType); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs b/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs deleted file mode 100644 index cc786e4..0000000 --- a/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Ardalis.Specification; -using PyroFetes.Models; - -namespace PyroFetes.Specifications.Settings; - -public sealed class GetSettingByIdSpec : Specification -{ - public GetSettingByIdSpec(int settingId) - { - Query - .Where(setting => setting.Id == settingId); - } -} \ No newline at end of file diff --git a/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs b/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs index add1699..c649454 100644 --- a/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs +++ b/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs @@ -3,11 +3,13 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Suppliers; -public sealed class GetSupplierByIdSpec : Specification +public sealed class GetSupplierByIdSpec : SingleResultSpecification { public GetSupplierByIdSpec(int? supplierId) { Query + .Include(x => x.Prices!) + .ThenInclude(p => p.Product) .Where(x => x.Id == supplierId); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Users/GetUserByIdSpec.cs b/PyroFetes/Specifications/Users/GetUserByIdSpec.cs index db5c0be..7cd8d7c 100644 --- a/PyroFetes/Specifications/Users/GetUserByIdSpec.cs +++ b/PyroFetes/Specifications/Users/GetUserByIdSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Users; -public sealed class GetUserByIdSpec : Specification +public sealed class GetUserByIdSpec : SingleResultSpecification { public GetUserByIdSpec(int userId) { diff --git a/PyroFetes/Specifications/Users/GetUserByNameSpec.cs b/PyroFetes/Specifications/Users/GetUserByNameSpec.cs index daa75ad..78edf1f 100644 --- a/PyroFetes/Specifications/Users/GetUserByNameSpec.cs +++ b/PyroFetes/Specifications/Users/GetUserByNameSpec.cs @@ -3,11 +3,11 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Users; -public sealed class GetUserByNameSpec : Specification +public sealed class GetUserByNameSpec : SingleResultSpecification { public GetUserByNameSpec(string userName) { Query - .Where(x=> x.Name == userName); + .Where(x => x.Name == userName); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/WareHouse/GetWareHouseByIdSpec.cs b/PyroFetes/Specifications/WareHouse/GetWareHouseByIdSpec.cs new file mode 100644 index 0000000..edf79c7 --- /dev/null +++ b/PyroFetes/Specifications/WareHouse/GetWareHouseByIdSpec.cs @@ -0,0 +1,13 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.WareHouse; + +public class GetWareHouseByIdSpec : SingleResultSpecification +{ + public GetWareHouseByIdSpec(int id) + { + Query + .Where(x => x.Id == id); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/WarehouseProducts/GetProductTotalQuantitySpec.cs b/PyroFetes/Specifications/WarehouseProducts/GetProductTotalQuantitySpec.cs index 9dd451f..c860c36 100644 --- a/PyroFetes/Specifications/WarehouseProducts/GetProductTotalQuantitySpec.cs +++ b/PyroFetes/Specifications/WarehouseProducts/GetProductTotalQuantitySpec.cs @@ -9,6 +9,5 @@ public sealed class GetProductTotalQuantitySpec : Specification wp.ProductId == productId); - } } \ No newline at end of file diff --git a/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs b/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs index ff135c1..416c01a 100644 --- a/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs +++ b/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs @@ -3,11 +3,16 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.WarehouseProducts; -public sealed class GetWarehouseProductByProductIdSpec : Specification +public sealed class GetWarehouseProductByProductIdSpec : SingleResultSpecification { - public GetWarehouseProductByProductIdSpec(int productId) + public GetWarehouseProductByProductIdSpec(int productId, int? warehouseId = null) { Query .Where(x => x.ProductId == productId); + + if (warehouseId.HasValue) + { + Query.Where(x => x.WarehouseId == warehouseId.Value); + } } } \ No newline at end of file diff --git a/PyroFetes/data.sql b/PyroFetes/data.sql new file mode 100644 index 0000000..876af84 --- /dev/null +++ b/PyroFetes/data.sql @@ -0,0 +1,765 @@ +-- ============================================================ +-- PyroFetes – Jeu de données complet +-- Compatible SQL Server / EF Core +-- Ordre d'insertion respectant les contraintes FK +-- ============================================================ + +-- ------------------------------------------------------- +-- 2. Cities +-- ------------------------------------------------------- +INSERT INTO Cities (Name, ZipCode) +VALUES ('Paris', 75001), + ('Lyon', 69001), + ('Marseille', 13001), + ('Bordeaux', 33000), + ('Strasbourg', 67000), + ('Nantes', 44000), + ('Toulouse', 31000), + ('Lille', 59000), + ('Nice', 06000), + ('Montpellier', 34000); + +-- ------------------------------------------------------- +-- 3. Classifications +-- ------------------------------------------------------- +INSERT INTO Classifications (Label) +VALUES ('F1 – Faible danger'), + ('F2 – Danger moyen'), + ('F3 – Danger élevé'), + ('F4 – Usage professionnel'), + ('T1 – Théâtral usage général'), + ('T2 – Théâtral usage professionnel'); + +-- ------------------------------------------------------- +-- 4. ProductCategories +-- ------------------------------------------------------- +INSERT INTO ProductCategories (Label) +VALUES ('Bouquet final'), + ('Chandelle romaine'), + ('Fontaine'), + ('Fusée'), + ('Mine'), + ('Pétard'), + ('Torche'), + ('Batterie'), + ('Cascades'), + ('Lanceur électrique'); + +-- ------------------------------------------------------- +-- 5. Colors +-- ------------------------------------------------------- +INSERT INTO Colors (Label) +VALUES ('Rouge'), + ('Vert'), + ('Bleu'), + ('Or'), + ('Argent'), + ('Blanc'), + ('Orange'), + ('Violet'), + ('Rose'), + ('Multicolore'); + +-- ------------------------------------------------------- +-- 6. Effects +-- ------------------------------------------------------- +INSERT INTO Effects (Label) +VALUES ('Craquement'), + ('Sifflement'), + ('Scintillement'), + ('Pluie dorée'), + ('Bouquet étoilé'), + ('Palmier'), + ('Chrysanthème'), + ('Peony'), + ('Comet'), + ('Strobe'), + ('Nishiki Kamuro'), + ('Pistil'); + +-- ------------------------------------------------------- +-- 7. Movements (avant Products car FK) +-- ------------------------------------------------------- +INSERT INTO Movements (Date, Start, Arrival, Quantity, SourceWarehouseId, DestinationWarehouseId) +VALUES ('2024-01-10 08:00:00', '2024-01-10 08:00:00', '2024-01-10 14:00:00', 200, NULL, 1), + ('2024-02-15 09:00:00', '2024-02-15 09:00:00', '2024-02-15 16:30:00', 150, NULL, 2), + ('2024-03-01 07:30:00', '2024-03-01 07:30:00', '2024-03-01 12:00:00', 80, 1, 3), + ('2024-04-20 10:00:00', '2024-04-20 10:00:00', '2024-04-20 18:00:00', 300, 2, 1), + ('2024-05-05 08:00:00', '2024-05-05 08:00:00', '2024-05-05 15:00:00', 120, 3, 2), + ('2024-06-14 06:00:00', '2024-06-14 06:00:00', '2024-06-14 10:00:00', 500, 1, NULL), + ('2024-07-04 07:00:00', '2024-07-04 07:00:00', '2024-07-04 11:00:00', 250, 2, NULL), + ('2024-08-12 09:00:00', '2024-08-12 09:00:00', '2024-08-12 17:00:00', 180, NULL, 3); + +-- ------------------------------------------------------- +-- 8. Products +-- ------------------------------------------------------- +INSERT INTO Products (Reference, Name, Duration, Caliber, ApprovalNumber, Weight, Nec, Image, Link, MinimalQuantity, ClassificationId, ProductCategoryId, MovementId) +VALUES ('PYR-001', 'Bouquet Tricolore 30T', 45.5, 30, 'APP-2023-001', 1.200, 0.850, 'products/bouquet_tricolore.jpg', 'https://catalogue.pyrofetes.fr/PYR-001', 10, 4, 1, 2), + ('PYR-002', 'Chandelle Or 25T', 30.0, 25, 'APP-2023-002', 0.800, 0.560, 'products/chandelle_or.jpg', 'https://catalogue.pyrofetes.fr/PYR-002', 20, 3, 2, 2), + ('PYR-003', 'Fontaine Argentée 20T', 60.0, 20, 'APP-2023-003', 0.500, 0.300, 'products/fontaine_arg.jpg', 'https://catalogue.pyrofetes.fr/PYR-003', 15, 2, 3, 3), + ('PYR-004', 'Fusée Palmier 50T', 25.0, 50, 'APP-2023-004', 2.500, 1.800, 'products/fusee_palmier.jpg', 'https://catalogue.pyrofetes.fr/PYR-004', 5, 4, 4, 4), + ('PYR-005', 'Mine Chrysanthème 75T', 15.0, 75, 'APP-2023-005', 3.200, 2.400, 'products/mine_chrysantheme.jpg', 'https://catalogue.pyrofetes.fr/PYR-005', 5, 4, 5, 5), + ('PYR-006', 'Batterie Festival 100T', 120.0, 100, 'APP-2023-006', 8.000, 5.600, 'products/batterie_festival.jpg', 'https://catalogue.pyrofetes.fr/PYR-006', 3, 4, 8, 6), + ('PYR-007', 'Torche Colorée 15T', 90.0, 15, 'APP-2023-007', 0.300, 0.180, 'products/torche_coloree.jpg', 'https://catalogue.pyrofetes.fr/PYR-007', 30, 2, 7, 7), + ('PYR-008', 'Cascade Dorée 40T', 75.0, 40, 'APP-2023-008', 1.800, 1.200, 'products/cascade_doree.jpg', 'https://catalogue.pyrofetes.fr/PYR-008', 10, 4, 9, 8), + ('PYR-009', 'Peony Multicolore 60T', 30.0, 60, 'APP-2023-009', 4.500, 3.200, 'products/peony_multi.jpg', 'https://catalogue.pyrofetes.fr/PYR-009', 5, 4, 1, 6), + ('PYR-010', 'Lanceur 36 Tirs EL', 0.0, 0, 'APP-2023-010', 2.100, 0.000, 'products/lanceur_36.jpg', 'https://catalogue.pyrofetes.fr/PYR-010', 2, 6, 10, 2), + ('PYR-011', 'Strobe Blanc Intense 25T', 45.0, 25, 'APP-2023-011', 0.900, 0.650, 'products/strobe_blanc.jpg', 'https://catalogue.pyrofetes.fr/PYR-011', 10, 3, 3, 3), + ('PYR-012', 'Comet Violet 30T', 20.0, 30, 'APP-2023-012', 1.100, 0.800, 'products/comet_violet.jpg', 'https://catalogue.pyrofetes.fr/PYR-012', 12, 3, 4, 4); + +-- ------------------------------------------------------- +-- 9. Brands +-- ------------------------------------------------------- +INSERT INTO Brands (Name, ProductId) +VALUES ('PyroMaster', 3), + ('GoldFlame', 3), + ('ArtificePlus', 10), + ('ArtificePlus', 3), + ('StarBurst', 4), + ('StarBurst', 5), + ('FestivalFire', 6), + ('TorchCo', 7), + ('GoldFlame', 8), + ('PyroMaster', 9), + ('ElecFire', 10), + ('PyroMaster', 11), + ('StarBurst', 12); + +-- ------------------------------------------------------- +-- 10. ProductColors +-- ------------------------------------------------------- +INSERT INTO ProductColors (ProductId, ColorId) +VALUES (3, 1), + (3, 3), + (3, 6), -- Bouquet Tricolore : rouge, bleu, blanc + (3, 4), -- Chandelle Or + (3, 5), -- Fontaine Argentée + (4, 4), + (4, 2), -- Fusée Palmier : or, vert + (5, 7), + (5, 4), -- Mine Chrysanthème : orange, or + (6, 10), -- Batterie Festival : multicolore + (7, 1), + (7, 2), + (7, 3), -- Torche : rouge, vert, bleu + (8, 4), + (8, 5), -- Cascade Dorée : or, argent + (9, 10), -- Peony Multicolore + (11, 6), -- Strobe Blanc + (12, 8); +-- Comet Violet + +-- ------------------------------------------------------- +-- 11. ProductEffects +-- ------------------------------------------------------- +INSERT INTO ProductEffects (ProductId, EffectId) +VALUES (3, 5), + (3, 8), -- Bouquet : bouquet étoilé, peony + (3, 4), + (4, 3), -- Chandelle Or : pluie dorée, scintillement + (3, 3), -- Fontaine : scintillement + (4, 6), + (4, 9), -- Fusée Palmier : palmier, comet + (5, 7), + (5, 1), -- Mine : chrysanthème, craquement + (6, 5), + (6, 7), + (6, 10), -- Batterie : bouquet, chrysanthème, strobe + (7, 3), + (7, 2), -- Torche : scintillement, sifflement + (8, 4), + (8, 11), -- Cascade : pluie dorée, Nishiki + (9, 8), + (9, 12), -- Peony : peony, pistil + (11, 10), -- Strobe + (12, 9); +-- Comet + +-- ------------------------------------------------------- +-- 12. Warehouses +-- ------------------------------------------------------- +INSERT INTO Warehouses (Name, MaxWeight, [ Current], MinWeight, Address, ZipCode, City) +VALUES ('Entrepôt Central Paris', 50000, 18500, 5000, '12 rue de la Pyrotechnie', '75019', 'Paris'), + ('Dépôt Sud Marseille', 30000, 12000, 3000, '8 avenue du Port Sec', '13016', 'Marseille'), + ('Stockage Est Strasbourg', 20000, 8200, 2000, '5 chemin des Entrepôts', '67200', 'Strasbourg'), + ('Site Ouest Nantes', 25000, 6500, 2500, '22 zone industrielle Ouest', '44800', 'Nantes'); + +-- ------------------------------------------------------- +-- 13. WarehouseProducts +-- ------------------------------------------------------- +INSERT INTO WarehouseProducts (ProductId, WarehouseId, Quantity) +VALUES (3, 1, 120), + (3, 2, 60), + (3, 3, 80), + (3, 4, 90), + (4, 1, 40), + (4, 2, 25), + (5, 1, 30), + (5, 2, 15), + (6, 1, 20), + (6, 3, 10), + (7, 2, 300), + (7, 4, 180), + (8, 1, 75), + (8, 2, 50), + (9, 1, 35), + (10, 1, 18), + (10, 3, 12), + (11, 2, 60), + (12, 3, 45); + +-- ------------------------------------------------------- +-- 14. Materials +-- ------------------------------------------------------- +INSERT INTO Materials (Name, Quantity, WarehouseId) +VALUES ('Câble électrique 50m', 40, 1), + ('Détonateur électrique', 500, 1), + ('Bouchon sécurité rouge', 300, 1), + ('Trépied aluminium', 25, 2), + ('Tuyau métallique 1m', 80, 2), + ('Boitier de tir 36 sorties', 10, 1), + ('Rallonge 10m IP67', 60, 3), + ('Mortier plastique 50mm', 200, 3), + ('Mortier acier 75mm', 100, 1), + ('Tableau de tir 100 CH', 5, 4), + ('Caisse de transport étanche', 30, 2), + ('Lunettes de protection', 50, 1); + +-- ------------------------------------------------------- +-- 15. MaterialWarehouses +-- ------------------------------------------------------- +INSERT INTO MaterialWarehouses (MaterialId, WarehouseId) +VALUES (1, 1), + (1, 3), + (2, 1), + (2, 2), + (3, 1), + (4, 2), + (4, 4), + (5, 2), + (5, 3), + (6, 1), + (6, 4), + (7, 3), + (8, 3), + (8, 1), + (9, 1), + (10, 4), + (11, 2), + (12, 1), + (12, 2); + +-- ------------------------------------------------------- +-- 16. Suppliers +-- ------------------------------------------------------- +INSERT INTO Suppliers (Name, Email, Phone, Address, ZipCode, City, DeliveryDelay) +VALUES ('Pyrotechnie Ruggieri', 'commandes@ruggieri.fr', '01 47 00 11 22', '14 avenue de la Fête', '75015', 'Paris', 7), + ('Lacroix Défense Feux', 'pro@lacroix-feux.com', '04 78 92 00 10', '3 zone industrielle Nord', '69130', 'Lyon', 10), + ('Jorge Banus Pyro', 'info@jorgebanus-pyro.es', '+34 952 810 000', 'Pol. Ind. Las Maravillas', '29600', 'Marbella', 21), + ('Brother Pyro Import', 'sales@brotherpyro.com', '+1 555 010 2020', '1200 Fireworks Blvd', '30301', 'Atlanta', 30), + ('Nico Pyrotechnie', 'achats@nico-pyro.fr', '04 91 25 36 47', '27 impasse des Artifices', '13010', 'Marseille', 5), + ('Surex Pyrotechnie', 'contact@surex.fr', '03 90 00 12 34', '10 rue Gutenberg', '67600', 'Sélestat', 6); + +-- ------------------------------------------------------- +-- 17. Prices (Product x Supplier) +-- ------------------------------------------------------- +INSERT INTO Prices (ProductId, SupplierId, SellingPrice) +VALUES (1, 1, 12.50), + (1, 2, 13.00), + (2, 1, 6.80), + (2, 5, 7.20), + (3, 1, 4.50), + (3, 5, 4.80), + (4, 2, 28.00), + (4, 3, 26.50), + (5, 2, 35.00), + (5, 3, 33.00), + (6, 1, 95.00), + (6, 2, 98.50), + (7, 5, 3.20), + (7, 6, 3.50), + (8, 1, 22.00), + (8, 2, 23.50), + (9, 2, 42.00), + (9, 4, 39.00), + (10, 1, 185.00), + (10, 6, 190.00), + (11, 5, 8.90), + (11, 6, 9.20), + (12, 3, 14.00), + (12, 4, 13.50); + +-- ------------------------------------------------------- +-- 18. Deliverers +-- ------------------------------------------------------- +INSERT INTO Deliverers (Transporter) +VALUES ('Chronopost Marchandises Dangereuses'), + ('DHL Fret Spécial'), + ('TNT Express ADR'), + ('Transport Pyro Interne'), + ('Geodis Fret'); + +-- ------------------------------------------------------- +-- 19. DeliveryNotes +-- ------------------------------------------------------- +INSERT INTO DeliveryNotes (TrackingNumber, DelivererId, EstimateDeliveryDate, ExpeditionDate, RealDeliveryDate) +VALUES ('CPM-2024-001234', 1, '2024-01-12', '2024-01-09', '2024-01-12'), + ('DHL-2024-005678', 2, '2024-02-18', '2024-02-14', '2024-02-17'), + ('TNT-2024-009012', 3, '2024-03-05', '2024-03-01', '2024-03-06'), + ('INT-2024-000001', 4, '2024-04-22', '2024-04-20', '2024-04-22'), + ('GEO-2024-001111', 5, '2024-05-10', '2024-05-07', NULL); + +-- ------------------------------------------------------- +-- 20. ProductDeliveries +-- ------------------------------------------------------- +INSERT INTO ProductDeliveries (ProductId, DeliveryNoteId, Quantity) +VALUES (1, 1, 60), + (2, 1, 100), + (3, 2, 80), + (4, 2, 20), + (5, 3, 15), + (6, 3, 8), + (7, 4, 150), + (8, 4, 40), + (9, 5, 30), + (10, 5, 6); + +-- ------------------------------------------------------- +-- 21. PurchaseOrders +-- ------------------------------------------------------- +INSERT INTO PurchaseOrders (PurchaseConditions, SupplierId) +VALUES ('Paiement à 30 jours – transport inclus – palette EUR 80x120', 1), + ('Paiement à 60 jours – Incoterm EXW Lyon – assurance acheteur', 2), + ('Paiement anticipé -2% – transport DDP Paris – emballage ADR inclus', 5), + ('Paiement à 45 jours – transport à la charge du vendeur jusqu au dépôt', 3), + ('Paiement à 30 jours – transport maritime consolidé', 4); + +-- ------------------------------------------------------- +-- 22. PurchaseProducts +-- ------------------------------------------------------- +INSERT INTO PurchaseProducts (ProductId, PurchaseOrderId, Quantity) +VALUES (1, 1, 200), + (2, 1, 300), + (3, 1, 150), + (4, 2, 50), + (5, 2, 30), + (6, 2, 20), + (7, 3, 500), + (8, 3, 100), + (9, 4, 40), + (10, 4, 15), + (11, 5, 100), + (12, 5, 80); + +-- ------------------------------------------------------- +-- 23. ProviderTypes +-- ------------------------------------------------------- +INSERT INTO ProviderTypes (Label) +VALUES ('Sonorisation'), + ('Éclairage scénique'), + ('Sécurité / Protection'), + ('Logistique & Transport'), + ('Location de matériel'), + ('Médical / Secours'); + +-- ------------------------------------------------------- +-- 24. ServiceProviders +-- ------------------------------------------------------- +INSERT INTO ServiceProviders (Price, ProviderTypeId) +VALUES (4500.00, 1), + (3200.00, 1), + (5800.00, 2), + (2800.00, 3), + (7500.00, 3), + (1200.00, 4), + (73500.00, 5), + (900.00, 6); + +-- ------------------------------------------------------- +-- 25. CustomerTypes +-- ------------------------------------------------------- +INSERT INTO CustomerTypes (Label) +VALUES ('Mairie / Collectivité'), + ('Association'), + ('Entreprise privée'), + ('Particulier'), + ('Organisateur d événements'); + +-- ------------------------------------------------------- +-- 26. Customers + + +-- ------------------------------------------------------- +-- 27. Contacts +-- ------------------------------------------------------- + + +-- ------------------------------------------------------- +-- 31. QuotationProducts +-- ------------------------------------------------------- +INSERT INTO QuotationProducts (ProductId, QuotationId, Quantity) +VALUES (1, 1, 80), + (4, 1, 30), + (5, 1, 20), + (6, 1, 5), + (8, 1, 40), + (2, 2, 50), + (3, 2, 40), + (7, 2, 80), + (1, 3, 40), + (6, 3, 3), + (9, 3, 15), + (1, 4, 60), + (4, 4, 20), + (6, 4, 4), + (7, 4, 100), + (1, 5, 70), + (5, 5, 15), + (8, 5, 30), + (2, 6, 60), + (3, 6, 50), + (7, 6, 90); + +-- ------------------------------------------------------- +-- 32. Staff +-- ------------------------------------------------------- +INSERT INTO Staffs (FirstName, LastName, Profession, Email, F4T2NumberApproval, F4T2ExpirationDate) +VALUES ('Antoine', 'Duval', 'Chef artificier', 'a.duval@pyrofetes.fr', 'F4-2021-00142', '2025-12-31'), + ('Camille', 'Renard', 'Artificier', 'c.renard@pyrofetes.fr', 'F4-2022-00255', '2026-06-30'), + ('Nicolas', 'Lefort', 'Artificier', 'n.lefort@pyrofetes.fr', 'F4-2020-00387', '2024-12-31'), + ('Emma', 'Vidal', 'Technicien pyrotechnie', 'e.vidal@pyrofetes.fr', 'T2-2023-00104', '2027-03-31'), + ('Julien', 'Moreau', 'Chef de chantier', 'j.moreau@pyrofetes.fr', 'F4-2021-00521', '2025-09-30'), + ('Laura', 'Blanc', 'Artificière', 'l.blanc@pyrofetes.fr', 'F4-2022-00698', '2026-12-31'), + ('Pierre', 'Garnier', 'Technicien électronique', 'p.garnier@pyrofetes.fr', 'T2-2021-00789', '2025-11-30'), + ('Marie', 'Lefebvre', 'Responsable sécurité', 'm.lefebvre@pyrofetes.fr', 'F4-2023-00901', '2027-06-30'), + ('Hugo', 'Simon', 'Artificier junior', 'h.simon@pyrofetes.fr', 'T1-2023-01023', '2025-06-30'), + ('Pauline', 'Robert', 'Coordinatrice logistique', 'p.robert@pyrofetes.fr', 'T2-2022-01145', '2026-09-30'); + +-- ------------------------------------------------------- +-- 33. ExperienceLevels +-- ------------------------------------------------------- +INSERT INTO ExperienceLevels (Label, StaffId) +VALUES ('Expert – +15 ans', 1), + ('Confirmé – 8 ans', 2), + ('Confirmé – 6 ans', 3), + ('Intermédiaire – 3 ans', 4), + ('Expert – +12 ans', 5), + ('Confirmé – 7 ans', 6), + ('Intermédiaire – 4 ans', 7), + ('Confirmé – 5 ans', 8), + ('Débutant – 1 an', 9), + ('Intermédiaire – 3 ans', 10); + +-- ------------------------------------------------------- +-- 34. HistoryOfApprovals +-- ------------------------------------------------------- +INSERT INTO HistoryOfApprovals (DeliveryDate, ExpirationDate) +VALUES ('2021-03-15', '2025-12-31'), + ('2022-06-01', '2026-06-30'), + ('2020-09-10', '2024-12-31'), + ('2023-01-20', '2027-03-31'), + ('2021-09-05', '2025-09-30'), + ('2022-12-15', '2026-12-31'), + ('2021-11-01', '2025-11-30'), + ('2023-06-10', '2027-06-30'), + ('2019-03-15', '2021-03-14'), -- expirée (historique) + ('2023-09-01', '2026-09-30'); + +-- ------------------------------------------------------- +-- 35. StaffHistoryOfApprovals +-- ------------------------------------------------------- +INSERT INTO StaffHistoryOfApprovals (StaffId, HistoryOfApprovalId) +VALUES (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (3, 1); +-- Nicolas a eu une précédente approbation + +-- ------------------------------------------------------- +-- 36. Availabilities +-- ------------------------------------------------------- +INSERT INTO Availabilities (AvailabilityDate, DeliveryDate, ExpirationDate, RenewallDate) +VALUES ('2024-07-14', '2024-07-14', '2024-07-15', '2025-07-14'), + ('2024-07-14', '2024-07-14', '2024-07-15', '2025-07-14'), + ('2024-08-15', '2024-08-15', '2024-08-16', '2025-08-15'), + ('2024-08-15', '2024-08-15', '2024-08-16', '2025-08-15'), + ('2024-09-21', '2024-09-21', '2024-09-22', '2025-09-21'), + ('2024-12-31', '2024-12-31', '2025-01-01', '2025-12-31'), + ('2024-07-04', '2024-07-04', '2024-07-05', '2025-07-04'), + ('2024-06-21', '2024-06-21', '2024-06-22', '2025-06-21'); + +-- ------------------------------------------------------- +-- 37. StaffAvailabilities +-- ------------------------------------------------------- +INSERT INTO StaffAvailabilities (StaffId, AvailabilityId) +VALUES (1, 1), + (2, 1), + (5, 1), + (8, 1), -- Paris 14 juillet + (1, 3), + (3, 3), + (6, 3), + (7, 3), -- Marseille 15 août + (2, 5), + (4, 5), + (9, 5), -- Bordeaux + (1, 6), + (2, 6), + (5, 6), + (10, 6), -- Nouvel an + (3, 7), + (6, 7), + (8, 7), -- 4 juillet Lyon + (4, 8), + (7, 8), + (9, 8); +-- Fête musique + +-- ------------------------------------------------------- +-- 38. StaffContacts +-- ------------------------------------------------------- +INSERT INTO StaffContacts (StaffId, ContactId) +VALUES (1, 1), + (1, 2), + (2, 4), + (5, 6), + (6, 3), + (8, 5), + (10, 8); + +-- ------------------------------------------------------- +-- 39. Trucks +-- ------------------------------------------------------- +INSERT INTO Trucks (Type, MaxExplosiveCapacity, Sizes, Status) +VALUES ('Fourgon 20m³', 500.0, '5.5m x 2.2m x 2.5m', 'Disponible'), + ('Semi-remorque ADR 82m³', 3000.0, '13.6m x 2.4m x 2.8m', 'Disponible'), + ('Camion 40m³ frigorifié', 1000.0, '7.2m x 2.4m x 2.6m', 'En maintenance'), + ('Fourgon 15m³', 300.0, '4.2m x 2.0m x 2.2m', 'Disponible'), + ('Pick-up plateau', 80.0, '2.0m x 1.8m x 0.5m', 'Disponible'); + +-- ------------------------------------------------------- +-- 40. SoundCategories +-- ------------------------------------------------------- +INSERT INTO SoundCategories (Name) +VALUES ('Ouverture / Intro'), + ('Corps de spectacle'), + ('Bouquet final'), + ('Transition'), + ('Ambiance'); + +-- ------------------------------------------------------- +-- 41. Sounds +-- ------------------------------------------------------- +INSERT INTO Sounds (Name, Type, Artist, Duration, Kind, Format, CreationDate, SoundCategoryId) +VALUES ('1812 Ouverture', 'Classique', 'Tchaïkovski', 900, 'Musique', 'WAV 48kHz 24bit', '2023-05-10', 1), + ('La Marseillaise Orchestrale', 'Hymne', 'Berlioz arr.', 210, 'Musique', 'WAV 48kHz 24bit', '2023-05-10', 1), + ('Also Sprach Zarathustra', 'Classique', 'Richard Strauss', 480, 'Musique', 'WAV 48kHz 24bit', '2023-06-01', 1), + ('Fanfare Spectacle 01', 'Fanfare', 'Studio Pyro', 60, 'Jingle', 'WAV 44.1kHz', '2024-01-15', 4), + ('Symphonie Feu & Lumière', 'Orchestral', 'Studio Pyro', 1200, 'Musique', 'WAV 48kHz 24bit', '2024-02-20', 2), + ('Rock the Fireworks', 'Rock', 'PyroRock Band', 780, 'Musique', 'MP3 320kbps', '2023-09-05', 2), + ('Electronic Fire Mix', 'Électronique', 'DJ Pyro', 960, 'Mix', 'WAV 44.1kHz', '2023-11-15', 2), + ('Finale Épique', 'Orchestral', 'Studio Pyro', 180, 'Musique', 'WAV 48kHz 24bit', '2024-01-15', 3), + ('Grand Finale 2024', 'Orchestral', 'Philharmonique Pyro', 240, 'Musique', 'WAV 48kHz 24bit', '2024-03-01', 3), + ('Ambiance Nocturne', 'Ambient', 'Sound Design Studio', 600, 'Musique', 'WAV 44.1kHz', '2023-07-20', 5); + +-- ------------------------------------------------------- +-- 42. Shows +-- ------------------------------------------------------- +INSERT INTO Shows (Name, Place, Description, Date, PyrotechnicImplementationPlan, CityId) +VALUES ('Feux du 14 Juillet Paris 2024', 'Trocadéro – Tour Eiffel', 'Grand spectacle national – 30 minutes – 120 000 spectateurs', '2024-07-14', + 'plans/paris_14juillet_2024_v3.pdf', 1), + ('Festival Lumières Lyon 2024', 'Place Bellecour', 'Spectacle estival – 20 minutes – 50 000 spectateurs', '2024-08-03', 'plans/lyon_festival_2024_v2.pdf', 2), + ('Fête Nationale Marseille 2024', 'Vieux-Port', 'Show nautique et aérien – 25 minutes', '2024-07-14', 'plans/marseille_14juillet_2024_v1.pdf', 3), + ('Gala Entreprise Paris 2024', 'Château de Versailles', 'Show privé soirée de gala – 15 minutes', '2024-09-21', 'plans/versailles_gala_2024_v2.pdf', 1), + ('Saint-Sylvestre Bordeaux 2024', 'Place de la Bourse', 'Feux du nouvel an – 20 minutes', '2024-12-31', 'plans/bordeaux_sylvestre_2024_v1.pdf', 4), + ('Fête de la Musique Nantes 2024', 'Île de Nantes', 'Show pyrotechnique de clôture – 10 minutes', '2024-06-21', 'plans/nantes_musique_2024_v1.pdf', 6), + ('Inauguration Parc Strasbourg 2025', 'Parc de l Orangerie', 'Feux d\inauguration – 12 minutes', '2025-04-15', 'plans/strasbourg_inaug_2025_v1.pdf', 5), + ('Feux Casino Nice 2024', 'Promenade des Anglais', 'Show prestige casino – 18 minutes', '2024-11-01', 'plans/nice_casino_2024_v2.pdf', 9); + +-- ------------------------------------------------------- +-- 43. ShowStaffs +-- ------------------------------------------------------- +INSERT INTO ShowStaffs (StaffId, ShowId) +VALUES (1, 1), + (2, 1), + (5, 1), + (8, 1), + (7, 1), + (1, 2), + (3, 2), + (6, 2), + (10, 2), + (2, 3), + (4, 3), + (6, 3), + (8, 3), + (1, 4), + (5, 4), + (7, 4), + (2, 5), + (3, 5), + (9, 5), + (10, 5), + (4, 6), + (7, 6), + (9, 6), + (1, 7), + (6, 7), + (8, 7), + (2, 8), + (5, 8), + (7, 8); + +-- ------------------------------------------------------- +-- 44. ShowTrucks +-- ------------------------------------------------------- +INSERT INTO ShowTrucks (ShowId, TruckId) +VALUES (1, 2), + (1, 4), + (2, 1), + (2, 4), + (3, 2), + (3, 5), + (4, 1), + (5, 2), + (5, 4), + (6, 4), + (6, 5), + (7, 1), + (8, 2); + +-- ------------------------------------------------------- +-- 45. ShowMaterials +-- ------------------------------------------------------- +INSERT INTO ShowMaterials (ShowId, MaterialId) +VALUES (1, 1), + (1, 2), + (1, 3), + (1, 6), + (1, 9), + (1, 10), + (1, 12), + (2, 1), + (2, 2), + (2, 4), + (2, 6), + (2, 8), + (2, 12), + (3, 1), + (3, 2), + (3, 5), + (3, 6), + (3, 9), + (4, 1), + (4, 2), + (4, 6), + (4, 7), + (4, 11), + (5, 1), + (5, 2), + (5, 3), + (5, 6), + (5, 9), + (6, 1), + (6, 4), + (6, 6), + (6, 8), + (7, 1), + (7, 2), + (7, 6), + (7, 7), + (8, 1), + (8, 2), + (8, 6), + (8, 10); + +-- ------------------------------------------------------- +-- 46. Contracts (Show x ServiceProvider) +-- ------------------------------------------------------- +INSERT INTO Contracts (ShowId, ServiceProviderId, TermsAndConditions) +VALUES (1, 1, 'Prestation sono 4h – montage J-1 inclus – démo technique 13/07'), + (1, 4, 'Sécurité périmètre – 25 agents – 12h de présence'), + (2, 2, 'Sono scène + diffusion – installation J-1'), + (2, 3, 'Éclairage scénique 200 projecteurs LED'), + (3, 5, 'Sécurité renforcée port – zone pyro – 40 agents'), + (4, 1, 'Sono de prestige – régie son Versailles'), + (4, 3, 'Éclairage château – mapping vidéo inclus'), + (5, 2, 'Sono place de la Bourse – diffusion périmètre'), + (6, 7, 'Location groupe électrogène 100kVA'), + (7, 6, 'Transport matériel Strasbourg – 2 rotations'), + (8, 1, 'Sono promenade – diffusion linéaire'), + (8, 8, 'Équipe médicale de permanence – 4h'); + +-- ------------------------------------------------------- +-- 47. SoundTimecodes (Show x Sound) +-- ------------------------------------------------------- +INSERT INTO SoundTimecodes (ShowId, SoundId, Start, [ End]) +VALUES (1, 1, 0.0, 900.0), + (1, 5, 900.0, 2100.0), + (1, 9, 2100.0, 2340.0), + (2, 3, 0.0, 480.0), + (2, 7, 480.0, 1440.0), + (2, 8, 1440.0, 1620.0), + (3, 2, 0.0, 210.0), + (3, 6, 210.0, 990.0), + (3, 9, 990.0, 1230.0), + (4, 10, 0.0, 600.0), + (4, 5, 600.0, 1500.0), + (4, 8, 1500.0, 1680.0), + (5, 7, 0.0, 960.0), + (5, 9, 960.0, 1200.0), + (8, 10, 0.0, 600.0), + (8, 5, 600.0, 1320.0), + (8, 9, 1320.0, 1560.0); + +-- ------------------------------------------------------- +-- 48. ProductTimecodes (Product x Show) +-- ------------------------------------------------------- +INSERT INTO ProductTimecodes (ProductId, ShowId, Start, [ End]) +VALUES +-- Paris 14 juillet +(3, 1, 0.0, 60.0), +(7, 1, 30.0, 300.0), +(2, 1, 300.0, 600.0), +(1, 1, 600.0, 1200.0), +(8, 1, 1200.0, 1800.0), +(4, 1, 1800.0, 2100.0), +(5, 1, 2100.0, 2200.0), +(6, 1, 2200.0, 2340.0), +-- Lyon festival +(7, 2, 0.0, 240.0), +(2, 2, 240.0, 600.0), +(1, 2, 600.0, 1000.0), +(9, 2, 1000.0, 1200.0), +-- Marseille +(3, 3, 0.0, 90.0), +(7, 3, 60.0, 360.0), +(4, 3, 360.0, 900.0), +(6, 3, 900.0, 1230.0), +-- Gala Versailles +(10, 4, 0.0, 60.0), +(2, 4, 60.0, 300.0), +(1, 4, 300.0, 700.0), +(6, 4, 700.0, 900.0), +-- Bordeaux Sylvestre +(7, 5, 0.0, 300.0), +(1, 5, 300.0, 900.0), +(5, 5, 900.0, 1000.0), +(6, 5, 1000.0, 1200.0); + +-- ------------------------------------------------------- +-- 49. Users +-- ------------------------------------------------------- +INSERT INTO Users (Name, Password, Salt, Email, Fonction) +VALUES ('admin', '$2a$12$hashed_password_admin', 'salt_admin_abc123', 'admin@pyrofetes.fr', 'Administrateur système'), + ('jean.dupuis', '$2a$12$hashed_password_jd', 'salt_jd_xyz789', 'j.dupuis@pyrofetes.fr', 'Directeur commercial'), + ('sophie.martin', '$2a$12$hashed_password_sm', 'salt_sm_qrs456', 's.martin@pyrofetes.fr', 'Responsable production'), + ('marc.leroy', '$2a$12$hashed_password_ml', 'salt_ml_tuv321', 'm.leroy@pyrofetes.fr', 'Gestionnaire stock'), + ('alice.henry', '$2a$12$hashed_password_ah', 'salt_ah_wxy654', 'a.henry@pyrofetes.fr', 'Chargée de projets'); \ No newline at end of file diff --git a/PyroFetes/wwwroot/default.txt b/PyroFetes/wwwroot/default.txt new file mode 100644 index 0000000..e69de29