diff --git a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs index c2ee0d9d..b486e161 100644 --- a/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs +++ b/PyroFetes/DTO/DeliveryNote/Request/CreateDeliveryNoteDto.cs @@ -5,8 +5,8 @@ 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 Dictionary? ProductQuantities { 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 26e52e75..c465649f 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 1eac8278..00000000 --- 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 32ae0923..6657f2fb 100644 --- a/PyroFetes/DTO/Price/Response/GetPriceDto.cs +++ b/PyroFetes/DTO/Price/Response/GetPriceDto.cs @@ -2,18 +2,8 @@ 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 string? SupplierZipCode { get; set; } - public string? SupplierCity { get; set; } - public int SupplierDeliveryDelay { get; set; } - public int ProductId { get; set; } public string? ProductReference { get; set; } public string? ProductName { get; set; } diff --git a/PyroFetes/DTO/Product/Request/CreateProductDto.cs b/PyroFetes/DTO/Product/Request/CreateProductDto.cs deleted file mode 100644 index ddc689c3..00000000 --- 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/ProductDelivery/Request/CreateProductDeliveryDto.cs b/PyroFetes/DTO/ProductDelivery/Request/CreateProductDeliveryDto.cs deleted file mode 100644 index d993ad35..00000000 --- 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 7a6bb71d..00000000 --- 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 9fdbe043..92c78cfc 100644 --- a/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs +++ b/PyroFetes/DTO/ProductDelivery/Response/GetProductDeliveryDto.cs @@ -14,15 +14,5 @@ public class GetProductDeliveryDto 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/Response/GetPurchaseOrderDto.cs b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs index 20dbe4e6..f2d626ac 100644 --- a/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs +++ b/PyroFetes/DTO/PurchaseOrder/Response/GetPurchaseOrderDto.cs @@ -6,5 +6,6 @@ public class GetPurchaseOrderDto { public int Id { get; set; } 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/PurchaseProduct/Request/CreatePurchaseProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs index 1249b419..f23dfb0b 100644 --- a/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs +++ b/PyroFetes/DTO/PurchaseProduct/Request/CreatePurchaseProductDto.cs @@ -5,5 +5,4 @@ public class CreatePurchaseProductDto 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/UpdatePurchaseProductDto.cs b/PyroFetes/DTO/PurchaseProduct/Request/UpdatePurchaseProductDto.cs deleted file mode 100644 index 8a718cbb..00000000 --- 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 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 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 cdfc15e6..e3233952 100644 --- a/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs +++ b/PyroFetes/DTO/PurchaseProduct/Response/GetPurchaseProductDto.cs @@ -3,7 +3,7 @@ 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 int ProductCaliber { get; set; } @@ -15,8 +15,5 @@ public class GetPurchaseProductDto 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/QuotationProduct/Request/CreateProductQuotationDto.cs b/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs index 51b0771a..43bcca75 100644 --- a/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs +++ b/PyroFetes/DTO/QuotationProduct/Request/CreateProductQuotationDto.cs @@ -1,6 +1,5 @@ namespace PyroFetes.DTO.QuotationProduct.Request; -// Pour création global public class CreateProductQuotationDto { public int ProductId { get; set; } diff --git a/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs index a4e1e5aa..c7abdcf4 100644 --- a/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs +++ b/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs @@ -1,22 +1,8 @@ namespace PyroFetes.DTO.QuotationProduct.Request; -public class CreateQuotationProductDto +public class AddQuotationProductDto { 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 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; } } \ 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 a726136f..00000000 --- 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 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; } -} \ No newline at end of file diff --git a/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs index 86643f91..087e844e 100644 --- a/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs +++ b/PyroFetes/DTO/QuotationProduct/Response/GetQuotationProductDto.cs @@ -4,12 +4,8 @@ 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 int ProductCaliber { get; set; } diff --git a/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs b/PyroFetes/DTO/SettingDTO/Request/CreateSettingDto.cs index 56146d3d..35abce90 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 44e567e1..22406281 100644 --- a/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs +++ b/PyroFetes/DTO/SettingDTO/Request/PatchSettingElectronicSignatureDto.cs @@ -3,5 +3,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 58a952e6..24963df8 100644 --- a/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs +++ b/PyroFetes/DTO/SettingDTO/Request/PatchSettingLogoDto.cs @@ -3,5 +3,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 2edbe935..bea9b70f 100644 --- a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -1,5 +1,4 @@ using PyroFetes.DTO.Price.Response; -using PyroFetes.DTO.Product.Response; namespace PyroFetes.DTO.Supplier.Response; @@ -13,6 +12,5 @@ public class GetSupplierDto public string? ZipCode { get; set; } public string? City { get; set; } public int DeliveryDelay { get; set; } - public List? Products { get; set; } public List? Prices { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs index 4eabfa5c..f5310452 100644 --- a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs @@ -6,9 +6,7 @@ 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() { @@ -18,13 +16,12 @@ public class CreateDelivererEndpoint( 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 a2981fe9..31ee0920 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}); + Delete("/deliverers/{@Id}", x => new { x.DelivererId }); AllowAnonymous(); - } 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 5710628f..b30d02fc 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; @@ -12,12 +10,10 @@ public class GetAllDelivererEndpoint(DeliverersRepository deliverersRepository) { Get("/deliverers"); AllowAnonymous(); - } 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 22a027f4..640d0c29 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}); + Get("/deliverers/{@Id}", x => new { x.DelivererId }); AllowAnonymous(); - } 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 ebf153ef..a9b38f52 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}); + Put("/deliverers/{@Id}", x => new { x.Id }); AllowAnonymous(); - } 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 63d3103f..3266034c 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs @@ -1,6 +1,5 @@ using FastEndpoints; using PyroFetes.DTO.DeliveryNote.Request; -using PyroFetes.DTO.DeliveryNote.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Deliverers; @@ -12,8 +11,7 @@ public class CreateDeliveryNoteEndpoint( DeliveryNotesRepository deliveryNotesRepository, DeliverersRepository deliverersRepository, ProductsRepository productsRepository, - ProductDeliveriesRepository productDeliveriesRepository, - AutoMapper.IMapper mapper) : Endpoint + ProductDeliveriesRepository productDeliveriesRepository) : Endpoint { public override void Configure() { @@ -23,46 +21,44 @@ public class CreateDeliveryNoteEndpoint( 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); + if (deliverer 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, + ExpeditionDate = req.ExpeditionDate, + DelivererId = deliverer.Id, Deliverer = deliverer, - }; - + 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 index 4fe76448..bc14d89e 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/DeleteDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/DeleteDeliveryNoteEndpoint.cs @@ -1,9 +1,7 @@ using FastEndpoints; -using PyroFetes.Endpoints.Quotations; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.DeliveryNotes; -using PyroFetes.Specifications.Quotations; namespace PyroFetes.Endpoints.DeliveryNotes; @@ -17,22 +15,21 @@ public class DeleteDeliveryNoteEndpoint( { public override void Configure() { - Delete("/deliveryNotes/{@Id}", x => new {x.Id}); + Delete("/deliveryNotes/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(DeleteDeliveryNoteRequest req, CancellationToken ct) { - DeliveryNote? deliveryNote = await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); + DeliveryNote? deliveryNote = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); - if (deliveryNote == null) + 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 7e126b83..56c19c63 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; @@ -14,7 +15,6 @@ public class GetAllDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRep 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/GetDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNoteEndpoint.cs index 90f33874..62597db6 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}); + Get("/deliveryNotes/{@Id}", x => new { x.DeliveryNoteId }); AllowAnonymous(); } 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 index 76bbbab8..19b47d1e 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNotePdfEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/GetDeliveryNotePdfEndpoint.cs @@ -5,39 +5,37 @@ using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Services.Pdf; using PyroFetes.Specifications.DeliveryNotes; -using PyroFetes.Specifications.Quotations; namespace PyroFetes.Endpoints.DeliveryNotes; -public class GetDeliveryNotePdfEndpoint( - DeliveryNotesRepository deliveryNotesRepository, - IDeliveryNotePdfService deliveryNotePdfService) - : Endpoint +public class GetDeliveryNotePdfEndpoint(DeliveryNotesRepository deliveryNotesRepository, IDeliveryNotePdfService deliveryNotePdfService, SettingsRepository settingsRepository) : Endpoint { public override void Configure() { - Get("/deliveryNotes/{@Id}/pdf", x => new {x.Id}); + Get("/deliveryNotes/{@Id}/pdf", x => new { x.Id }); AllowAnonymous(); Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); } - + public override async Task HandleAsync(GetDeliveryNotePdfDto req, CancellationToken ct) { DeliveryNote? deliveryNote = await deliveryNotesRepository - .FirstOrDefaultAsync(new GetDeliveryNoteByIdWithProductsSpec(req.Id), ct); + .SingleOrDefaultAsync(new GetDeliveryNoteByIdWithProductsSpec(req.Id), ct); - if (deliveryNote == null) + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); + + if (deliveryNote is null) { await Send.NotFoundAsync(ct); return; } - - var bytes = deliveryNotePdfService.Generate(deliveryNote, deliveryNote.ProductDeliveries!); + + byte[] bytes = deliveryNotePdfService.Generate(deliveryNote, deliveryNote.ProductDeliveries!, setting!); await Send.BytesAsync( bytes: bytes, contentType: "application/pdf", - fileName: $"bon-de-livraison-{deliveryNote.Id}.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 99c35c1e..a7100443 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/PatchRealDeliveryDateEndpoint.cs @@ -1,45 +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}); + Patch("/deliveryNotes/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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; } - - if (deliveryNoteToPath.RealDeliveryDate != null) + + if (deliveryNoteToPath.RealDeliveryDate is not null) { - await Send.StringAsync("Impossible de modifier la date.", 400); + await Send.StringAsync("Impossible de modifier la date.", 400, cancellation: ct); return; } - - deliveryNoteToPath.RealDeliveryDate = req.RealDeliveryDate; - + + 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 index 5d347cb8..6fccf9be 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/UpdateDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/UpdateDeliveryNoteEndpoint.cs @@ -1,40 +1,32 @@ using FastEndpoints; using PyroFetes.DTO.DeliveryNote.Request; -using PyroFetes.DTO.DeliveryNote.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.DeliveryNotes; namespace PyroFetes.Endpoints.DeliveryNotes; -public class UpdateDeliveryNoteEndpoint( - DeliveryNotesRepository deliveryNotesRepository, - AutoMapper.IMapper mapper) : Endpoint +public class UpdateDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRepository, AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Put("/deliveryNotes/{@Id}", x => new {x.Id}); + Put("/deliveryNotes/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(UpdateDeliveryNoteDto req, CancellationToken ct) { - DeliveryNote? deliveryNote = await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); - - if (deliveryNote == null) + DeliveryNote? deliveryNote = await deliveryNotesRepository.SingleOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id), ct); + + if (deliveryNote is null) { await Send.NotFoundAsync(ct); return; } - - deliveryNote.TrackingNumber = req.TrackingNumber; - deliveryNote.EstimateDeliveryDate = req.EstimateDeliveryDate; - deliveryNote.ExpeditionDate = req.ExpeditionDate; - deliveryNote.RealDeliveryDate = req.RealDeliveryDate; - deliveryNote.DelivererId = req.DelivererId; - - await deliveryNotesRepository.UpdateAsync(deliveryNote, ct); - - await Send.OkAsync(mapper.Map(deliveryNote), ct); + + 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 5445c0db..00000000 --- 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/Products/DeleteProductEndpoint.cs b/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs index 1e481636..a7720644 100644 --- a/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs +++ b/PyroFetes/Endpoints/Products/DeleteProductEndpoint.cs @@ -1,8 +1,6 @@ using FastEndpoints; -using PyroFetes.Endpoints.Deliverers; using PyroFetes.Models; using PyroFetes.Repositories; -using PyroFetes.Specifications.Deliverers; using PyroFetes.Specifications.Products; namespace PyroFetes.Endpoints.Products; @@ -11,28 +9,26 @@ 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}); + Delete("/products/{@Id}", x => new { x.ProductId }); AllowAnonymous(); - } public override async Task HandleAsync(DeleteProductsRequest req, CancellationToken ct) { - Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); + Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); - if (product == null) + if (product is null) { await Send.NotFoundAsync(ct); return; } - - await productsRepository.DeleteAsync(product, ct); + 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 6b4f2e07..e6c9343e 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; diff --git a/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs b/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs index 2057c35c..0b9768fb 100644 --- a/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs +++ b/PyroFetes/Endpoints/Products/GetAllProductsUnderLimitEndpoint.cs @@ -1,4 +1,3 @@ -using AutoMapper; using FastEndpoints; using PyroFetes.DTO.Product.Response; using PyroFetes.Repositories; @@ -15,7 +14,7 @@ public class GetAllProductsUnderLimitEndpoint(ProductsRepository productsReposit } 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 705f5d21..efe2a7bd 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,7 +17,7 @@ public class GetProductEndpoint( { public override void Configure() { - Get("/products/{@Id}", x => new {x.Id}); + Get("/products/{@Id}", x => new { x.Id }); AllowAnonymous(); } @@ -26,12 +25,12 @@ public class GetProductEndpoint( { 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 6d2cf8b0..40ebeba8 100644 --- a/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs +++ b/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs @@ -1,16 +1,12 @@ 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() { @@ -20,17 +16,17 @@ public class PatchProductMinimalStockEndpoint( 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 0b37aa9a..81fccdd6 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}); + Put("/products/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 00000000..9a02d203 --- /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 }); + AllowAnonymous(); + } + + 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 index b3ca8754..b30ec5d9 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs @@ -1,19 +1,18 @@ using FastEndpoints; using PyroFetes.DTO.PurchaseOrder.Request; -using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseProduct.Request; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Products; -using PyroFetes.Specifications.PurchaseOrders; +using PyroFetes.Specifications.PurchaseProducts; namespace PyroFetes.Endpoints.PurchaseOrders; public class CreatePurchaseOrder( PurchaseOrdersRepository purchaseOrdersRepository, ProductsRepository productsRepository, - AutoMapper.IMapper mapper) : Endpoint + PurchaseProductsRepository purchaseProductsRepository, + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { @@ -23,30 +22,35 @@ public class CreatePurchaseOrder( public override async Task HandleAsync(CreatePurchaseOrderDto req, CancellationToken ct) { - PurchaseOrder purchaseOrder = new PurchaseOrder - { - PurchaseConditions = req.PurchaseConditions ?? "Conditions non précisées", - PurchaseProducts = new List() - }; + PurchaseOrder purchaseOrder = mapper.Map(req); - foreach (var line in req.Products) + if (req.Products != null) { - var product = await productsRepository.GetByIdAsync(line.ProductId, ct); - if (product == null) + foreach (CreatePurchaseOrderProductDto line in req.Products) { - await Send.NotFoundAsync(ct); - return; + 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); + } + + PurchaseProduct? productOnPurchase = mapper.Map(line); + productOnPurchase.PurchaseOrderId = purchaseOrder.Id; + + await purchaseProductsRepository.AddAsync(productOnPurchase, ct); } - - purchaseOrder.PurchaseProducts.Add(new PurchaseProduct - { - ProductId = product.Id, - Quantity = line.Quantity, - }); } await purchaseOrdersRepository.AddAsync(purchaseOrder, ct); - - await Send.OkAsync(mapper.Map(purchaseOrder), ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs similarity index 51% rename from PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs rename to PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs index 7ce0dffb..8f6274e4 100644 --- a/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/DeleteProductFromPurchaseOrderEndpoint.cs @@ -1,10 +1,9 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.PurchaseProducts; -namespace PyroFetes.Endpoints.PurchaseProducts; +namespace PyroFetes.Endpoints.PurchaseOrders; public class DeletePurchaseProductRequest { @@ -12,27 +11,26 @@ public class DeletePurchaseProductRequest public int PurchaseOrderId { get; set; } } -public class DeletePurchaseProductEndpoint(PurchaseProductsRepository purchaseProductsRepository) : Endpoint +public class DeleteProductFromPurchaseOrderEndpoint(PurchaseProductsRepository purchaseProductsRepository) : Endpoint { public override void Configure() { - Delete("/purchaseProducts/{@ProductId}/{@PurchaseOrderId}", x => new {x.ProductId, x.PurchaseOrderId}); + Delete("/purchaseOrders/{@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); + PurchaseProduct? purchaseProduct = + await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct); - if (purchaseProduct == null) + 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 580efb65..b3f077c9 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,13 +10,11 @@ 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}); + Delete("/purchaseOrders/{@Id}", x => new { x.Id }); AllowAnonymous(); } @@ -25,19 +22,13 @@ public class DeletePurchaseOrderEndpoint( { 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 4bfd0123..8a3dd58e 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs @@ -1,7 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Response; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Repositories; namespace PyroFetes.Endpoints.PurchaseOrders; diff --git a/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs index 2b66aee6..c9d906c7 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}); + Get("/purchaseOrders/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 index a044b50c..05c1f86a 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderPdfEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderPdfEndpoint.cs @@ -5,37 +5,40 @@ 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) + IPurchaseOrderPdfService purchaseOrderPdfService, + SettingsRepository settingsRepository) : Endpoint { public override void Configure() { - Get("/purchaseOrders/{@Id}/pdf", x => new {x.Id}); + Get("/purchaseOrders/{@Id}/pdf", x => new { x.Id }); AllowAnonymous(); Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); } - + public override async Task HandleAsync(GetPurchaseOrderPdfDto req, CancellationToken ct) { - PurchaseOrder? purchaseOrder = await purchaseOrdersRepository - .FirstOrDefaultAsync(new GetPurchaseOrderByIdWithProductsSpec(req.Id), ct); - - if (purchaseOrder == null) + 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); - var bytes = purchaseOrderPdfService.Generate(purchaseOrder, purchaseOrder.PurchaseProducts!); + byte[] bytes = purchaseOrderPdfService.Generate(purchaseOrder, purchaseOrder.PurchaseProducts!, setting!); await Send.BytesAsync( bytes: bytes, contentType: "application/pdf", - fileName: $"bon-de-commande-{purchaseOrder.Id}.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 7b5c1f5f..0adbae4c 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs @@ -1,17 +1,14 @@ 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() { @@ -21,16 +18,16 @@ public class PatchPurchaseOrderPurchaseConditionsEndpoint( 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 00000000..1453e0a8 --- /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 }); + AllowAnonymous(); + } + + 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 24fe1f75..00000000 --- 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/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs deleted file mode 100644 index d1aad89d..00000000 --- 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 2c13b2e9..00000000 --- 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/Quotations/AddProductoToQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/AddProductoToQuotationEndpoint.cs new file mode 100644 index 00000000..9d71325b --- /dev/null +++ b/PyroFetes/Endpoints/Quotations/AddProductoToQuotationEndpoint.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 AddProductoToQuotationEndpoint( + QuotationProductsRepository quotationProductsRepository, + AutoMapper.IMapper mapper) : Endpoint +{ + public override void Configure() + { + Post("/quotations/{@Id}/products", x => new { x.ProductId, x.QuotationId }); + AllowAnonymous(); + } + + 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 index a7003c86..c8ba9553 100644 --- a/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs @@ -1,15 +1,19 @@ using FastEndpoints; using PyroFetes.DTO.Quotation.Request; using PyroFetes.DTO.Quotation.Response; +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 + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { @@ -19,32 +23,36 @@ public class CreateQuotationEndpoint( public override async Task HandleAsync(CreateQuotationDto req, CancellationToken ct) { - Quotation quotation = new Quotation - { - Message = req.Message, - ConditionsSale = req.ConditionsSale ?? "Conditions non précisées", - CustomerId = 1, // A changer - QuotationProducts = new List() - }; + Quotation quotation = mapper.Map(req); + quotation.CustomerId = 1; // TODO: A changer - foreach (var line in req.Products) + if (req.Products != null) { - var product = await productsRepository.GetByIdAsync(line.ProductId, ct); - if (product == null) + foreach (CreateProductQuotationDto line in req.Products) { - await Send.NotFoundAsync(ct); - return; + 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); + } + + QuotationProduct? productOnQuotation = mapper.Map(line); + productOnQuotation.QuotationId = quotation.Id; + + await quotationProductsRepository.AddAsync(productOnQuotation, ct); } - - quotation.QuotationProducts.Add(new QuotationProduct - { - ProductId = product.Id, - Quantity = line.Quantity, - }); } await quotationsRepository.AddAsync(quotation, ct); - - await Send.OkAsync(mapper.Map(quotation), 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 55% rename from PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs rename to PyroFetes/Endpoints/Quotations/DeleteProductFromQuotationEndpoint.cs index 554ccd4d..569694e2 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}); + Delete("/quotations/{@ProductId}/{@QuotationId}", x => new { x.ProductId, x.QuotationId }); AllowAnonymous(); } 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 80df36cf..737fa9e3 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,25 @@ 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}); + Delete("/quotations/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 b4674f30..9d7059d5 100644 --- a/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs @@ -1,8 +1,5 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Response; -using PyroFetes.DTO.QuotationProduct.Response; -using PyroFetes.Models; using PyroFetes.Repositories; namespace PyroFetes.Endpoints.Quotations; diff --git a/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs index bdc57c21..bc4b4fa7 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}); + Get("/quotations/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 index 29201727..0c754504 100644 --- a/PyroFetes/Endpoints/Quotations/GetQuotationPdfEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetQuotationPdfEndpoint.cs @@ -10,33 +10,35 @@ namespace PyroFetes.Endpoints.Quotations; public class GetQuotationPdfEndpoint( QuotationsRepository quotationRepository, - IQuotationPdfService quotationPdfService) + IQuotationPdfService quotationPdfService, + SettingsRepository settingsRepository) : Endpoint { public override void Configure() { - Get("/quotations/{@Id}/pdf", x => new {x.Id}); + Get("/quotations/{@Id}/pdf", x => new { x.Id }); AllowAnonymous(); Description(b => b.Produces(200, MediaTypeNames.Application.Pdf)); } - + public override async Task HandleAsync(GetQuotationPdfDto req, CancellationToken ct) { - Quotation? quotation = await quotationRepository - .FirstOrDefaultAsync(new GetQuotationByIdWithProductsSpec(req.Id), ct); + Quotation? quotation = await quotationRepository.SingleOrDefaultAsync(new GetQuotationByIdWithProductsSpec(req.Id), ct); - if (quotation == null) + if (quotation is null) { await Send.NotFoundAsync(ct); return; } + + Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct); - var bytes = quotationPdfService.Generate(quotation, quotation.QuotationProducts!); + byte[] bytes = quotationPdfService.Generate(quotation, quotation.QuotationProducts!, setting!); await Send.BytesAsync( bytes: bytes, contentType: "application/pdf", - fileName: $"devis-{quotation.Id}.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 e8287f16..c0a80a89 100644 --- a/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs @@ -9,7 +9,7 @@ namespace PyroFetes.Endpoints.Quotations; public class PatchQuotationConditionsSaleEndpoint( QuotationsRepository quotationsRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { @@ -19,18 +19,17 @@ public class PatchQuotationConditionsSaleEndpoint( 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); + mapper.Map(req, quotation); - await Send.OkAsync(mapper.Map(quotation), ct); + 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 00000000..8de48b48 --- /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 }); + AllowAnonymous(); + } + + 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/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs b/PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs similarity index 52% rename from PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs rename to PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs index de8546ef..ad036271 100644 --- a/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationProductQuantityEndpoint.cs @@ -1,37 +1,35 @@ 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; +namespace PyroFetes.Endpoints.Quotations; public class PatchQuotationProductQuantityEndpoint( QuotationProductsRepository quotationProductsRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { - Patch("/quotationProducts/{@ProductId}/{@QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId }); + Patch("/quotations/{@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 quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct); + if (quotationProduct is null) { await Send.NotFoundAsync(ct); return; } + + mapper.Map(req, quotationProduct); - quotationProduct.Quantity = req.Quantity; - await quotationProductsRepository.UpdateAsync(quotationProduct, ct); - - await Send.OkAsync(mapper.Map(quotationProduct), ct); + 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 index 3b1f47be..b383c719 100644 --- a/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs @@ -9,7 +9,7 @@ namespace PyroFetes.Endpoints.Quotations; public class UpdateQuotationEndpoint( QuotationsRepository quotationsRepository, - AutoMapper.IMapper mapper) : Endpoint + AutoMapper.IMapper mapper) : Endpoint { public override void Configure() { @@ -19,18 +19,17 @@ public class UpdateQuotationEndpoint( public override async Task HandleAsync(UpdateQuotationDto 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; } + + mapper.Map(req, quotation); - quotation.ConditionsSale = req.ConditionsSale; - quotation.Message = req.Message; - await quotationsRepository.UpdateAsync(quotation, ct); - - await Send.OkAsync(mapper.Map(quotation), ct); + await quotationsRepository.SaveChangesAsync(ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs index 893996b9..a1a12cae 100644 --- a/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs @@ -1,14 +1,11 @@ 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 class CreateSettingEndpoint(SettingsRepository settingsRepository) : Endpoint { public override void Configure() { @@ -18,14 +15,21 @@ public class CreateSettingEndpoint( public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct) { - Setting setting = new Setting() - { - ElectronicSignature = req.ElectronicSignature, - Logo = req.Logo - }; - - await settingsRepository.AddAsync(setting, ct); + // Encodage en base64 + using MemoryStream memoryStream = new(); + if (req.Logo != null) await req.Logo.CopyToAsync(memoryStream, ct); + byte[] logoBytes = memoryStream.ToArray(); - await Send.OkAsync(mapper.Map(setting), ct); + if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct); + byte[] signatureBytes = memoryStream.ToArray(); + + Setting setting = new() + { + ElectronicSignature = Convert.ToBase64String(signatureBytes), + Logo = Convert.ToBase64String(logoBytes) + }; + + await settingsRepository.AddAsync(setting, ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs index 2979b019..319acf93 100644 --- a/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/DeleteSettingEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Settings; @@ -15,22 +14,21 @@ public class DeleteSettingEndpoint(SettingsRepository settingsRepository) : Endp { public override void Configure() { - Delete("/settings/{@Id}", x => new {x.Id}); + 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); + Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - if (setting == null) + if (setting is 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 17350084..a36dcd93 100644 --- a/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs @@ -1,5 +1,4 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.Models; using PyroFetes.Repositories; @@ -18,15 +17,15 @@ public class GetSettingEndpoint( { public override void Configure() { - Get("/settings/{@Id}", x => new {x.Id}); + Get("/settings/{@Id}", x => new { x.Id }); AllowAnonymous(); } - + public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct) { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); + Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - if (setting == null) + if (setting is null) { await Send.NotFoundAsync(ct); return; diff --git a/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs index ca73c8c5..2aa7d4e1 100644 --- a/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.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 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}); + Patch("/settings/{@Id}/ElectronicSignature", x => new { x.Id }); AllowAnonymous(); } - + 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.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); + + if (setting is null) { await Send.NotFoundAsync(ct); return; } - setting.ElectronicSignature = req.ElectronicSignature; - await settingsRepository.UpdateAsync(setting, ct); - - await Send.OkAsync(mapper.Map(setting), ct); + // Encodage en base64 + using MemoryStream memoryStream = new(); + if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct); + byte[] signatureBytes = memoryStream.ToArray(); + + 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 f180cbc7..e35bb204 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}); + Patch("/settings/{@Id}/logo", x => new { x.Id }); AllowAnonymous(); } - + public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct) { - Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); + Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct); - if (setting == null) + if (setting is null) { await Send.NotFoundAsync(ct); return; } - setting.Logo = req.Logo; - await settingsRepository.UpdateAsync(setting, ct); + // Encodage en base64 + using MemoryStream memoryStream = new(); + if (req.Logo != null) await req.Logo.CopyToAsync(memoryStream, ct); + byte[] logoBytes = memoryStream.ToArray(); - await Send.OkAsync(mapper.Map(setting), ct); + 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 00000000..6a342526 --- /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 }); + AllowAnonymous(); + } + + 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 afd95f21..6a137e68 100644 --- a/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs @@ -1,14 +1,11 @@ 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() { @@ -18,19 +15,7 @@ public class CreateSupplierEndpoint( 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/Prices/DeletePriceEndpoint.cs b/PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs similarity index 51% rename from PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs index 6ff65772..8c2e5144 100644 --- a/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/DeleteProductToSupplierEndpoint.cs @@ -1,10 +1,9 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Prices; -namespace PyroFetes.Endpoints.Prices; +namespace PyroFetes.Endpoints.Suppliers; public class DeletePriceRequest { @@ -12,26 +11,25 @@ public class DeletePriceRequest public int SupplierId { get; set; } } -public class DeletePriceEndpoint(PricesRepository pricesRepository) : Endpoint +public class DeleteProductToSupplierEndpoint(PricesRepository pricesRepository) : Endpoint { public override void Configure() { - Delete("/prices/{@ProductId}/{@SupplierId}", x => new {x.ProductId, x.SupplierId}); + Delete("/suppliers/{@SupplierId}/{@Product}", x => new { x.SupplierId, x.ProductId }); AllowAnonymous(); } public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct) { - Price? price = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId,req.SupplierId), ct); + Price? price = await pricesRepository.SingleOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); - if (price == null) + if (price is null) { await Send.NotFoundAsync(ct); return; } - - await pricesRepository.DeleteAsync(price, ct); - + + 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 67860154..40f26556 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}); + Delete("/suppliers/{@Id}", x => new { x.Id }); AllowAnonymous(); } - + 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 3c655f8d..5a8bc289 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; diff --git a/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs index 50fbb54f..29ba25a8 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}); + Get("/suppliers/{@Id}", x => new { x.Id }); AllowAnonymous(); } - + 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 59% rename from PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/PatchPriceEndpoint.cs index 23cb247c..b6ab7ac4 100644 --- a/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/PatchPriceEndpoint.cs @@ -1,15 +1,14 @@ 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() { @@ -19,18 +18,17 @@ public class PatchPriceEndpoint( 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; } + + mapper.Map(req, price); - price.SellingPrice = req.SellingPrice; - - await pricesRepository.UpdateAsync(price, ct); - - await Send.OkAsync(mapper.Map(price), ct); + 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 0a832539..b058225f 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,27 @@ 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}); + Patch("/suppliers/{@Id}/deliveryDelay", x => new { x.Id }); AllowAnonymous(); } - + 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 79206ce2..d9f79f6d 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}); + Put("/suppliers/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 07e6eaaa..14314c0b 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 = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong"; + 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 73c557bd..a4f183a7 100644 --- a/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs @@ -8,9 +8,7 @@ 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() { @@ -20,17 +18,17 @@ public class CreateUserEndpoint( public override async Task HandleAsync(CreateUserDto req, CancellationToken ct) { - User? ckeckName = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct); - - if (ckeckName != null) + 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à.",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 user = new User() + + User user = new() { Name = req.Name, Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt), @@ -38,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 859d5486..32726e49 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}); + Delete("/users/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 6a36ca98..46b50037 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; diff --git a/PyroFetes/Endpoints/Users/GetUserEndpoint.cs b/PyroFetes/Endpoints/Users/GetUserEndpoint.cs index a03e04f6..c6b5d452 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; @@ -12,26 +11,24 @@ 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) : Endpoint { public override void Configure() { - Get("/users/{@Id}", x => new {x.Id}); + Get("/users/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(GetUserRequest 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 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 1647bd41..d56153d7 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,9 +7,7 @@ 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() { @@ -20,9 +17,9 @@ public class PatchUserPasswordEndpoint( 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 46eac236..ead9dbba 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}); + Put("/users/{@Id}", x => new { x.Id }); AllowAnonymous(); } 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 && ckeckName.Id != user.Id) + + 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/WareHouseProducts/GetTotalQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs index 01011189..f24ae3e6 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; @@ -20,21 +18,20 @@ public class GetTotalQuantityEndpoint( Get("/wareHouseProducts/{@ProductId}", x => new { x.ProductId }); AllowAnonymous(); } - + 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? totalQuantityNullable = await warehouseProductsRepository. - SumAsync(new GetProductTotalQuantitySpec(req.ProductId), wp => wp.Quantity, ct); - - int totalQuantity = totalQuantityNullable ?? 0; + + 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 93a4e07c..ff41e56c 100644 --- a/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs @@ -1,13 +1,13 @@ using FastEndpoints; -using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.WareHouseProduct.Request; using PyroFetes.DTO.WareHouseProduct.Response; using PyroFetes.Models; +using PyroFetes.Repositories; +using PyroFetes.Specifications.WarehouseProducts; namespace PyroFetes.Endpoints.WareHouseProducts; -public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) - : Endpoint +public class PatchWareHouseProductQuantityEndpoint(WarehouseProductsRepository warehouseProductsRepository) : Endpoint { public override void Configure() { @@ -17,25 +17,17 @@ public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) 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); + + if (wareHouseProduct is null) { await Send.NotFoundAsync(ct); return; } wareHouseProduct.Quantity = req.Quantity; - await database.SaveChangesAsync(ct); - - GetWareHouseProductDto responseDto = new() - { - ProductId = wareHouseProduct.ProductId, - WareHouseId = wareHouseProduct.WarehouseId, - Quantity = wareHouseProduct.Quantity - }; - await Send.OkAsync(responseDto, ct); + 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 132c1352..d79b9667 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,50 +20,65 @@ 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(); - CreateMap(); + 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(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.PurchaseOrderId, opt => opt.Ignore()); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.QuotationId, 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(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); - CreateMap(); + CreateMap() + .ForMember(dest => dest.ProductId, opt => opt.Ignore()) + .ForMember(dest => dest.WarehouseId, opt => opt.Ignore()); } } \ No newline at end of file diff --git a/PyroFetes/MappingProfiles/EntityToDtoMappings.cs b/PyroFetes/MappingProfiles/EntityToDtoMappings.cs index c74e6851..5604064b 100644 --- a/PyroFetes/MappingProfiles/EntityToDtoMappings.cs +++ b/PyroFetes/MappingProfiles/EntityToDtoMappings.cs @@ -24,46 +24,25 @@ public class EntityToDtoMappings : Profile 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() - .ForMember(dest => dest.Products, - opt => opt.MapFrom(src => src.PurchaseProducts)); - - CreateMap() - .ForMember(dest => dest.ProductId, opt => opt.MapFrom(src => src.ProductId)) - .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity)) - .ForMember(dest => dest.ProductName, opt => opt.MapFrom(src => src.Product.Name)) - .ForMember(dest => dest.ProductReferences, opt => opt.MapFrom(src => src.Product.Reference)) - .ForMember(dest => dest.ProductPrice, opt => opt.MapFrom(src => src.Product.Prices - .FirstOrDefault(p => p.SupplierId == src.PurchaseOrder!.SupplierId) - .SellingPrice)); - - // CreateMap(); - // - //CreateMap(); + .ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.PurchaseProducts)); + CreateMap(); CreateMap() - .ForMember(dest => dest.Products, - opt => opt.MapFrom(src => src.QuotationProducts)); + .ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.QuotationProducts)); - CreateMap() - .ForMember(dest => dest.ProductId, opt => opt.MapFrom(src => src.ProductId)) - .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity)) - .ForMember(dest => dest.ProductName, opt => opt.MapFrom(src => src.Product.Name)) - .ForMember(dest => dest.ProductReferences, opt => opt.MapFrom(src => src.Product.Reference)); + CreateMap(); CreateMap(); diff --git a/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs new file mode 100644 index 00000000..e644ca2b --- /dev/null +++ b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.Designer.cs @@ -0,0 +1,1983 @@ +// +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("20260524095820_ChangeDatabaseName")] + partial class ChangeDatabaseName + { + /// + 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") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Caliber") + .HasColumnType("int"); + + 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.Property("SupplierId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + 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") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + 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(60) + .HasColumnType("nvarchar(60)"); + + 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") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + 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.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") + .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/20260524095820_ChangeDatabaseName.cs b/PyroFetes/Migrations/20260524095820_ChangeDatabaseName.cs new file mode 100644 index 00000000..727fd050 --- /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/Program.cs b/PyroFetes/Program.cs index 83ef61b4..b0564138 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -80,7 +80,7 @@ app.UseAuthentication() }) .UseSwaggerGen(); -app.UseHttpsRedirection(); +// app.UseHttpsRedirection(); app.UseCors(); diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index 5aa90b1d..a492cc16 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -31,17 +31,9 @@ <_ContentIncludedByDefault Remove="wwwroot\Images\logo.jpg" /> - - - PreserveNewest - - - PreserveNewest - - - + diff --git a/PyroFetes/PyroFetesDbContext.cs b/PyroFetes/PyroFetesDbContext.cs index f8230eb8..7d8c9007 100644 --- a/PyroFetes/PyroFetesDbContext.cs +++ b/PyroFetes/PyroFetesDbContext.cs @@ -63,15 +63,13 @@ public class PyroFetesDbContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connectionString = - "Server=localhost,1433;" + - "Database=pyrofetes-db;" + - "User Id=sa;" + - "Password=AdminMotDePasse!;" + + "Server=romaric-thibault.fr;" + + "Database=PyroFetes-Sujet2;" + + "User Id=pyrofetes;" + + "Password=Crablike8-Fringe-Swimmable;" + "TrustServerCertificate=true;"; optionsBuilder.UseSqlServer(connectionString); - - } // Models customization diff --git a/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs b/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs index e084ec2c..eae9b7e6 100644 --- a/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs +++ b/PyroFetes/Services/Pdf/DeliveryNotePdfService.cs @@ -7,18 +7,18 @@ namespace PyroFetes.Services.Pdf; public interface IDeliveryNotePdfService { - byte[] Generate(DeliveryNote deliveryNote, List lignes); + byte[] Generate(DeliveryNote deliveryNote, List lignes, Setting setting); } public class DeliveryNotePdfService : IDeliveryNotePdfService { - public byte[] Generate(DeliveryNote deliveryNote, List lignes) + public byte[] Generate(DeliveryNote deliveryNote, List lignes, Setting setting) { - var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg"); - var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png"); + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); int total = 0; int totalQuantity = 0; - var document = Document.Create(container => + Document document = Document.Create(container => { container.Page(page => { @@ -48,7 +48,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService // Logo + société à droite row.ConstantItem(200).Column(col => { - col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea); + 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); @@ -93,7 +93,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService header.Cell().Element(CellHeader).AlignRight().Text("Total"); }); - foreach (var l in lignes) + foreach (ProductDelivery l in lignes) { table.Cell().Element(CellBody).Text(l.Product?.Name); table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString()); @@ -123,7 +123,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService // Signature en bas à droite page.Footer().AlignRight().Column(col => { - col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea); + col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); }); }); diff --git a/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs b/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs index 6861e8bc..c5ef60e2 100644 --- a/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs +++ b/PyroFetes/Services/Pdf/PurchaseOrderPdfService.cs @@ -7,18 +7,18 @@ namespace PyroFetes.Services.Pdf; public interface IPurchaseOrderPdfService { - byte[] Generate(PurchaseOrder purchaseOrder, List lignes); + byte[] Generate(PurchaseOrder purchaseOrder, List lignes, Setting setting); } public class PurchaseOrderPdfService : IPurchaseOrderPdfService { - public byte[] Generate(PurchaseOrder purchaseOrder, List lignes) + public byte[] Generate(PurchaseOrder purchaseOrder, List lignes, Setting setting) { - var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg"); - var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png"); + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); int totalQuantity = 0; decimal total = 0; - var document = Document.Create(container => + Document document = Document.Create(container => { container.Page(page => { @@ -42,7 +42,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService // Logo + société à droite row.ConstantItem(200).Column(col => { - col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea); + 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); @@ -90,7 +90,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService header.Cell().Element(CellHeader).AlignRight().Text("Total"); }); - foreach (var l in lignes) + foreach (PurchaseProduct l in lignes) { decimal price = l.Product!.Prices! .FirstOrDefault(p => p.SupplierId == l.PurchaseOrder!.SupplierId) @@ -140,7 +140,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService // Signature en bas à droite page.Footer().AlignRight().Column(col => { - col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea); + col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); }); }); diff --git a/PyroFetes/Services/Pdf/QuotationPdfService.cs b/PyroFetes/Services/Pdf/QuotationPdfService.cs index c5709e12..40e4b759 100644 --- a/PyroFetes/Services/Pdf/QuotationPdfService.cs +++ b/PyroFetes/Services/Pdf/QuotationPdfService.cs @@ -1,5 +1,4 @@ using PyroFetes.Models; -using QuestPDF.Companion; using QuestPDF.Fluent; using QuestPDF.Helpers; using QuestPDF.Infrastructure; @@ -8,17 +7,17 @@ namespace PyroFetes.Services.Pdf; public interface IQuotationPdfService { - byte[] Generate(Quotation quotation, List lignes); + byte[] Generate(Quotation quotation, List lignes, Setting setting); } public class QuotationPdfService : IQuotationPdfService { - public byte[] Generate(Quotation quotation, List lignes) + public byte[] Generate(Quotation quotation, List lignes, Setting setting) { - var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg"); - var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png"); + byte[] logo = Convert.FromBase64String(setting.Logo!); + byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!); int total = 0; - var document = Document.Create(container => + Document document = Document.Create(container => { container.Page(page => { @@ -42,7 +41,7 @@ public class QuotationPdfService : IQuotationPdfService // Logo + société à droite row.ConstantItem(200).Column(col => { - col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea); + 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); @@ -90,7 +89,7 @@ public class QuotationPdfService : IQuotationPdfService header.Cell().Element(CellHeader).AlignRight().Text("Total"); }); - foreach (var l in lignes) + foreach (QuotationProduct l in lignes) { table.Cell().Element(CellBody).Text(l.Product?.Name); table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString()); @@ -134,7 +133,7 @@ public class QuotationPdfService : IQuotationPdfService // Signature en bas à droite page.Footer().AlignRight().Column(col => { - col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea); + col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea); }); }); }); diff --git a/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs b/PyroFetes/Specifications/Deliverers/GetDelivererByIdSpec.cs index 63763819..8477c0cd 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 00000000..30ef09ab --- /dev/null +++ b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs @@ -0,0 +1,16 @@ +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) + .Where(x => true); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdSpec.cs index 2fc04947..e37a9046 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 index 5849019f..0eb3506b 100644 --- a/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdWithProductsSpec.cs +++ b/PyroFetes/Specifications/DeliveryNotes/GetDeliveryNoteByIdWithProductsSpec.cs @@ -3,13 +3,13 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.DeliveryNotes; -public class GetDeliveryNoteByIdWithProductsSpec : Specification +public class GetDeliveryNoteByIdWithProductsSpec : SingleResultSpecification { public GetDeliveryNoteByIdWithProductsSpec(int deliveryNoteId) { Query - .Where(d => d.Id == deliveryNoteId) - .Include(d => d.ProductDeliveries!) - .ThenInclude(dp => dp.Product); + .Where(x => x.Id == deliveryNoteId) + .Include(x => x.ProductDeliveries!) + .ThenInclude(p => p.Product); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs b/PyroFetes/Specifications/Prices/GetPriceByProductIdAndSupplierIdSpec.cs index 5f74c136..42a883bc 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 db1421f7..24fb16ff 100644 --- a/PyroFetes/Specifications/Products/GetProductByIdSpec.cs +++ b/PyroFetes/Specifications/Products/GetProductByIdSpec.cs @@ -3,9 +3,9 @@ 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) diff --git a/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs index 26c8d12f..23075f7c 100644 --- a/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs +++ b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs @@ -9,6 +9,6 @@ public sealed class GetProductsUnderLimitSpec : Specification { Query .Include(p => p.QuotationProducts) - .Where(p => p.QuotationProducts.Any(q => q.Quantity < p.MinimalQuantity)); + .Where(p => p.QuotationProducts != null && p.QuotationProducts.Any(q => q.Quantity < p.MinimalQuantity)); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdSpec.cs index 272ad75f..b9036860 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 index 7bac3f87..5b1ae68b 100644 --- a/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdWithProductsSpec.cs +++ b/PyroFetes/Specifications/PurchaseOrders/GetPurchaseOrderByIdWithProductsSpec.cs @@ -3,14 +3,14 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.PurchaseOrders; -public class GetPurchaseOrderByIdWithProductsSpec : Specification +public class GetPurchaseOrderByIdWithProductsSpec : SingleResultSpecification { public GetPurchaseOrderByIdWithProductsSpec(int purchaseOrderId) { Query - .Where(p => p.Id == purchaseOrderId) - .Include(p => p.PurchaseProducts!) - .ThenInclude(pp => pp.Product) - .ThenInclude(pp=> pp!.Prices); + .Where(x => x.Id == purchaseOrderId) + .Include(x => x.PurchaseProducts!) + .ThenInclude(p => p.Product) + .ThenInclude(p=> p!.Prices); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs b/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs index 5d35c62c..2d801b6d 100644 --- a/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs +++ b/PyroFetes/Specifications/PurchaseProducts/GetPurchaseProductByProductIdAndPurchaseOrderIdSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.PurchaseProducts; -public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : Specification +public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : SingleResultSpecification { public GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(int productId, int purchaseOrderId) { diff --git a/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs b/PyroFetes/Specifications/QuotationProducts/GetQuotationProductByProductIdAndQuotationIdSpec.cs index 9c3b65a4..f0fb5364 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/GetQuotationByIdSpec.cs b/PyroFetes/Specifications/Quotations/GetQuotationByIdSpec.cs index 5f1e1837..57cb7b75 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 index 3e8d7243..93d7472e 100644 --- a/PyroFetes/Specifications/Quotations/GetQuotationByIdWithProductsSpec.cs +++ b/PyroFetes/Specifications/Quotations/GetQuotationByIdWithProductsSpec.cs @@ -3,13 +3,13 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Quotations; -public class GetQuotationByIdWithProductsSpec : Specification +public class GetQuotationByIdWithProductsSpec : SingleResultSpecification { public GetQuotationByIdWithProductsSpec(int quotationId) { Query - .Where(q => q.Id == quotationId) - .Include(q => q.QuotationProducts!) - .ThenInclude(qp => qp.Product); + .Where(x => x.Id == quotationId) + .Include(x => x.QuotationProducts!) + .ThenInclude(p => p.Product); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs b/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs index cc786e40..fb919a8f 100644 --- a/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs +++ b/PyroFetes/Specifications/Settings/GetSettingByIdSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Settings; -public sealed class GetSettingByIdSpec : Specification +public sealed class GetSettingByIdSpec : SingleResultSpecification { public GetSettingByIdSpec(int settingId) { diff --git a/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs b/PyroFetes/Specifications/Suppliers/GetSupplierByIdSpec.cs index add16994..c649454b 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 db5c0be9..7cd8d7c2 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 daa75ad9..2affac1c 100644 --- a/PyroFetes/Specifications/Users/GetUserByNameSpec.cs +++ b/PyroFetes/Specifications/Users/GetUserByNameSpec.cs @@ -3,7 +3,7 @@ using PyroFetes.Models; namespace PyroFetes.Specifications.Users; -public sealed class GetUserByNameSpec : Specification +public sealed class GetUserByNameSpec : SingleResultSpecification { public GetUserByNameSpec(string userName) { diff --git a/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs b/PyroFetes/Specifications/WarehouseProducts/GetWarehouseProductByProductIdSpec.cs index ff135c13..416c01ac 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 index 6a0d4af5..876af84f 100644 --- a/PyroFetes/data.sql +++ b/PyroFetes/data.sql @@ -4,336 +4,386 @@ -- Ordre d'insertion respectant les contraintes FK -- ============================================================ --- ------------------------------------------------------- --- 1. Settings --- ------------------------------------------------------- -INSERT INTO Settings ( Logo, ElectronicSignature) VALUES - ( 'assets/logo_pyrofetes.png', 'assets/signature_direction.png'); - -- ------------------------------------------------------- -- 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); +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'); +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'); +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'); +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'); +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); +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, 1), - ( '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, 1), - ( '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); +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', 1), - ( 'GoldFlame', 1), - ( 'ArtificePlus', 2), - ( 'ArtificePlus', 3), - ( 'StarBurst', 4), - ( 'StarBurst', 5), - ( 'FestivalFire', 6), - ( 'TorchCo', 7), - ( 'GoldFlame', 8), - ( 'PyroMaster', 9), - ( 'ElecFire', 10), - ( 'PyroMaster', 11), - ( 'StarBurst', 12); +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 - (1, 1), (1, 3), (1, 6), -- Bouquet Tricolore : rouge, bleu, blanc - (2, 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 +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 - (1, 5), (1, 8), -- Bouquet : bouquet étoilé, peony - (2, 4), (2, 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 +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'); +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 - (1, 1, 120), (1, 2, 60), - (2, 1, 200), (2, 3, 80), - (3, 1, 150), (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); +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); +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); +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); +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); +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'); +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); +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); +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); +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); +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'); +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); +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'); +INSERT INTO CustomerTypes (Label) +VALUES ('Mairie / Collectivité'), + ('Association'), + ('Entreprise privée'), + ('Particulier'), + ('Organisateur d événements'); -- ------------------------------------------------------- -- 26. Customers @@ -344,272 +394,372 @@ INSERT INTO CustomerTypes ( Label) VALUES -- ------------------------------------------------------- - -- ------------------------------------------------------- -- 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); +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'); +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); +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'); +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 +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'); +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 +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); +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'); +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'); +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); +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); +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); +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); +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); +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'); +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); +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 +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), +(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), +(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), +(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), +(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), +(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 +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/docker-compose.yml b/PyroFetes/docker-compose.yml deleted file mode 100644 index b486e83f..00000000 --- a/PyroFetes/docker-compose.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: 'pyrofetes-api' - -services: - sqlserver: - image: mcr.microsoft.com/mssql/server:2022-latest - container_name: ${COMPOSE_PROJECT_NAME}-sqlserver - ports: - - 127.0.0.1:1433:1433 - volumes: - - type: volume - source: sqlserver-volume - target: /var/opt/mssql - environment: - ACCEPT_EULA: "Y" - MSSQL_SA_PASSWORD: ${SA_PASSWORD} - MSSQL_PID: "Developer" - healthcheck: - test: ["CMD", "/opt/mssql-tools18/bin/sqlcmd", "-S", "localhost", "-U", "sa", "-P", "${SA_PASSWORD}", "-Q", "SELECT 1", "-No"] - interval: 10s - timeout: 5s - retries: 10 - start_period: 30s - networks: - - network - -networks: - network: - name: ${COMPOSE_PROJECT_NAME}-network - driver: bridge - -volumes: - sqlserver-volume: - driver: local diff --git a/PyroFetes/wwwroot/Images/logo.jpg b/PyroFetes/wwwroot/Images/logo.jpg deleted file mode 100644 index e4594597..00000000 Binary files a/PyroFetes/wwwroot/Images/logo.jpg and /dev/null differ diff --git a/PyroFetes/wwwroot/Images/signature.png b/PyroFetes/wwwroot/Images/signature.png deleted file mode 100644 index c5d16683..00000000 Binary files a/PyroFetes/wwwroot/Images/signature.png and /dev/null differ