diff --git a/PyroFetes/DTO/Brand/Request/CreateBrandDto.cs b/PyroFetes/DTO/Brand/Request/CreateBrandDto.cs new file mode 100644 index 0000000..4d5e3f0 --- /dev/null +++ b/PyroFetes/DTO/Brand/Request/CreateBrandDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Brand.Request; + +public class CreateBrandDto +{ + public string? Name { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs b/PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs new file mode 100644 index 0000000..c111b09 --- /dev/null +++ b/PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Brand.Request; + +public class UpdateBrandDto +{ + public int Id { get; set; } + public string? Name { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Brand/Response/GetBrandDto.cs b/PyroFetes/DTO/Brand/Response/GetBrandDto.cs new file mode 100644 index 0000000..e57228f --- /dev/null +++ b/PyroFetes/DTO/Brand/Response/GetBrandDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Brand.Response; + +public class GetBrandDto +{ + public int Id { get; set; } + public string? Name { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Classification/Request/CreateClassificationDto.cs b/PyroFetes/DTO/Classification/Request/CreateClassificationDto.cs new file mode 100644 index 0000000..dfa6238 --- /dev/null +++ b/PyroFetes/DTO/Classification/Request/CreateClassificationDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Classification.Request; + +public class CreateClassificationDto +{ + public string? Label { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Classification/Request/UpdateClassificationDto.cs b/PyroFetes/DTO/Classification/Request/UpdateClassificationDto.cs new file mode 100644 index 0000000..2cc2b8d --- /dev/null +++ b/PyroFetes/DTO/Classification/Request/UpdateClassificationDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Classification.Request; + +public class UpdateClassificationDto +{ + public int Id { get; set; } + public string? Label { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Classification/Response/GetClassificationDto.cs b/PyroFetes/DTO/Classification/Response/GetClassificationDto.cs new file mode 100644 index 0000000..e7a1cae --- /dev/null +++ b/PyroFetes/DTO/Classification/Response/GetClassificationDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Classification.Response; + +public class GetClassificationDto +{ + public int Id { get; set; } + public string? Label { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Color/Request/CreateColorDto.cs b/PyroFetes/DTO/Color/Request/CreateColorDto.cs new file mode 100644 index 0000000..43b1851 --- /dev/null +++ b/PyroFetes/DTO/Color/Request/CreateColorDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Color.Request; + +public class CreateColorDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Color/Request/UpdateColorDto.cs b/PyroFetes/DTO/Color/Request/UpdateColorDto.cs new file mode 100644 index 0000000..3838a49 --- /dev/null +++ b/PyroFetes/DTO/Color/Request/UpdateColorDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Color.Request; + +public class UpdateColorDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Color/Response/GetColorDto.cs b/PyroFetes/DTO/Color/Response/GetColorDto.cs new file mode 100644 index 0000000..d53c0fc --- /dev/null +++ b/PyroFetes/DTO/Color/Response/GetColorDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Color.Response; + +public class GetColorDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Effect/Request/CreateEffectDto.cs b/PyroFetes/DTO/Effect/Request/CreateEffectDto.cs new file mode 100644 index 0000000..cb6f630 --- /dev/null +++ b/PyroFetes/DTO/Effect/Request/CreateEffectDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Effect.Request; + +public class CreateEffectDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs b/PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs new file mode 100644 index 0000000..004a0c5 --- /dev/null +++ b/PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Effect.Request; + +public class UpdateEffectDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Effect/Response/GetEffectDto.cs b/PyroFetes/DTO/Effect/Response/GetEffectDto.cs new file mode 100644 index 0000000..1708fc6 --- /dev/null +++ b/PyroFetes/DTO/Effect/Response/GetEffectDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Effect.Response; + +public class GetEffectDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Material/Request/CreateMaterialDto.cs b/PyroFetes/DTO/Material/Request/CreateMaterialDto.cs new file mode 100644 index 0000000..54fecd5 --- /dev/null +++ b/PyroFetes/DTO/Material/Request/CreateMaterialDto.cs @@ -0,0 +1,9 @@ +namespace PyroFetes.DTO.Material.Request; + +public class CreateMaterialDto +{ + public string? Label { get; set; } + public int Quantity { get; set; } + public int WarehouseId {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs b/PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs new file mode 100644 index 0000000..e462751 --- /dev/null +++ b/PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs @@ -0,0 +1,10 @@ +namespace PyroFetes.DTO.Material.Request; + +public class UpdateMaterialDto +{ + public int Id { get; set; } + public string? Label { get; set; } + public int Quantity { get; set; } + public int WarehouseId {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Material/Response/GetMaterialDto.cs b/PyroFetes/DTO/Material/Response/GetMaterialDto.cs new file mode 100644 index 0000000..bad4c77 --- /dev/null +++ b/PyroFetes/DTO/Material/Response/GetMaterialDto.cs @@ -0,0 +1,10 @@ +namespace PyroFetes.DTO.Material.Response; + +public class GetMaterialDto +{ + public int Id { get; set; } + public string? Label { get; set; } + public int Quantity { get; set; } + public int WarehouseId {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Movement/Request/CreateMovementDto.cs b/PyroFetes/DTO/Movement/Request/CreateMovementDto.cs new file mode 100644 index 0000000..043b1e0 --- /dev/null +++ b/PyroFetes/DTO/Movement/Request/CreateMovementDto.cs @@ -0,0 +1,10 @@ +namespace API.DTO.Movement.Request; + +public class CreateMovementDto +{ + public DateTime Date { get; set; } + public DateTime Start {get; set;} + public DateTime Arrival {get; set;} + public int Quantity {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs b/PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs new file mode 100644 index 0000000..f932ec9 --- /dev/null +++ b/PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs @@ -0,0 +1,11 @@ +namespace API.DTO.Movement.Request; + +public class UpdateMovementDto +{ + public int Id { get; set; } + public DateTime Date { get; set; } + public DateTime Start {get; set;} + public DateTime Arrival {get; set;} + public int Quantity {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Movement/Response/GetMovementDto.cs b/PyroFetes/DTO/Movement/Response/GetMovementDto.cs new file mode 100644 index 0000000..3d8f452 --- /dev/null +++ b/PyroFetes/DTO/Movement/Response/GetMovementDto.cs @@ -0,0 +1,11 @@ +namespace API.DTO.Movement.Response; + +public class GetMovementDto +{ + public int Id { get; set; } + public DateTime Date { get; set; } + public DateTime Start {get; set;} + public DateTime Arrival {get; set;} + public int Quantity {get; set;} + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Request/CreateProductDto.cs b/PyroFetes/DTO/Product/Request/CreateProductDto.cs new file mode 100644 index 0000000..a704c38 --- /dev/null +++ b/PyroFetes/DTO/Product/Request/CreateProductDto.cs @@ -0,0 +1,21 @@ +using PyroFetes.Models; + +namespace PyroFetes.DTO.Product.Request; + +public class CreateProductDto +{ + public int References { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice {get; set;} + public string? Image { get; set; } + public string? Link { get; set; } + + public int ClassificationId { get; set;} + public int ProductCategoryId { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs new file mode 100644 index 0000000..1bc96a4 --- /dev/null +++ b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs @@ -0,0 +1,20 @@ +using PyroFetes.Models; + +namespace PyroFetes.DTO.Product.Request; + +public class UpdateProductDto +{ + public int Id { get; set; } + public int Reference { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice {get; set;} + public string? Image { get; set; } + public string? Link { get; set; } + public int ClassificationId { get; set;} + public int ProductCategoryId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Response/GetProductDto.cs b/PyroFetes/DTO/Product/Response/GetProductDto.cs new file mode 100644 index 0000000..dbfed6a --- /dev/null +++ b/PyroFetes/DTO/Product/Response/GetProductDto.cs @@ -0,0 +1,23 @@ +using PyroFetes.Models; + +namespace PyroFetes.DTO.Product.Response; + +public class GetProductDto +{ + public int Id { get; set; } + public int Reference { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice {get; set;} + public string? Image { get; set; } + public string? Link { get; set; } + public int ClassificationId { get; set;} + public string? ClassificationLabel { get; set; } + public int ProductCategoryId { get; set; } + public string? ProductCategoryLabel { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductCategory/Request/CreateProductCategoryDto.cs b/PyroFetes/DTO/ProductCategory/Request/CreateProductCategoryDto.cs new file mode 100644 index 0000000..cf5ebe9 --- /dev/null +++ b/PyroFetes/DTO/ProductCategory/Request/CreateProductCategoryDto.cs @@ -0,0 +1,6 @@ +namespace API.DTO.ProductCategory.Request; + +public class CreateProductCategoryDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductCategory/Request/UpdateProductCategoryDto.cs b/PyroFetes/DTO/ProductCategory/Request/UpdateProductCategoryDto.cs new file mode 100644 index 0000000..2856e23 --- /dev/null +++ b/PyroFetes/DTO/ProductCategory/Request/UpdateProductCategoryDto.cs @@ -0,0 +1,7 @@ +namespace API.DTO.ProductCategory.Request; + +public class UpdateProductCategoryDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductCategory/Response/GetProductCategoryDto.cs b/PyroFetes/DTO/ProductCategory/Response/GetProductCategoryDto.cs new file mode 100644 index 0000000..ee64f0a --- /dev/null +++ b/PyroFetes/DTO/ProductCategory/Response/GetProductCategoryDto.cs @@ -0,0 +1,8 @@ +namespace API.DTO.ProductCategory.Response; + +public class GetProductCategoryDto +{ + public int Id { get; set; } + public string? Label { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs b/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs new file mode 100644 index 0000000..25a94a4 --- /dev/null +++ b/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs @@ -0,0 +1,11 @@ +namespace API.DTO.Supplier.Request; + +public class CreateSupplierDto +{ + public string Name { get; set; } + public string Email { get; set; } + public string PhoneNumber { get; set; } + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs b/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs new file mode 100644 index 0000000..20ae5f0 --- /dev/null +++ b/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs @@ -0,0 +1,12 @@ +namespace API.DTO.Supplier.Request; + +public class UpdateSupplierDto +{ + public int Id { get; set; } + public string Name { get; set; } + public string Email { get; set; } + public string PhoneNumber { get; set; } + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs new file mode 100644 index 0000000..ddc2365 --- /dev/null +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -0,0 +1,12 @@ +namespace API.DTO.Supplier.Response; + +public class GetSupplierDto +{ + public int Id { get; set; } + public string Name { get; set; } + public string Email { get; set; } + public string PhoneNumber { get; set; } + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs new file mode 100644 index 0000000..9f2e7cb --- /dev/null +++ b/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs @@ -0,0 +1,12 @@ +namespace API.DTO.Warehouse.Request; + +public class CreateWarehouseDto +{ + public string Name {get; set;} + public int MaxWeight {get; set;} + public int Current {get; set;} + public int MinWeight {get; set;} + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} diff --git a/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs new file mode 100644 index 0000000..a154737 --- /dev/null +++ b/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs @@ -0,0 +1,13 @@ +namespace API.DTO.Warehouse.Request; + +public class UpdateWarehouseDto +{ + public int Id {get; set;} + public string Name {get; set;} + public int MaxWeight {get; set;} + public int Current {get; set;} + public int MinWeight {get; set;} + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs new file mode 100644 index 0000000..77df53c --- /dev/null +++ b/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs @@ -0,0 +1,13 @@ +namespace API.DTO.Warehouse.Response; + +public class GetWarehouseDto +{ + public int Id {get; set;} + public string Name {get; set;} + public int MaxWeight {get; set;} + public int Current {get; set;} + public int MinWeight {get; set;} + public string Adress { get; set; } + public int ZipCode { get; set; } + public string City { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Brand/CreateBrandEndpoint.cs b/PyroFetes/Endpoints/Brand/CreateBrandEndpoint.cs new file mode 100644 index 0000000..265abc6 --- /dev/null +++ b/PyroFetes/Endpoints/Brand/CreateBrandEndpoint.cs @@ -0,0 +1,35 @@ +using PyroFetes.DTO.Brand.Request; +using PyroFetes.DTO.Brand.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Brand; + +public class CreateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/brands"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateBrandDto req, CancellationToken ct) + { + + Models.Brand brand = new () + { + Name = req.Name + }; + + pyrofetesdbcontext.Brands.Add(brand); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Marque créé avec succès !"); + + GetBrandDto responseDto = new () + { + Name = req.Name + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Brand/DeleteBrandEndpoint.cs b/PyroFetes/Endpoints/Brand/DeleteBrandEndpoint.cs new file mode 100644 index 0000000..eb4fa26 --- /dev/null +++ b/PyroFetes/Endpoints/Brand/DeleteBrandEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Brand; + +public class DeleteBrandRequest +{ + public int Id { get; set; } +} + +public class DeleteBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/brands/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteBrandRequest req, CancellationToken ct) + { + + Models.Brand? brandToDelete = await pyrofetesdbcontext + .Brands + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (brandToDelete == null) + { + Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.Brands.Remove(brandToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs b/PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs new file mode 100644 index 0000000..c4995ae --- /dev/null +++ b/PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs @@ -0,0 +1,28 @@ +using PyroFetes.DTO.Brand.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Brand; + +public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/brands"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + + List responseDto = await pyrofetesdbcontext.Brands + .Select(a => new GetBrandDto + { + Id = a.Id, + Name = a.Name, + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Brand/GetBrandEndpoint.cs b/PyroFetes/Endpoints/Brand/GetBrandEndpoint.cs new file mode 100644 index 0000000..86d7da9 --- /dev/null +++ b/PyroFetes/Endpoints/Brand/GetBrandEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Brand.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Brand; + +public class GetBrandRequest +{ + public int Id { get; set; } +} + +public class GetBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Get("/api/brands/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetBrandRequest req, CancellationToken ct) + { + + Models.Brand? brand = await pyrofetesdbcontext + .Brands + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (brand == null) + { + Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetBrandDto responseDto = new() + { + Id = req.Id, + Name = brand.Name + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs b/PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs new file mode 100644 index 0000000..652291c --- /dev/null +++ b/PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs @@ -0,0 +1,34 @@ +using PyroFetes.DTO.Brand.Request; +using PyroFetes.DTO.Brand.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Brand; + +public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/brands"); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateBrandDto req, CancellationToken ct) + { + + Models.Brand brand = new() + { + Name = req.Name + }; + pyrofetesdbcontext.Add(brand); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetBrandDto response = new() + { + Id = req.Id, + Name = req.Name + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Classification/CreateClassificationEndpoint.cs b/PyroFetes/Endpoints/Classification/CreateClassificationEndpoint.cs new file mode 100644 index 0000000..bc7ed9e --- /dev/null +++ b/PyroFetes/Endpoints/Classification/CreateClassificationEndpoint.cs @@ -0,0 +1,35 @@ +using PyroFetes.DTO.Classification.Request; +using PyroFetes.DTO.Classification.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Classification; + +public class CreateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/classifications"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateClassificationDto req, CancellationToken ct) + { + + Models.Classification classification = new () + { + Label = req.Label + }; + + pyrofetesdbcontext.Classifications.Add(classification); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Classification créée avec succès !"); + + GetClassificationDto responseDto = new () + { + Label = req.Label + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Classification/DeleteClassificationEndpoint.cs b/PyroFetes/Endpoints/Classification/DeleteClassificationEndpoint.cs new file mode 100644 index 0000000..0982278 --- /dev/null +++ b/PyroFetes/Endpoints/Classification/DeleteClassificationEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Classification; + +public class DeleteClassificationRequest +{ + public int Id { get; set; } +} + +public class DeleteClassificationEndpoint(PyroFetesDbContext libraryDbContext) : Endpoint +{ + public override void Configure() + { + Delete("/api/classifications/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteClassificationRequest req, CancellationToken ct) + { + + Models.Classification? classificationToDelete = await libraryDbContext + .Classifications + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (classificationToDelete == null) + { + Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + libraryDbContext.Classifications.Remove(classificationToDelete); + await libraryDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Classification/GetAllClassificationsEndpoint.cs b/PyroFetes/Endpoints/Classification/GetAllClassificationsEndpoint.cs new file mode 100644 index 0000000..7513e7e --- /dev/null +++ b/PyroFetes/Endpoints/Classification/GetAllClassificationsEndpoint.cs @@ -0,0 +1,28 @@ +using PyroFetes.DTO.Classification.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Classification; + +public class GetAllClassificationsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/classifications"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + + List responseDto = await pyrofetesdbcontext.Classifications + .Select(a => new GetClassificationDto + { + Id = a.Id, + Label = a.Label, + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Classification/GetClassificationEndpoint.cs b/PyroFetes/Endpoints/Classification/GetClassificationEndpoint.cs new file mode 100644 index 0000000..a972863 --- /dev/null +++ b/PyroFetes/Endpoints/Classification/GetClassificationEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Classification.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Classification; + +public class GetClassificationRequest +{ + public int Id { get; set; } +} + +public class GetClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Get("/api/classifications/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetClassificationRequest req, CancellationToken ct) + { + + Models.Classification? classification = await pyrofetesdbcontext + .Classifications + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (classification == null) + { + Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetClassificationDto responseDto = new() + { + Id = req.Id, + Label = classification.Label + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Classification/UpdateClassificationEndpoint.cs b/PyroFetes/Endpoints/Classification/UpdateClassificationEndpoint.cs new file mode 100644 index 0000000..cee10d3 --- /dev/null +++ b/PyroFetes/Endpoints/Classification/UpdateClassificationEndpoint.cs @@ -0,0 +1,34 @@ +using PyroFetes.DTO.Classification.Request; +using PyroFetes.DTO.Classification.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Classification; + +public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/classifications"); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateClassificationDto req, CancellationToken ct) + { + + Models.Classification classification = new() + { + Label = req.Label + }; + pyrofetesdbcontext.Add(classification); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetClassificationDto response = new() + { + Id = req.Id, + Label = req.Label + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Color/CreateColorEndpoint.cs b/PyroFetes/Endpoints/Color/CreateColorEndpoint.cs new file mode 100644 index 0000000..e926e52 --- /dev/null +++ b/PyroFetes/Endpoints/Color/CreateColorEndpoint.cs @@ -0,0 +1,35 @@ +using PyroFetes.DTO.Color.Request; +using PyroFetes.DTO.Color.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Color; + +public class CreateColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/color/create"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateColorDto req, CancellationToken ct) + { + Models.Color color = new() + { + Label = req.Label, + }; + + appDbContext.Colors.Add(color); + await appDbContext.SaveChangesAsync(ct); + Console.WriteLine("Added Color"); + + GetColorDto responseDto = new() + { + Id = color.Id, + Label = req.Label, + }; + + await Send.OkAsync(responseDto, ct); + } + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Color/DeleteColorEndpoint.cs b/PyroFetes/Endpoints/Color/DeleteColorEndpoint.cs new file mode 100644 index 0000000..7fa6e50 --- /dev/null +++ b/PyroFetes/Endpoints/Color/DeleteColorEndpoint.cs @@ -0,0 +1,37 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Color; + +public class DeleteColorRequest +{ + public int Id { get; set; } +} + +public class DeleteColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Delete("/api/colors/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct) + { + Models.Color? colorToDelete = await appDbContext + .Colors + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (colorToDelete == null) + { + Console.WriteLine($"Aucune couleur avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + appDbContext.Colors.Remove(colorToDelete); + await appDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Color/GetAllColorsEndpoint.cs b/PyroFetes/Endpoints/Color/GetAllColorsEndpoint.cs new file mode 100644 index 0000000..c5c4bee --- /dev/null +++ b/PyroFetes/Endpoints/Color/GetAllColorsEndpoint.cs @@ -0,0 +1,26 @@ +using PyroFetes.DTO.Color.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Color; + +public class GetAllColorsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/colors"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await appDbContext.Colors + .Select(a => new GetColorDto + { + Id = a.Id, + Label = a.Label, + } + ).ToListAsync(ct); + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Color/GetColorEndpoint.cs b/PyroFetes/Endpoints/Color/GetColorEndpoint.cs new file mode 100644 index 0000000..ad29958 --- /dev/null +++ b/PyroFetes/Endpoints/Color/GetColorEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Color.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Authentication; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Color; + +public class GetColorRequest +{ + public int Id { get; set; } +} + +public class GetColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Get("/api/colors/{@id}", x => new { x.Id}); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetColorRequest req, CancellationToken ct) + { + Models.Color? color = await appDbContext + .Colors + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (color == null) + { + Console.WriteLine($"Aucune couleur avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetColorDto responseDto = new() + { + Id = color.Id, + Label = color.Label, + }; + await Send.OkAsync(responseDto, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Color/UpdateColorEndpoint.cs b/PyroFetes/Endpoints/Color/UpdateColorEndpoint.cs new file mode 100644 index 0000000..43c9ee9 --- /dev/null +++ b/PyroFetes/Endpoints/Color/UpdateColorEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Color.Request; +using PyroFetes.DTO.Color.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Server.Kestrel; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Color; + +public class UpdateColorEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Put("/api/colors/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct) + { + Models.Color? colorToEdit = await appDbContext + .Colors + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (colorToEdit == null) + { + Console.WriteLine($"Aucune couleur avec l'id {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + + } + colorToEdit.Label = req.Label; + await appDbContext.SaveChangesAsync(ct); + + GetColorDto responseDto = new() + { + Id = req.Id, + Label = req.Label, + }; + await Send.OkAsync(responseDto, ct); + + } + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Effect/CreateEffectEndpoint.cs b/PyroFetes/Endpoints/Effect/CreateEffectEndpoint.cs new file mode 100644 index 0000000..1e6aafa --- /dev/null +++ b/PyroFetes/Endpoints/Effect/CreateEffectEndpoint.cs @@ -0,0 +1,34 @@ +using PyroFetes.DTO.Effect.Request; +using PyroFetes.DTO.Effect.Response; + +using FastEndpoints; +namespace PyroFetes.Endpoints.Effect; + +public class CreateEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/effect/create"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct) + { + Models.Effect effect = new() + { + Label = req.Label, + }; + + appDbContext.Effects.Add(effect); + await appDbContext.SaveChangesAsync(ct); + Console.WriteLine("Effect added"); + + GetEffectDto responseDto = new() + { + Id = effect.Id, + Label = req.Label, + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Effect/DeleteEffectEndpoint.cs b/PyroFetes/Endpoints/Effect/DeleteEffectEndpoint.cs new file mode 100644 index 0000000..fddb5fa --- /dev/null +++ b/PyroFetes/Endpoints/Effect/DeleteEffectEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Effect; + +public class DeleteEffectRequest +{ + public int Id { get; set; } +} +public class DeleteEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Delete("/api/effects/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct) + { + Models.Effect? effectToDelete = await appDbContext + .Effects + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (effectToDelete == null) + { + Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + appDbContext.Effects.Remove(effectToDelete); + await appDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs b/PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs new file mode 100644 index 0000000..8896fa1 --- /dev/null +++ b/PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs @@ -0,0 +1,27 @@ +using PyroFetes.DTO.Effect.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Effect; + +public class GetAllEffectsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/effects"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await appDbContext.Effects + .Select(a => new GetEffectDto + { + Id = a.Id, + Label = a.Label, + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Effect/GetEffectEndpoint.cs b/PyroFetes/Endpoints/Effect/GetEffectEndpoint.cs new file mode 100644 index 0000000..2465755 --- /dev/null +++ b/PyroFetes/Endpoints/Effect/GetEffectEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Effect.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Authentication; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Effect; + +public class GetEffectRequest +{ + public int Id { get; set; } +} + +public class GetEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Get("/api/effect/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct) + { + Models.Effect? effect = await appDbContext + .Effects + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (effect == null) + { + Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetEffectDto responseDto = new() + { + Id = effect.Id, + Label = effect.Label, + }; + await Send.OkAsync(responseDto, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Effect/UpdateEffectEndpoint.cs b/PyroFetes/Endpoints/Effect/UpdateEffectEndpoint.cs new file mode 100644 index 0000000..1ff9417 --- /dev/null +++ b/PyroFetes/Endpoints/Effect/UpdateEffectEndpoint.cs @@ -0,0 +1,42 @@ +using PyroFetes.DTO.Effect.Request; +using PyroFetes.DTO.Effect.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Server.Kestrel; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Effect; + +public class UpdateEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Put("/api/effect/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct) + { + Models.Effect? effectToEdit = await appDbContext + .Effects + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (effectToEdit == null) + { + Console.WriteLine($"Aucun effet avec l'id {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + + } + effectToEdit.Label = req.Label; + await appDbContext.SaveChangesAsync(ct); + + GetEffectDto responseDto = new() + { + Id = req.Id, + Label = req.Label, + }; + await Send.OkAsync(responseDto, ct); + + } + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Material/CreateMaterialEndpoint.cs b/PyroFetes/Endpoints/Material/CreateMaterialEndpoint.cs new file mode 100644 index 0000000..cdb8ab2 --- /dev/null +++ b/PyroFetes/Endpoints/Material/CreateMaterialEndpoint.cs @@ -0,0 +1,36 @@ +using PyroFetes.DTO.Material.Request; +using PyroFetes.DTO.Material.Response; +using FastEndpoints; +namespace PyroFetes.Endpoints.Material; + +public class CreateMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/material/create"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct) + { + Models.Material material = new() + { + Label = req.Label, + Quantity = req.Quantity, + WarehouseId = req.WarehouseId, + }; + + appDbContext.Materials.Add(material); + await appDbContext.SaveChangesAsync(ct); + Console.WriteLine("Material added"); + + GetMaterialDto responseDto = new() + { + Id = material.Id, + WarehouseId = material.WarehouseId, + Label = req.Label, + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Material/DeleteMaterialEndpoint.cs b/PyroFetes/Endpoints/Material/DeleteMaterialEndpoint.cs new file mode 100644 index 0000000..6912a26 --- /dev/null +++ b/PyroFetes/Endpoints/Material/DeleteMaterialEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Material; +public class DeleteMaterialRequest +{ + public int Id { get; set; } +} +public class DeleteMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Delete("/api/materials/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct) + { + Models.Material? materialToDelete = await appDbContext + .Materials + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (materialToDelete == null) + { + Console.WriteLine($"Aucun matériel avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + appDbContext.Materials.Remove(materialToDelete); + await appDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint.cs b/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint.cs new file mode 100644 index 0000000..a809711 --- /dev/null +++ b/PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint.cs @@ -0,0 +1,28 @@ +using PyroFetes.DTO.Material.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Material; + +public class GetAllMaterialsEndpoint(PyroFetesDbContext appDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/material"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await appDbContext.Materials + .Select(a => new GetMaterialDto + { + Id = a.Id, + Label = a.Label, + Quantity = a.Quantity, + WarehouseId = a.WarehouseId, + } + ).ToListAsync(ct); + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Material/GetMaterialEndpoint.cs b/PyroFetes/Endpoints/Material/GetMaterialEndpoint.cs new file mode 100644 index 0000000..7860ab8 --- /dev/null +++ b/PyroFetes/Endpoints/Material/GetMaterialEndpoint.cs @@ -0,0 +1,43 @@ +using PyroFetes.DTO.Material.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Authentication; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Material; + +public class GetMaterialRequest +{ + public int Id { get; set; } +} + +public class GetMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Get("/api/material/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct) + { + Models.Material? material = await appDbContext + .Materials + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (material == null) + { + Console.WriteLine("Aucun matériel avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetMaterialDto responseDto = new() + { + Id = material.Id, + Label = material.Label, + WarehouseId = material.WarehouseId, + }; + await Send.OkAsync(responseDto, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Material/UpdateMaterialEndpoint.cs b/PyroFetes/Endpoints/Material/UpdateMaterialEndpoint.cs new file mode 100644 index 0000000..c22a5b5 --- /dev/null +++ b/PyroFetes/Endpoints/Material/UpdateMaterialEndpoint.cs @@ -0,0 +1,43 @@ +using PyroFetes.DTO.Material.Request; +using PyroFetes.DTO.Material.Response; +using FastEndpoints; +using Microsoft.AspNetCore.Server.Kestrel; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Material; + +public class UpdateMaterialEndpoint(PyroFetesDbContext appDbContext) : Endpoint +{ + public override void Configure() + { + Put("/api/material/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct) + { + Models.Material? materialToEdit = await appDbContext + .Materials + .SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (materialToEdit == null) + { + Console.WriteLine($"Aucun matériel avec l'id {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + + } + materialToEdit.Label = req.Label; + materialToEdit.WarehouseId = req.WarehouseId; + await appDbContext.SaveChangesAsync(ct); + + GetMaterialDto responseDto = new() + { + Id = req.Id, + Label = req.Label, + WarehouseId = req.WarehouseId, + }; + await Send.OkAsync(responseDto, ct); + } + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Movement/CreateMovementEndpoint.cs b/PyroFetes/Endpoints/Movement/CreateMovementEndpoint.cs new file mode 100644 index 0000000..d8e838f --- /dev/null +++ b/PyroFetes/Endpoints/Movement/CreateMovementEndpoint.cs @@ -0,0 +1,41 @@ +using API.DTO.Movement.Request; +using API.DTO.Movement.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Movement; + +public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/movements"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateMovementDto req, CancellationToken ct) + { + + Models.Movement movement = new () + { + Date = req.Date, + Start = req.Start, + Arrival = req.Arrival, + Quantity = req.Quantity + }; + + pyrofetesdbcontext.Movements.Add(movement); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Movement créée avec succès !"); + + GetMovementDto responseDto = new () + { + Date = req.Date, + Start = req.Start, + Arrival = req.Arrival, + Quantity = req.Quantity + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Movement/DeleteMovementEndpoint.cs b/PyroFetes/Endpoints/Movement/DeleteMovementEndpoint.cs new file mode 100644 index 0000000..c49bd04 --- /dev/null +++ b/PyroFetes/Endpoints/Movement/DeleteMovementEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Movement; + +public class DeleteMovementRequest +{ + public int Id { get; set; } +} + +public class DeleteMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/Movements/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteMovementRequest req, CancellationToken ct) + { + + Models.Movement? movementToDelete = await pyrofetesdbcontext + .Movements + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (movementToDelete == null) + { + Console.WriteLine($"Aucune mouvement avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.Movements.Remove(movementToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs b/PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs new file mode 100644 index 0000000..da0d977 --- /dev/null +++ b/PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs @@ -0,0 +1,31 @@ +using API.DTO.Movement.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Movement; + +public class GetAllMovementsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/movements"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + + List responseDto = await pyrofetesdbcontext.Movements + .Select(a => new GetMovementDto + { + Id = a.Id, + Date = a.Date, + Start = a.Start, + Arrival = a.Arrival, + Quantity = a.Quantity + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Movement/GetMovementEndpoint.cs b/PyroFetes/Endpoints/Movement/GetMovementEndpoint.cs new file mode 100644 index 0000000..33e60ec --- /dev/null +++ b/PyroFetes/Endpoints/Movement/GetMovementEndpoint.cs @@ -0,0 +1,45 @@ +using API.DTO.Movement.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Movement; + +public class GetMovementRequest +{ + public int Id { get; set; } +} + +public class GetMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Get("/api/movements/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetMovementRequest req, CancellationToken ct) + { + + Models.Movement? movement = await pyrofetesdbcontext + .Movements + .SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); + + if (movement == null) + { + Console.WriteLine($"Aucun mouvement avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetMovementDto responseDto = new() + { + Id = req.Id, + Date = movement.Date, + Start = movement.Start, + Arrival = movement.Arrival, + Quantity = movement.Quantity + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Movement/UpdateMovementEndpoint.cs b/PyroFetes/Endpoints/Movement/UpdateMovementEndpoint.cs new file mode 100644 index 0000000..151ffc9 --- /dev/null +++ b/PyroFetes/Endpoints/Movement/UpdateMovementEndpoint.cs @@ -0,0 +1,40 @@ +using API.DTO.Movement.Request; +using API.DTO.Movement.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Movement; + +public class UpdateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/movements"); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateMovementDto req, CancellationToken ct) + { + + Models.Movement movement = new() + { + Date = req.Date, + Start = req.Start, + Arrival = req.Arrival, + Quantity = req.Quantity + }; + pyrofetesdbcontext.Add(movement); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetMovementDto response = new() + { + Id = req.Id, + Date = req.Date, + Start = req.Start, + Arrival = req.Arrival, + Quantity = req.Quantity + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs new file mode 100644 index 0000000..5a30b83 --- /dev/null +++ b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs @@ -0,0 +1,57 @@ +using FastEndpoints; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; + +namespace PyroFetes.Endpoints.Product; + +public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/products"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateProductDto req, CancellationToken ct) + { + Models.Product product = new () + { + References = req.References, + Name = req.Name!, + Duration = req.Duration, + Caliber = req.Caliber, + ApprovalNumber = req.ApprovalNumber, + Weight = req.Weight, + Nec = req.Nec, + SellingPrice = req.SellingPrice, + Image = req.Image!, + Link = req.Link!, + ProductCategoryId = req.ProductCategoryId, + ClassificationId = req.ClassificationId + }; + + pyrofetesdbcontext.Products.Add(product); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Product créé avec succès !"); + + GetProductDto responseDto = new () + { + Id = product.Id, + Reference = req.References, + Name = req.Name, + Duration = req.Duration, + Caliber = req.Caliber, + ApprovalNumber = req.ApprovalNumber, + Weight = req.Weight, + Nec = req.Nec, + SellingPrice = req.SellingPrice, + Image = req.Image, + Link = req.Link, + ProductCategoryId = req.ProductCategoryId, + ClassificationId = req.ClassificationId + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Product/DeleteProductEndpoint.cs b/PyroFetes/Endpoints/Product/DeleteProductEndpoint.cs new file mode 100644 index 0000000..cf425ea --- /dev/null +++ b/PyroFetes/Endpoints/Product/DeleteProductEndpoint.cs @@ -0,0 +1,37 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Product; + +public class DeleteProductRequest +{ + public int Id { get; set; } +} + +public class DeleteProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/products/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteProductRequest req, CancellationToken ct) + { + Models.Product? productToDelete = await pyrofetesdbcontext + .Products + .SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct); + + if (productToDelete == null) + { + Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.Products.Remove(productToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs new file mode 100644 index 0000000..ee81ef9 --- /dev/null +++ b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs @@ -0,0 +1,40 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Response; + +namespace PyroFetes.Endpoints.Product; + +public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/products"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await pyrofetesdbcontext.Products + .Select(p => new GetProductDto() + { + Id = p.Id, + Reference = p.References, + Name = p.Name, + Duration = p.Duration, + Caliber = p.Caliber, + ApprovalNumber = p.ApprovalNumber, + Weight = p.Weight, + Nec = p.Nec, + SellingPrice = p.SellingPrice, + Image = p.Image, + Link = p.Link, + ClassificationId = p.ClassificationId, + ClassificationLabel = p.Classification!.Label, + ProductCategoryId = p.ProductCategoryId, + ProductCategoryLabel = p.ProductCategory!.Label, + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} diff --git a/PyroFetes/Endpoints/Product/GetProductEndpoint.cs b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs new file mode 100644 index 0000000..df4b64f --- /dev/null +++ b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs @@ -0,0 +1,55 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Response; + +namespace PyroFetes.Endpoints.Product; + +public class GetProductRequest +{ + public int Id { get; set; } +} + + +public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Get("/api/product/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProductRequest req, CancellationToken ct) + { + Models.Product? product = await pyrofetesdbcontext + .Products.Include(product => product.Classification).Include(product => product.ProductCategory) + .SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct); + + if (product == null) + { + Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetProductDto responseDto = new() + { + Id = product.Id, + Reference = product.References, + Name = product.Name, + Duration = product.Duration, + Caliber = product.Caliber, + ApprovalNumber = product.ApprovalNumber, + Weight = product.Weight, + Nec = product.Nec, + SellingPrice = product.SellingPrice, + Image = product.Image, + Link = product.Link, + ClassificationId = product.ClassificationId, + ClassificationLabel = product.Classification!.Label, + ProductCategoryId = product.ProductCategoryId, + ProductCategoryLabel = product.ProductCategory!.Label, + }; + + await Send.OkAsync(responseDto, ct); + } +} diff --git a/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs new file mode 100644 index 0000000..2512e9c --- /dev/null +++ b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs @@ -0,0 +1,58 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; + +namespace PyroFetes.Endpoints.Product; + +public class UpdateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Put("/api/products/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct) + { + Models.Product? productToEdit = await pyrofetesdbcontext + .Products + .SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct); + + if (productToEdit == null) + { + Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + productToEdit.References = req.Reference; + productToEdit.Name = req.Name; + productToEdit.Duration = req.Duration; + productToEdit.Caliber = req.Caliber; + productToEdit.ApprovalNumber = req.ApprovalNumber; + productToEdit.Weight = req.Weight; + productToEdit.Nec = req.Nec; + productToEdit.SellingPrice = req.SellingPrice; + productToEdit.Image = req.Image; + productToEdit.Link = req.Link; + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetProductDto responseDto = new() + { + Id = req.Id, + Reference = req.Reference, + Name = req.Name, + Duration = req.Duration, + Caliber = req.Caliber, + ApprovalNumber = req.ApprovalNumber, + Weight = req.Weight, + Nec = req.Nec, + SellingPrice = req.SellingPrice, + Image = req.Image, + Link = req.Link + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProductCategory/CreateProductCategoryEndpoint.cs b/PyroFetes/Endpoints/ProductCategory/CreateProductCategoryEndpoint.cs new file mode 100644 index 0000000..b1009f9 --- /dev/null +++ b/PyroFetes/Endpoints/ProductCategory/CreateProductCategoryEndpoint.cs @@ -0,0 +1,37 @@ +using API.DTO.ProductCategory.Request; +using API.DTO.ProductCategory.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.ProductCategory; + +public class CreateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/productcategories"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateProductCategoryDto req, CancellationToken ct) + { + Models.ProductCategory productCategory = new () + { + Label = req.Label, + + }; + + pyrofetesdbcontext.ProductCategories.Add(productCategory); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Category créé avec succès !"); + + GetProductCategoryDto responseDto = new () + { + Id = productCategory.Id, + Label = productCategory.Label + + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProductCategory/DeleteProductCategoryEndpoint.cs b/PyroFetes/Endpoints/ProductCategory/DeleteProductCategoryEndpoint.cs new file mode 100644 index 0000000..9b00562 --- /dev/null +++ b/PyroFetes/Endpoints/ProductCategory/DeleteProductCategoryEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.ProductCategory; + +public class DeleteProductCategoryRequest +{ + public int Id { get; set; } +} + +public class DeleteProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/productcategories/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteProductCategoryRequest req, CancellationToken ct) + { + Models.ProductCategory? productCategoryToDelete = await pyrofetesdbcontext + .ProductCategories + .SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct); + + if (productCategoryToDelete == null) + { + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.ProductCategories.Remove(productCategoryToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProductCategory/GetAllProductCategoriesEndpoint.cs b/PyroFetes/Endpoints/ProductCategory/GetAllProductCategoriesEndpoint.cs new file mode 100644 index 0000000..d0039c6 --- /dev/null +++ b/PyroFetes/Endpoints/ProductCategory/GetAllProductCategoriesEndpoint.cs @@ -0,0 +1,27 @@ +using API.DTO.ProductCategory.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.ProductCategory; + +public class GetAllProductCategoriesEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/productcategories"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await pyrofetesdbcontext.ProductCategories + .Select(pc => new GetProductCategoryDto() + { + Id = pc.Id, + Label = pc.Label + } + ).ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} diff --git a/PyroFetes/Endpoints/ProductCategory/GetProductCategoryEndpoint.cs b/PyroFetes/Endpoints/ProductCategory/GetProductCategoryEndpoint.cs new file mode 100644 index 0000000..f2d823b --- /dev/null +++ b/PyroFetes/Endpoints/ProductCategory/GetProductCategoryEndpoint.cs @@ -0,0 +1,42 @@ +using API.DTO.ProductCategory.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.ProductCategory; + +public class GetProductCategoryRequest +{ + public int Id { get; set; } +} + + +public class GetProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Get("/api/productcategory/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProductCategoryRequest req, CancellationToken ct) + { + Models.ProductCategory? productCategory = await pyrofetesdbcontext + .ProductCategories + .SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct); + + if (productCategory == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetProductCategoryDto responseDto = new() + { + Id = productCategory.Id, + Label = productCategory.Label + + }; + + await Send.OkAsync(responseDto, ct); + } +} diff --git a/PyroFetes/Endpoints/ProductCategory/UpdateProductCategoryEndpoint.cs b/PyroFetes/Endpoints/ProductCategory/UpdateProductCategoryEndpoint.cs new file mode 100644 index 0000000..e5d7e21 --- /dev/null +++ b/PyroFetes/Endpoints/ProductCategory/UpdateProductCategoryEndpoint.cs @@ -0,0 +1,39 @@ +using API.DTO.ProductCategory.Request; +using API.DTO.ProductCategory.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.ProductCategory; + +public class UpdateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint +{ + public override void Configure() + { + Put("/api/productcategory/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateProductCategoryDto req, CancellationToken ct) + { + Models.ProductCategory? productCategoryToEdit = await pyrofetesdbcontext + .ProductCategories + .SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct); + + if (productCategoryToEdit == null) + { + await Send.NotFoundAsync(ct); + return; + } + + productCategoryToEdit.Label = req.Label; + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetProductCategoryDto responseDto = new() + { + Id = req.Id, + Label = req.Label, + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs b/PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs new file mode 100644 index 0000000..761eb4a --- /dev/null +++ b/PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs @@ -0,0 +1,48 @@ +using API.DTO.Supplier.Request; +using API.DTO.Supplier.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Supplier; + +public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/suppliers"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct) + { + // Création d'un nouvel objet Supplier + Models.Supplier supplier = new() + { + Name = req.Name, + Email = req.Email, + Phone = req.PhoneNumber, + Address = req.Adress, + ZipCode = req.ZipCode, + City = req.City + }; + + // Ajout à la base et sauvegarde + pyrofetesdbcontext.Suppliers.Add(supplier); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Fournisseur créé avec succès !"); + + // Préparation de la réponse + GetSupplierDto responseDto = new() + { + Id = supplier.Id, + Name = supplier.Name, + Email = supplier.Email, + PhoneNumber = supplier.Phone, + Adress = supplier.Address, + ZipCode = supplier.ZipCode, + City = supplier.City + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Supplier/DeleteSupplierEndpoint.cs b/PyroFetes/Endpoints/Supplier/DeleteSupplierEndpoint.cs new file mode 100644 index 0000000..dbeb8db --- /dev/null +++ b/PyroFetes/Endpoints/Supplier/DeleteSupplierEndpoint.cs @@ -0,0 +1,37 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Supplier; + +public class DeleteSupplierRequest +{ + public int Id { get; set; } +} + +public class DeleteSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/suppliers/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct) + { + Models.Supplier? supplierToDelete = await pyrofetesdbcontext + .Suppliers + .SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct); + + if (supplierToDelete == null) + { + Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.Suppliers.Remove(supplierToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs b/PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs new file mode 100644 index 0000000..51df593 --- /dev/null +++ b/PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs @@ -0,0 +1,32 @@ +using API.DTO.Supplier.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Supplier; + +public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/suppliers"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await pyrofetesdbcontext.Suppliers + .Select(s => new GetSupplierDto + { + Id = s.Id, + Name = s.Name!, + Email = s.Email!, + PhoneNumber = s.Phone!, + Adress = s.Address!, + ZipCode = s.ZipCode, + City = s.City! + }) + .ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs b/PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs new file mode 100644 index 0000000..878e8ba --- /dev/null +++ b/PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs @@ -0,0 +1,46 @@ +using API.DTO.Supplier.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Supplier; + +public class GetSupplierRequest +{ + public int Id { get; set; } +} + +public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Get("/api/suppliers/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct) + { + Models.Supplier? supplier = await pyrofetesdbcontext + .Suppliers + .SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct); + + if (supplier == null) + { + Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetSupplierDto responseDto = new() + { + Id = supplier.Id, + Name = supplier.Name!, + Email = supplier.Email!, + PhoneNumber = supplier.Phone!, + Adress = supplier.Address!, + ZipCode = supplier.ZipCode, + City = supplier.City! + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs b/PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs new file mode 100644 index 0000000..e835fce --- /dev/null +++ b/PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs @@ -0,0 +1,52 @@ +using API.DTO.Supplier.Request; +using API.DTO.Supplier.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Supplier; + +public class UpdateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Put("/api/suppliers/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct) + { + Models.Supplier? supplierToEdit = await pyrofetesdbcontext + .Suppliers + .SingleOrDefaultAsync(s => s.Id == req.Id, cancellationToken: ct); + + if (supplierToEdit == null) + { + Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + // Mise à jour des propriétés + supplierToEdit.Name = req.Name; + supplierToEdit.Email = req.Email; + supplierToEdit.Phone = req.PhoneNumber; + supplierToEdit.Address = req.Adress; + supplierToEdit.ZipCode = req.ZipCode; + supplierToEdit.City = req.City; + + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetSupplierDto responseDto = new() + { + Id = supplierToEdit.Id, + Name = supplierToEdit.Name, + Email = supplierToEdit.Email, + PhoneNumber = supplierToEdit.Phone, + Adress = supplierToEdit.Address, + ZipCode = supplierToEdit.ZipCode, + City = supplierToEdit.City + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Warehouse/CreateWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/CreateWarehouseEndpoint.cs new file mode 100644 index 0000000..2c46f85 --- /dev/null +++ b/PyroFetes/Endpoints/Warehouse/CreateWarehouseEndpoint.cs @@ -0,0 +1,47 @@ +using API.DTO.Warehouse.Request; +using API.DTO.Warehouse.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Warehouse; + +public class CreateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Post("/api/warehouse"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateWarehouseDto req, CancellationToken ct) + { + Models.Warehouse warehouse = new() + { + Name = req.Name, + MaxWeight = req.MaxWeight, + Current = req.Current, + MinWeight = req.MinWeight, + Address = req.Adress, + ZipCode = req.ZipCode, + City = req.City + }; + + pyrofetesdbcontext.Warehouses.Add(warehouse); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + Console.WriteLine("Entrepôt créé avec succès !"); + + GetWarehouseDto responseDto = new() + { + Id = warehouse.Id, + Name = warehouse.Name, + MaxWeight = warehouse.MaxWeight, + Current = warehouse.Current, + MinWeight = warehouse.MinWeight, + Adress = warehouse.Address, + ZipCode = warehouse.ZipCode, + City = warehouse.City + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs new file mode 100644 index 0000000..758096b --- /dev/null +++ b/PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs @@ -0,0 +1,37 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Warehouse; + +public class DeleteWarehouseRequest +{ + public int Id { get; set; } +} + +public class DeleteWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Delete("/api/warehouse/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(DeleteWarehouseRequest req, CancellationToken ct) + { + Models.Warehouse? warehouseToDelete = await pyrofetesdbcontext + .Warehouses + .SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct); + + if (warehouseToDelete == null) + { + Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + pyrofetesdbcontext.Warehouses.Remove(warehouseToDelete); + await pyrofetesdbcontext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs new file mode 100644 index 0000000..0d98e6f --- /dev/null +++ b/PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs @@ -0,0 +1,33 @@ +using API.DTO.Warehouse.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Warehouse; + +public class GetAllWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get("/api/warehouses"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List responseDto = await pyrofetesdbcontext.Warehouses + .Select(w => new GetWarehouseDto + { + Id = w.Id, + Name = w.Name, + MaxWeight = w.MaxWeight, + Current = w.Current, + MinWeight = w.MinWeight, + Adress = w.Address, + ZipCode = w.ZipCode, + City = w.City + }) + .ToListAsync(ct); + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs new file mode 100644 index 0000000..b24e007 --- /dev/null +++ b/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs @@ -0,0 +1,47 @@ +using API.DTO.Warehouse.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Warehouse; + +public class GetWarehouseRequest +{ + public int Id { get; set; } +} + +public class GetWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Get("/api/warehouses/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetWarehouseRequest req, CancellationToken ct) + { + Models.Warehouse? warehouse = await pyrofetesdbcontext + .Warehouses + .SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct); + + if (warehouse == null) + { + Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + GetWarehouseDto responseDto = new() + { + Id = warehouse.Id, + Name = warehouse.Name!, + MaxWeight = warehouse.MaxWeight, + Current = warehouse.Current, + MinWeight = warehouse.MinWeight, + Adress = warehouse.Address!, + ZipCode = warehouse.ZipCode, + City = warehouse.City! + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs new file mode 100644 index 0000000..0864bd6 --- /dev/null +++ b/PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs @@ -0,0 +1,54 @@ +using API.DTO.Warehouse.Request; +using API.DTO.Warehouse.Response; +using FastEndpoints; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Endpoints.Warehouse; + +public class UpdateWarehouseEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint +{ + public override void Configure() + { + Put("/api/warehouses/{@id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateWarehouseDto req, CancellationToken ct) + { + Models.Warehouse? warehouseToEdit = await pyrofetesdbcontext + .Warehouses + .SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct); + + if (warehouseToEdit == null) + { + Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé."); + await Send.NotFoundAsync(ct); + return; + } + + // Mise à jour des champs + warehouseToEdit.Name = req.Name; + warehouseToEdit.MaxWeight = req.MaxWeight; + warehouseToEdit.Current = req.Current; + warehouseToEdit.MinWeight = req.MinWeight; + warehouseToEdit.Address = req.Adress; + warehouseToEdit.ZipCode = req.ZipCode; + warehouseToEdit.City = req.City; + + await pyrofetesdbcontext.SaveChangesAsync(ct); + + GetWarehouseDto responseDto = new() + { + Id = warehouseToEdit.Id, + Name = warehouseToEdit.Name, + MaxWeight = warehouseToEdit.MaxWeight, + Current = warehouseToEdit.Current, + MinWeight = warehouseToEdit.MinWeight, + Adress = warehouseToEdit.Address, + ZipCode = warehouseToEdit.ZipCode, + City = warehouseToEdit.City + }; + + await Send.OkAsync(responseDto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs new file mode 100644 index 0000000..1f414fb --- /dev/null +++ b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs @@ -0,0 +1,1948 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PyroFetes; + +#nullable disable + +namespace PyroFetes.Migrations +{ + [DbContext(typeof(PyroFetesDbContext))] + partial class PyroFetesDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.20") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("PyroFetes.Models.Availability", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvailabilityDate") + .HasColumnType("date"); + + b.Property("DeliveryDate") + .HasColumnType("date"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.Property("RenewallDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.ToTable("Availabilities"); + }); + + modelBuilder.Entity("PyroFetes.Models.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("Brands"); + }); + + modelBuilder.Entity("PyroFetes.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("City"); + }); + + modelBuilder.Entity("PyroFetes.Models.Classification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Classifications"); + }); + + modelBuilder.Entity("PyroFetes.Models.Color", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Colors"); + }); + + modelBuilder.Entity("PyroFetes.Models.Communication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Calling") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ContactId") + .HasColumnType("int"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Meeting") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.HasKey("Id"); + + b.HasIndex("ContactId"); + + b.ToTable("Communications"); + }); + + modelBuilder.Entity("PyroFetes.Models.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CustomerId") + .HasColumnType("int"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PhoneNumber") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Role") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => + { + b.Property("ContactId") + .HasColumnType("int"); + + b.Property("ServiceProviderId") + .HasColumnType("int"); + + b.HasKey("ContactId", "ServiceProviderId"); + + b.HasIndex("ServiceProviderId"); + + b.ToTable("ContactServiceProvider"); + }); + + modelBuilder.Entity("PyroFetes.Models.Contract", b => + { + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("ServiceProviderId") + .HasColumnType("int"); + + b.Property("TermsAndConditions") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ShowId", "ServiceProviderId"); + + b.HasIndex("ServiceProviderId"); + + b.ToTable("Contract"); + }); + + modelBuilder.Entity("PyroFetes.Models.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerTypeId") + .HasColumnType("int"); + + b.Property("Note") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerTypeId"); + + b.ToTable("Customers"); + }); + + modelBuilder.Entity("PyroFetes.Models.CustomerType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("CustomerTypes"); + }); + + modelBuilder.Entity("PyroFetes.Models.Deliverer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Transporter") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Deliverers"); + }); + + modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DelivererId") + .HasColumnType("int"); + + b.Property("EstimateDeliveryDate") + .HasColumnType("date"); + + b.Property("ExpeditionDate") + .HasColumnType("date"); + + b.Property("RealDeliveryDate") + .HasColumnType("date"); + + b.Property("TrackingNumber") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("DelivererId"); + + b.ToTable("DeliveryNotes"); + }); + + modelBuilder.Entity("PyroFetes.Models.Effect", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("Effects"); + }); + + modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("StaffId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StaffId"); + + b.ToTable("ExperienceLevels"); + }); + + modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeliveryDate") + .HasColumnType("date"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.ToTable("HistoryOfApprovals"); + }); + + modelBuilder.Entity("PyroFetes.Models.Material", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("WarehouseId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WarehouseId"); + + b.ToTable("Materials"); + }); + + modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => + { + b.Property("MaterialId") + .HasColumnType("int"); + + b.Property("WarehouseId") + .HasColumnType("int"); + + b.HasKey("MaterialId", "WarehouseId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("MaterialWarehouse"); + }); + + modelBuilder.Entity("PyroFetes.Models.Movement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Arrival") + .HasColumnType("datetime2"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DestinationWarehouseId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SourceWarehouseId") + .HasColumnType("int"); + + b.Property("Start") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("DestinationWarehouseId"); + + b.HasIndex("SourceWarehouseId"); + + b.ToTable("Movements"); + }); + + modelBuilder.Entity("PyroFetes.Models.Price", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("SellingPrice") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ProductId", "SupplierId"); + + b.HasIndex("SupplierId"); + + b.ToTable("Prices"); + }); + + modelBuilder.Entity("PyroFetes.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApprovalNumber") + .HasColumnType("int"); + + b.Property("Caliber") + .HasColumnType("decimal(18,2)"); + + b.Property("ClassificationId") + .HasColumnType("int"); + + b.Property("Duration") + .HasColumnType("decimal(18,2)"); + + b.Property("Image") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Link") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("MinimalQuantity") + .HasColumnType("int"); + + b.Property("MovementId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Nec") + .HasColumnType("decimal(18,2)"); + + b.Property("ProductCategoryId") + .HasColumnType("int"); + + b.Property("References") + .HasColumnType("int"); + + b.Property("SellingPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Weight") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("ClassificationId"); + + b.HasIndex("MovementId"); + + b.HasIndex("ProductCategoryId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("ProductCategories"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductColor", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("ColorId") + .HasColumnType("int"); + + b.HasKey("ProductId", "ColorId"); + + b.HasIndex("ColorId"); + + b.ToTable("ProductColors"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("DeliveryNoteId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("ProductId", "DeliveryNoteId"); + + b.HasIndex("DeliveryNoteId"); + + b.ToTable("ProductDeliveries"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("EffectId") + .HasColumnType("int"); + + b.HasKey("ProductId", "EffectId"); + + b.HasIndex("EffectId"); + + b.ToTable("ProductEffects"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("End") + .HasColumnType("decimal(18,2)"); + + b.Property("Start") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ProductId", "ShowId"); + + b.HasIndex("ShowId"); + + b.ToTable("ProductTimecode"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => + { + b.Property("ContactId") + .HasColumnType("int"); + + b.Property("ProviderId") + .HasColumnType("int"); + + b.HasKey("ContactId", "ProviderId"); + + b.HasIndex("ProviderId"); + + b.ToTable("ProviderContacts"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProviderType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("ProviderTypes"); + }); + + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PurchaseConditions") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.HasKey("Id"); + + b.ToTable("PurchaseOrders"); + }); + + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("PurchaseOrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("ProductId", "PurchaseOrderId"); + + b.HasIndex("PurchaseOrderId"); + + b.ToTable("PurchaseProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.Quotation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConditionsSale") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("CustomerId") + .HasColumnType("int"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Quotations"); + }); + + modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("QuotationId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("ProductId", "QuotationId"); + + b.HasIndex("QuotationId"); + + b.ToTable("QuotationProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("ProviderTypeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProviderTypeId"); + + b.ToTable("Providers"); + }); + + modelBuilder.Entity("PyroFetes.Models.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ElectronicSignature") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("PyroFetes.Models.Show", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CityId") + .HasColumnType("int"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Place") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("nvarchar(120)"); + + b.Property("PyrotechnicImplementationPlan") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("CityId"); + + b.ToTable("Shows"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => + { + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.HasKey("ShowId", "MaterialId"); + + b.HasIndex("MaterialId"); + + b.ToTable("ShowMaterial"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => + { + b.Property("StaffId") + .HasColumnType("int"); + + b.Property("ShowId") + .HasColumnType("int"); + + b.HasKey("StaffId", "ShowId"); + + b.HasIndex("ShowId"); + + b.ToTable("ShowStaff"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => + { + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("TruckId") + .HasColumnType("int"); + + b.HasKey("ShowId", "TruckId"); + + b.HasIndex("TruckId"); + + b.ToTable("ShowTruck"); + }); + + modelBuilder.Entity("PyroFetes.Models.Sound", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Artist") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("nvarchar(120)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Duration") + .IsRequired() + .HasColumnType("int"); + + b.Property("Format") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("Kind") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("nvarchar(120)"); + + b.Property("SoundCategoryId") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("SoundCategoryId"); + + b.ToTable("Sounds"); + }); + + modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("SoundCategories"); + }); + + modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => + { + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("SoundId") + .HasColumnType("int"); + + b.Property("End") + .HasColumnType("decimal(18,2)"); + + b.Property("Start") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ShowId", "SoundId"); + + b.HasIndex("SoundId"); + + b.ToTable("SoundTimecodes"); + }); + + modelBuilder.Entity("PyroFetes.Models.Staff", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("nvarchar(120)"); + + b.Property("F4T2ExpirationDate") + .HasColumnType("date"); + + b.Property("F4T2NumberApproval") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Profession") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Staffs"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => + { + b.Property("AvailabilityId") + .HasColumnType("int"); + + b.Property("StaffId") + .HasColumnType("int"); + + b.HasKey("AvailabilityId", "StaffId"); + + b.HasIndex("StaffId"); + + b.ToTable("StaffAvailabilities"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffContact", b => + { + b.Property("ContactId") + .HasColumnType("int"); + + b.Property("StaffId") + .HasColumnType("int"); + + b.HasKey("ContactId", "StaffId"); + + b.HasIndex("StaffId"); + + b.ToTable("StaffContacts"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => + { + b.Property("HistoryOfApprovalId") + .HasColumnType("int"); + + b.Property("StaffId") + .HasColumnType("int"); + + b.HasKey("HistoryOfApprovalId", "StaffId"); + + b.HasIndex("StaffId"); + + b.ToTable("StaffHistoryOfApprovals"); + }); + + modelBuilder.Entity("PyroFetes.Models.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("DeliveryDelay") + .HasColumnType("int"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Suppliers"); + }); + + modelBuilder.Entity("PyroFetes.Models.Truck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MaxExplosiveCapacity") + .IsRequired() + .HasColumnType("float"); + + b.Property("Sizes") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("nvarchar(80)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.HasKey("Id"); + + b.ToTable("Trucks"); + }); + + modelBuilder.Entity("PyroFetes.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Fonction") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Salt") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("PyroFetes.Models.Warehouse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Current") + .HasColumnType("int"); + + b.Property("MaxWeight") + .HasColumnType("int"); + + b.Property("MinWeight") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Warehouses"); + }); + + modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => + { + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("WarehouseId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("ProductId", "WarehouseId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("WarehouseProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.Brand", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("Brands") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("PyroFetes.Models.Communication", b => + { + b.HasOne("PyroFetes.Models.Contact", "Contact") + .WithMany("Communications") + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + }); + + modelBuilder.Entity("PyroFetes.Models.Contact", b => + { + b.HasOne("PyroFetes.Models.Customer", "Customer") + .WithMany("Contacts") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("PyroFetes.Models.ContactServiceProvider", b => + { + b.HasOne("PyroFetes.Models.Contact", "Contact") + .WithMany("ContactServiceProviders") + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") + .WithMany("ContactServiceProviders") + .HasForeignKey("ServiceProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + + b.Navigation("ServiceProvider"); + }); + + modelBuilder.Entity("PyroFetes.Models.Contract", b => + { + b.HasOne("PyroFetes.Models.ServiceProvider", "ServiceProvider") + .WithMany("Contracts") + .HasForeignKey("ServiceProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("Contracts") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ServiceProvider"); + + b.Navigation("Show"); + }); + + modelBuilder.Entity("PyroFetes.Models.Customer", b => + { + b.HasOne("PyroFetes.Models.CustomerType", "CustomerType") + .WithMany("Customers") + .HasForeignKey("CustomerTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomerType"); + }); + + modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => + { + b.HasOne("PyroFetes.Models.Deliverer", "Deliverer") + .WithMany("DeliveryNotes") + .HasForeignKey("DelivererId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Deliverer"); + }); + + modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => + { + b.HasOne("PyroFetes.Models.Staff", "Staff") + .WithMany("ExperienceLevels") + .HasForeignKey("StaffId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Staff"); + }); + + modelBuilder.Entity("PyroFetes.Models.Material", b => + { + b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("PyroFetes.Models.MaterialWarehouse", b => + { + b.HasOne("PyroFetes.Models.Material", "Material") + .WithMany("MaterialWarehouses") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") + .WithMany("MaterialWarehouses") + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Material"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("PyroFetes.Models.Movement", b => + { + b.HasOne("PyroFetes.Models.Warehouse", "DestinationWarehouse") + .WithMany("MovementsDestination") + .HasForeignKey("DestinationWarehouseId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("PyroFetes.Models.Warehouse", "SourceWarehouse") + .WithMany("MovementsSource") + .HasForeignKey("SourceWarehouseId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DestinationWarehouse"); + + b.Navigation("SourceWarehouse"); + }); + + modelBuilder.Entity("PyroFetes.Models.Price", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("Prices") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Supplier", "Supplier") + .WithMany("Prices") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Supplier"); + }); + + modelBuilder.Entity("PyroFetes.Models.Product", b => + { + b.HasOne("PyroFetes.Models.Classification", "Classification") + .WithMany("Products") + .HasForeignKey("ClassificationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Movement", "Movement") + .WithMany("Products") + .HasForeignKey("MovementId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.ProductCategory", "ProductCategory") + .WithMany("Products") + .HasForeignKey("ProductCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Classification"); + + b.Navigation("Movement"); + + b.Navigation("ProductCategory"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductColor", b => + { + b.HasOne("PyroFetes.Models.Color", "Color") + .WithMany("ProductColors") + .HasForeignKey("ColorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("ProductColors") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Color"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductDelivery", b => + { + b.HasOne("PyroFetes.Models.DeliveryNote", "DeliveryNote") + .WithMany("ProductDeliveries") + .HasForeignKey("DeliveryNoteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("ProductDeliveries") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeliveryNote"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductEffect", b => + { + b.HasOne("PyroFetes.Models.Effect", "Effect") + .WithMany("ProductEffects") + .HasForeignKey("EffectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("ProductEffects") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Effect"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductTimecode", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("ProductTimecodes") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("ProductTimecodes") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Show"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProviderContact", b => + { + b.HasOne("PyroFetes.Models.Contact", "Contact") + .WithMany() + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.ServiceProvider", "Provider") + .WithMany() + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("PyroFetes.Models.PurchaseProduct", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("PurchaseProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.PurchaseOrder", "PurchaseOrder") + .WithMany("PurchaseProducts") + .HasForeignKey("PurchaseOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("PurchaseOrder"); + }); + + modelBuilder.Entity("PyroFetes.Models.Quotation", b => + { + b.HasOne("PyroFetes.Models.Customer", "Customer") + .WithMany("Quotations") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("QuotationProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Quotation", "Quotation") + .WithMany("QuotationProducts") + .HasForeignKey("QuotationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Quotation"); + }); + + modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => + { + b.HasOne("PyroFetes.Models.ProviderType", "ProviderType") + .WithMany("ServiceProviders") + .HasForeignKey("ProviderTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProviderType"); + }); + + modelBuilder.Entity("PyroFetes.Models.Show", b => + { + b.HasOne("PyroFetes.Models.City", "City") + .WithMany("Shows") + .HasForeignKey("CityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("City"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => + { + b.HasOne("PyroFetes.Models.Material", "Material") + .WithMany("ShowMaterials") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("ShowMaterials") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Material"); + + b.Navigation("Show"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowStaff", b => + { + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("ShowStaffs") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Staff", "Staff") + .WithMany("ShowStaffs") + .HasForeignKey("StaffId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Show"); + + b.Navigation("Staff"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowTruck", b => + { + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("ShowTrucks") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Truck", "Truck") + .WithMany("ShowTrucks") + .HasForeignKey("TruckId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Show"); + + b.Navigation("Truck"); + }); + + modelBuilder.Entity("PyroFetes.Models.Sound", b => + { + b.HasOne("PyroFetes.Models.SoundCategory", "SoundCategory") + .WithMany("Sounds") + .HasForeignKey("SoundCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SoundCategory"); + }); + + modelBuilder.Entity("PyroFetes.Models.SoundTimecode", b => + { + b.HasOne("PyroFetes.Models.Show", "Show") + .WithMany("SoundTimecodes") + .HasForeignKey("ShowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Sound", "Sound") + .WithMany("SoundTimecodes") + .HasForeignKey("SoundId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Show"); + + b.Navigation("Sound"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffAvailability", b => + { + b.HasOne("PyroFetes.Models.Availability", "Availability") + .WithMany("StaffAvailabilities") + .HasForeignKey("AvailabilityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Staff", "Staff") + .WithMany("StaffAvailabilities") + .HasForeignKey("StaffId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Availability"); + + b.Navigation("Staff"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffContact", b => + { + b.HasOne("PyroFetes.Models.Contact", "Contact") + .WithMany("StaffContacts") + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Staff", "Staff") + .WithMany("StaffContacts") + .HasForeignKey("StaffId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + + b.Navigation("Staff"); + }); + + modelBuilder.Entity("PyroFetes.Models.StaffHistoryOfApproval", b => + { + b.HasOne("PyroFetes.Models.HistoryOfApproval", "HistoryOfApproval") + .WithMany("StaffHistoryOfApprovals") + .HasForeignKey("HistoryOfApprovalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Staff", "Staff") + .WithMany("StaffHistoryOfApprovals") + .HasForeignKey("StaffId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HistoryOfApproval"); + + b.Navigation("Staff"); + }); + + modelBuilder.Entity("PyroFetes.Models.WarehouseProduct", b => + { + b.HasOne("PyroFetes.Models.Product", "Product") + .WithMany("WarehouseProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PyroFetes.Models.Warehouse", "Warehouse") + .WithMany("WarehouseProducts") + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("PyroFetes.Models.Availability", b => + { + b.Navigation("StaffAvailabilities"); + }); + + modelBuilder.Entity("PyroFetes.Models.City", b => + { + b.Navigation("Shows"); + }); + + modelBuilder.Entity("PyroFetes.Models.Classification", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("PyroFetes.Models.Color", b => + { + b.Navigation("ProductColors"); + }); + + modelBuilder.Entity("PyroFetes.Models.Contact", b => + { + b.Navigation("Communications"); + + b.Navigation("ContactServiceProviders"); + + b.Navigation("StaffContacts"); + }); + + modelBuilder.Entity("PyroFetes.Models.Customer", b => + { + b.Navigation("Contacts"); + + b.Navigation("Quotations"); + }); + + modelBuilder.Entity("PyroFetes.Models.CustomerType", b => + { + b.Navigation("Customers"); + }); + + modelBuilder.Entity("PyroFetes.Models.Deliverer", b => + { + b.Navigation("DeliveryNotes"); + }); + + modelBuilder.Entity("PyroFetes.Models.DeliveryNote", b => + { + b.Navigation("ProductDeliveries"); + }); + + modelBuilder.Entity("PyroFetes.Models.Effect", b => + { + b.Navigation("ProductEffects"); + }); + + modelBuilder.Entity("PyroFetes.Models.HistoryOfApproval", b => + { + b.Navigation("StaffHistoryOfApprovals"); + }); + + modelBuilder.Entity("PyroFetes.Models.Material", b => + { + b.Navigation("MaterialWarehouses"); + + b.Navigation("ShowMaterials"); + }); + + modelBuilder.Entity("PyroFetes.Models.Movement", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("PyroFetes.Models.Product", b => + { + b.Navigation("Brands"); + + b.Navigation("Prices"); + + b.Navigation("ProductColors"); + + b.Navigation("ProductDeliveries"); + + b.Navigation("ProductEffects"); + + b.Navigation("ProductTimecodes"); + + b.Navigation("PurchaseProducts"); + + b.Navigation("QuotationProducts"); + + b.Navigation("WarehouseProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProductCategory", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("PyroFetes.Models.ProviderType", b => + { + b.Navigation("ServiceProviders"); + }); + + modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b => + { + b.Navigation("PurchaseProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.Quotation", b => + { + b.Navigation("QuotationProducts"); + }); + + modelBuilder.Entity("PyroFetes.Models.ServiceProvider", b => + { + b.Navigation("ContactServiceProviders"); + + b.Navigation("Contracts"); + }); + + modelBuilder.Entity("PyroFetes.Models.Show", b => + { + b.Navigation("Contracts"); + + b.Navigation("ProductTimecodes"); + + b.Navigation("ShowMaterials"); + + b.Navigation("ShowStaffs"); + + b.Navigation("ShowTrucks"); + + b.Navigation("SoundTimecodes"); + }); + + modelBuilder.Entity("PyroFetes.Models.Sound", b => + { + b.Navigation("SoundTimecodes"); + }); + + modelBuilder.Entity("PyroFetes.Models.SoundCategory", b => + { + b.Navigation("Sounds"); + }); + + modelBuilder.Entity("PyroFetes.Models.Staff", b => + { + b.Navigation("ExperienceLevels"); + + b.Navigation("ShowStaffs"); + + b.Navigation("StaffAvailabilities"); + + b.Navigation("StaffContacts"); + + b.Navigation("StaffHistoryOfApprovals"); + }); + + modelBuilder.Entity("PyroFetes.Models.Supplier", b => + { + b.Navigation("Prices"); + }); + + modelBuilder.Entity("PyroFetes.Models.Truck", b => + { + b.Navigation("ShowTrucks"); + }); + + modelBuilder.Entity("PyroFetes.Models.Warehouse", b => + { + b.Navigation("MaterialWarehouses"); + + b.Navigation("MovementsDestination"); + + b.Navigation("MovementsSource"); + + b.Navigation("WarehouseProducts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PyroFetes/Models/Availability.cs b/PyroFetes/Models/Availability.cs new file mode 100644 index 0000000..fdb5f68 --- /dev/null +++ b/PyroFetes/Models/Availability.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Availability +{ + //Champs + [Key] public int Id { get; set; } + [Required] public DateOnly AvailabilityDate { get; set; } + [Required] public DateOnly DeliveryDate { get; set; } + [Required] public DateOnly ExpirationDate { get; set; } + [Required] public DateOnly RenewallDate { get; set; } + + //Relations + public List? StaffAvailabilities { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Brand.cs b/PyroFetes/Models/Brand.cs new file mode 100644 index 0000000..f1b486f --- /dev/null +++ b/PyroFetes/Models/Brand.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Brand +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required] public int ProductId { get; set; } + + //Relations + [Required] public Product? Product { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/City.cs b/PyroFetes/Models/City.cs new file mode 100644 index 0000000..60cd49a --- /dev/null +++ b/PyroFetes/Models/City.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class City +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required] public int ZipCode { get; set; } + + //Relations + public List? Shows { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Classification.cs b/PyroFetes/Models/Classification.cs new file mode 100644 index 0000000..1ac77db --- /dev/null +++ b/PyroFetes/Models/Classification.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Classification +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + //Relations + public List? Products { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Color.cs b/PyroFetes/Models/Color.cs new file mode 100644 index 0000000..95cce3d --- /dev/null +++ b/PyroFetes/Models/Color.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Color +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + //Relations + public List? ProductColors { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Communication.cs b/PyroFetes/Models/Communication.cs new file mode 100644 index 0000000..1265822 --- /dev/null +++ b/PyroFetes/Models/Communication.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Communication +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Calling { get; set; } + [Required, MaxLength(100)] public string? Email { get; set; } + [Required, MaxLength(300)] public string? Meeting { get; set; } + + //Relations + [Required] public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Contact.cs b/PyroFetes/Models/Contact.cs new file mode 100644 index 0000000..5473328 --- /dev/null +++ b/PyroFetes/Models/Contact.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Contact +{ + //Champs + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? LastName { get; set; } + [Required, MaxLength(100)] public string? FirstName { get; set; } + [Required, MaxLength(100)] public string? Email { get; set; } + [Required, MaxLength(30)] public string? PhoneNumber { get; set; } + [Required, MaxLength(100)] public string? Address { get; set; } + [Required] public int ZipCode { get; set; } + [Required, MaxLength(100)] public string? City { get; set; } + [Required, MaxLength(100)] public string? Role { get; set; } + + + //Relations + public Customer? Customer { get; set; } + [Required] public int CustomerId { get; set; } + + public List? Communications { get; set; } + public List? StaffContacts { get; set; } + public List? ContactServiceProviders { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ContactServiceProvider.cs b/PyroFetes/Models/ContactServiceProvider.cs new file mode 100644 index 0000000..cc9cd1b --- /dev/null +++ b/PyroFetes/Models/ContactServiceProvider.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(ServiceProviderId))] +public class ContactServiceProvider +{ + [Required] public int ContactId { get; set; } + [Required] public int ServiceProviderId { get; set; } + + public Contact? Contact { get; set; } + public ServiceProvider? ServiceProvider { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Contract.cs b/PyroFetes/Models/Contract.cs new file mode 100644 index 0000000..97cd821 --- /dev/null +++ b/PyroFetes/Models/Contract.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ShowId), nameof(ServiceProviderId))] +public class Contract +{ + [Required] public int ShowId { get; set; } + [Required] public int ServiceProviderId { get; set; } + [Required] public string? TermsAndConditions { get; set; } + + public Show? Show { get; set; } + public ServiceProvider? ServiceProvider { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Customer.cs b/PyroFetes/Models/Customer.cs new file mode 100644 index 0000000..da6dbba --- /dev/null +++ b/PyroFetes/Models/Customer.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Customer +{ + [Key] public int Id { get; set; } + [Required, MaxLength(200)] public string? Note { get; set; } + + //Relations + [Required] public int CustomerTypeId { get; set; } + public CustomerType? CustomerType { get; set; } + + public List? Contacts { get; set; } + public List? Quotations { get; set; } +} diff --git a/PyroFetes/Models/CustomerType.cs b/PyroFetes/Models/CustomerType.cs new file mode 100644 index 0000000..197ad09 --- /dev/null +++ b/PyroFetes/Models/CustomerType.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class CustomerType +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + public List? Customers { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Deliverer.cs b/PyroFetes/Models/Deliverer.cs new file mode 100644 index 0000000..34e708c --- /dev/null +++ b/PyroFetes/Models/Deliverer.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Deliverer +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Transporter { get; set; } + + public List? DeliveryNotes { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/DeliveryNote.cs b/PyroFetes/Models/DeliveryNote.cs new file mode 100644 index 0000000..21e873e --- /dev/null +++ b/PyroFetes/Models/DeliveryNote.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class DeliveryNote +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? TrackingNumber { get; set; } + public int DelivererId { get; set; } + [Required] public DateOnly EstimateDeliveryDate { get; set; } + [Required] public DateOnly ExpeditionDate { get; set; } + [Required] public DateOnly RealDeliveryDate { get; set; } + + public Deliverer? Deliverer { get; set; } + public List? ProductDeliveries { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Effect.cs b/PyroFetes/Models/Effect.cs new file mode 100644 index 0000000..0dcb87c --- /dev/null +++ b/PyroFetes/Models/Effect.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Effect +{ + [Key] public int Id { get; set; } + [Required, MaxLength(200)] public string? Label { get; set; } + + public List? ProductEffects { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ExperienceLevel.cs b/PyroFetes/Models/ExperienceLevel.cs new file mode 100644 index 0000000..923f757 --- /dev/null +++ b/PyroFetes/Models/ExperienceLevel.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ExperienceLevel +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + public Staff? Staff { get; set; } + [Required] public int StaffId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/HistoryOfApproval.cs b/PyroFetes/Models/HistoryOfApproval.cs new file mode 100644 index 0000000..c8fd073 --- /dev/null +++ b/PyroFetes/Models/HistoryOfApproval.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class HistoryOfApproval +{ + [Key] public int Id { get; set; } + [Required] public DateOnly DeliveryDate { get; set; } + [Required] public DateOnly ExpirationDate { get; set; } + + public List? StaffHistoryOfApprovals { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Material.cs b/PyroFetes/Models/Material.cs new file mode 100644 index 0000000..61f74c9 --- /dev/null +++ b/PyroFetes/Models/Material.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Material +{ + [Key] public int Id {get; set;} + [Required, MaxLength(100)] public string? Label {get; set;} + [Required] public int Quantity {get; set;} + + [Required] public int WarehouseId {get; set;} + public Warehouse? Warehouse {get; set;} + + public List? ShowMaterials {get; set;} + public List? MaterialWarehouses {get; set;} +} \ No newline at end of file diff --git a/PyroFetes/Models/MaterialWarehouse.cs b/PyroFetes/Models/MaterialWarehouse.cs new file mode 100644 index 0000000..4f49ba9 --- /dev/null +++ b/PyroFetes/Models/MaterialWarehouse.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(MaterialId), nameof(WarehouseId))] +public class MaterialWarehouse +{ + [Required] public int MaterialId { get; set; } + [Required] public int WarehouseId { get; set; } + + public Material? Material { get; set; } + public Warehouse? Warehouse { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Movement.cs b/PyroFetes/Models/Movement.cs new file mode 100644 index 0000000..fe26f18 --- /dev/null +++ b/PyroFetes/Models/Movement.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Movement +{ + [Key] public int Id { get; set; } + [Required] public DateTime Date { get; set; } + [Required] public DateTime Start {get; set;} + [Required] public DateTime Arrival {get; set;} + [Required] public int Quantity {get; set;} + + public List? Products { get; set; } + + public int? SourceWarehouseId {get; set;} + public Warehouse? SourceWarehouse {get; set;} + public int? DestinationWarehouseId {get; set;} + public Warehouse? DestinationWarehouse {get; set;} +} \ No newline at end of file diff --git a/PyroFetes/Models/Price.cs b/PyroFetes/Models/Price.cs new file mode 100644 index 0000000..2ee597e --- /dev/null +++ b/PyroFetes/Models/Price.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using System.Runtime.CompilerServices; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(SupplierId))] +public class Price +{ + [Required] public int ProductId { get; set; } + [Required] public int SupplierId { get; set; } + [Required] public decimal SellingPrice { get; set; } + + public Product? Product { get; set; } + public Supplier? Supplier { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Product.cs b/PyroFetes/Models/Product.cs new file mode 100644 index 0000000..b0f0d7f --- /dev/null +++ b/PyroFetes/Models/Product.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models +{ + public class Product + { + [Key] public int Id { get; set; } + [Required] public int References { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required] public decimal Duration {get; set;} + [Required] public decimal Caliber { get; set; } + [Required] public int ApprovalNumber { get; set; } + [Required] public decimal Weight { get; set; } + [Required] public decimal Nec { get; set; } + [Required] public decimal SellingPrice { get; set; } + [Required] public string? Image { get; set; } + [Required, MaxLength(200)] public string? Link { get; set; } + [Required] public int MinimalQuantity { get; set; } + + // Relations + [Required] public int ClassificationId { get; set; } + public Classification? Classification { get; set; } + + [Required] public int ProductCategoryId { get; set; } + public ProductCategory? ProductCategory { get; set; } + + [Required] public int MovementId {get; set;} + public Movement? Movement {get; set;} + + public List? ProductDeliveries { get; set; } + public List? Brands { get; set; } + public List? ProductEffects { get; set; } + public List? ProductColors { get; set; } + public List? PurchaseProducts { get; set; } + public List? Prices { get; set; } + public List? QuotationProducts { get; set; } + public List? WarehouseProducts { get; set; } + public List? ProductTimecodes { get; set; } + + + } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProductCategory.cs b/PyroFetes/Models/ProductCategory.cs new file mode 100644 index 0000000..79bd67f --- /dev/null +++ b/PyroFetes/Models/ProductCategory.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ProductCategory +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + public List? Products { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProductColor.cs b/PyroFetes/Models/ProductColor.cs new file mode 100644 index 0000000..f93d964 --- /dev/null +++ b/PyroFetes/Models/ProductColor.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(ColorId))] +public class ProductColor +{ + public Product? Product { get; set; } + [Required] public int ProductId { get; set; } + + public Color? Color { get; set; } + [Required] public int ColorId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProductDelivery.cs b/PyroFetes/Models/ProductDelivery.cs new file mode 100644 index 0000000..bfbae68 --- /dev/null +++ b/PyroFetes/Models/ProductDelivery.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(DeliveryNoteId))] +public class ProductDelivery +{ + [Required] public int ProductId { get; set; } + [Required] public int DeliveryNoteId { get; set; } + [Required] public int Quantity { get; set; } + + public Product? Product { get; set; } + public DeliveryNote? DeliveryNote { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProductEffect.cs b/PyroFetes/Models/ProductEffect.cs new file mode 100644 index 0000000..3f269d6 --- /dev/null +++ b/PyroFetes/Models/ProductEffect.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(EffectId))] +public class ProductEffect +{ + [Required] public Product? Product { get; set; } + [Required] public int ProductId { get; set; } + + public Effect? Effect { get; set; } + [Required] public int EffectId { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/Models/ProductTimecode.cs b/PyroFetes/Models/ProductTimecode.cs new file mode 100644 index 0000000..a4ad826 --- /dev/null +++ b/PyroFetes/Models/ProductTimecode.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(ShowId))] +public class ProductTimecode +{ + public Product? Product { get; set; } + [Required] public int ProductId { get; set; } + + public Show? Show { get; set; } + [Required] public int ShowId { get; set; } + + [Required] public decimal Start { get; set; } + [Required] public decimal End { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProviderContact.cs b/PyroFetes/Models/ProviderContact.cs new file mode 100644 index 0000000..8d21d35 --- /dev/null +++ b/PyroFetes/Models/ProviderContact.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(ProviderId))] +public class ProviderContact +{ + public int ProviderId { get; set; } + public ServiceProvider? Provider { get; set; } + public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ProviderType.cs b/PyroFetes/Models/ProviderType.cs new file mode 100644 index 0000000..0871b8a --- /dev/null +++ b/PyroFetes/Models/ProviderType.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ProviderType +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Label { get; set; } + + public List? ServiceProviders { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/PurchaseOrder.cs b/PyroFetes/Models/PurchaseOrder.cs new file mode 100644 index 0000000..815f5a0 --- /dev/null +++ b/PyroFetes/Models/PurchaseOrder.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class PurchaseOrder +{ + [Key] public int Id { get; set; } + [Required, MaxLength(300)] public string? PurchaseConditions { get; set; } + + public List? PurchaseProducts { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/PurchaseProduct.cs b/PyroFetes/Models/PurchaseProduct.cs new file mode 100644 index 0000000..c335ede --- /dev/null +++ b/PyroFetes/Models/PurchaseProduct.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(PurchaseOrderId))] +public class PurchaseProduct +{ + public Product? Product { get; set; } + [Required] public int ProductId { get; set; } + + public PurchaseOrder? PurchaseOrder { get; set; } + [Required] public int PurchaseOrderId { get; set; } + + [Required] public int Quantity { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Quotation.cs b/PyroFetes/Models/Quotation.cs new file mode 100644 index 0000000..569c271 --- /dev/null +++ b/PyroFetes/Models/Quotation.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Quotation +{ + [Key] public int Id { get; set; } + [Required, MaxLength(200)] public string? Message { get; set; } + [Required, MaxLength(300)] public string? ConditionsSale { get; set; } + + [Required] public int CustomerId { get; set; } + public Customer? Customer { get; set; } + + public List? QuotationProducts { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/QuotationProduct.cs b/PyroFetes/Models/QuotationProduct.cs new file mode 100644 index 0000000..8e2f3bb --- /dev/null +++ b/PyroFetes/Models/QuotationProduct.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(QuotationId))] +public class QuotationProduct +{ + [Required] public int ProductId { get; set; } + [Required] public int QuotationId { get; set; } + [Required] public int Quantity { get; set; } + + public Product? Product { get; set; } + public Quotation? Quotation { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ServiceProvider.cs b/PyroFetes/Models/ServiceProvider.cs new file mode 100644 index 0000000..b91e0d7 --- /dev/null +++ b/PyroFetes/Models/ServiceProvider.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ServiceProvider +{ + [Key] public int Id { get; set; } + [Required] public decimal Price { get; set; } + + //Relations + [Required] public int ProviderTypeId { get; set; } + public ProviderType? ProviderType { get; set; } + + public List? Contracts { get; set; } + public List? ContactServiceProviders { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Setting.cs b/PyroFetes/Models/Setting.cs new file mode 100644 index 0000000..0759032 --- /dev/null +++ b/PyroFetes/Models/Setting.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Setting +{ + [Key] public int Id { get; set; } + [Required] public string? Logo { get; set; } + [Required] public string? ElectronicSignature { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Show.cs b/PyroFetes/Models/Show.cs new file mode 100644 index 0000000..bc425dd --- /dev/null +++ b/PyroFetes/Models/Show.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Show +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required, MaxLength(120)] public string? Place { get; set; } + [MaxLength(500)] public string? Description { get; set; } + public DateOnly? Date { get; set; } + + // Link (path/URL/file name) to the pyrotechnic implementation plan + [Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; } + + [Required] public int CityId { get; set; } + public City? City { get; set; } + + public List? ShowStaffs { get; set; } + public List? ShowTrucks { get; set; } + public List? SoundTimecodes { get; set; } + public List? ProductTimecodes { get; set; } + public List? Contracts { get; set; } + public List? ShowMaterials { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ShowMaterial.cs b/PyroFetes/Models/ShowMaterial.cs new file mode 100644 index 0000000..81cc82a --- /dev/null +++ b/PyroFetes/Models/ShowMaterial.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ShowId), nameof(MaterialId))] +public class ShowMaterial +{ + [Required] public Show? Show { get; set; } + [Required] public int ShowId { get; set; } + + public Material? Material { get; set; } + [Required] public int MaterialId { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/Models/ShowServiceProvider.cs b/PyroFetes/Models/ShowServiceProvider.cs new file mode 100644 index 0000000..351c9fc --- /dev/null +++ b/PyroFetes/Models/ShowServiceProvider.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class ShowServiceProvider +{ + [Key] public int Id { get; set; } + +} \ No newline at end of file diff --git a/PyroFetes/Models/ShowStaff.cs b/PyroFetes/Models/ShowStaff.cs new file mode 100644 index 0000000..60a7215 --- /dev/null +++ b/PyroFetes/Models/ShowStaff.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(StaffId), nameof(ShowId))] +public class ShowStaff +{ + public Staff? Staff { get; set; } + [Required] public int StaffId { get; set; } + + public Show? Show { get; set; } + [Required] public int ShowId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/ShowTruck.cs b/PyroFetes/Models/ShowTruck.cs new file mode 100644 index 0000000..9f39f8a --- /dev/null +++ b/PyroFetes/Models/ShowTruck.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ShowId), nameof(TruckId))] +public class ShowTruck +{ + public Show? Show { get; set; } + [Required] public int ShowId { get; set; } + + public Truck? Truck { get; set; } + [Required] public int TruckId { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Sound.cs b/PyroFetes/Models/Sound.cs new file mode 100644 index 0000000..3ddee3e --- /dev/null +++ b/PyroFetes/Models/Sound.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Sound +{ + [Key] public int Id { get; set; } + [Required, MaxLength(120)] public string Name { get; set; } = null!; + [Required, MaxLength(60)] public string? Type { get; set; } + [Required, MaxLength(120)] public string? Artist { get; set; } + [Required, Range(0, int.MaxValue)] public int? Duration { get; set; } + [Required, MaxLength(40)] public string? Kind { get; set; } + [Required, MaxLength(40)] public string? Format { get; set; } + public DateTime? CreationDate { get; set; } + + [Required] public int SoundCategoryId { get; set; } + public SoundCategory? SoundCategory { get; set; } + + public List? SoundTimecodes { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/SoundCategory.cs b/PyroFetes/Models/SoundCategory.cs new file mode 100644 index 0000000..52caeaf --- /dev/null +++ b/PyroFetes/Models/SoundCategory.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class SoundCategory +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string Name { get; set; } = null!; + + public List? Sounds { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/SoundTimecode.cs b/PyroFetes/Models/SoundTimecode.cs new file mode 100644 index 0000000..3411e0c --- /dev/null +++ b/PyroFetes/Models/SoundTimecode.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ShowId), nameof(SoundId))] +public class SoundTimecode +{ + [Required] public int ShowId { get; set; } + public Show? Show { get; set; } + [Required] public int SoundId { get; set; } + public Sound? Sound { get; set; } + + [Required] public decimal Start { get; set; } + [Required] public decimal End { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs new file mode 100644 index 0000000..a95c455 --- /dev/null +++ b/PyroFetes/Models/Staff.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Staff +{ + [Key] public int Id { get; set; } + [Required, MaxLength(60)] public string FirstName { get; set; } = null!; + [Required, MaxLength(60)] public string LastName { get; set; } = null!; + [Required, MaxLength(100)] public string? Profession { get; set; } + [Required, MaxLength(120)] public string? Email { get; set; } + [Required, MaxLength(100)] public string? F4T2NumberApproval { get; set; } + [Required] public DateOnly F4T2ExpirationDate { get; set; } + + public List? ShowStaffs { get; set; } + public List? ExperienceLevels { get; set; } + public List? StaffAvailabilities { get; set; } + public List? StaffHistoryOfApprovals { get; set; } + public List? StaffContacts { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffAvailability.cs b/PyroFetes/Models/StaffAvailability.cs new file mode 100644 index 0000000..3ba0732 --- /dev/null +++ b/PyroFetes/Models/StaffAvailability.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(AvailabilityId), nameof(StaffId))] +public class StaffAvailability +{ + public int StaffId { get; set; } + public Staff? Staff { get; set; } + public int AvailabilityId { get; set; } + public Availability? Availability { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffContact.cs b/PyroFetes/Models/StaffContact.cs new file mode 100644 index 0000000..18ab5a9 --- /dev/null +++ b/PyroFetes/Models/StaffContact.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(StaffId))] +public class StaffContact +{ + [Required] public int StaffId { get; set; } + public Staff? Staff { get; set; } + [Required] public int ContactId { get; set; } + public Contact? Contact { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/StaffHistoryOfApproval.cs b/PyroFetes/Models/StaffHistoryOfApproval.cs new file mode 100644 index 0000000..3937064 --- /dev/null +++ b/PyroFetes/Models/StaffHistoryOfApproval.cs @@ -0,0 +1,12 @@ +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(HistoryOfApprovalId), nameof(StaffId))] +public class StaffHistoryOfApproval +{ + public int StaffId { get; set; } + public Staff? Staff { get; set; } + public int HistoryOfApprovalId { get; set; } + public HistoryOfApproval? HistoryOfApproval { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Supplier.cs b/PyroFetes/Models/Supplier.cs new file mode 100644 index 0000000..f131804 --- /dev/null +++ b/PyroFetes/Models/Supplier.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Supplier +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required, MaxLength(100)] public string? Email { get; set; } + [Required, MaxLength(30)] public string? Phone { get; set; } + [Required, MaxLength(100)] public string? Address { get; set; } + [Required] public int ZipCode { get; set; } + [Required, MaxLength(100)] public string? City { get; set; } + [Required] public int DeliveryDelay { get; set; } + + public List? Prices { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Truck.cs b/PyroFetes/Models/Truck.cs new file mode 100644 index 0000000..91794a9 --- /dev/null +++ b/PyroFetes/Models/Truck.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Truck +{ + [Key] public int Id { get; set; } + [Required, MaxLength(40)] public string Type { get; set; } = null!; + [Required] public double? MaxExplosiveCapacity { get; set; } + [Required, MaxLength(80)] public string? Sizes { get; set; } + [Required, MaxLength(40)] public string? Status { get; set; } + + public List? ShowTrucks { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/User.cs b/PyroFetes/Models/User.cs new file mode 100644 index 0000000..8baaa1c --- /dev/null +++ b/PyroFetes/Models/User.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class User +{ + [Key] public int Id { get; set; } + [Required, MaxLength(100)] public string? Name { get; set; } + [Required, MinLength(12), MaxLength(50)] public string? Password { get; set; } + [Required, MaxLength(100)] public string? Salt { get; set; } + [Required, MaxLength(100)] public string? Email { get; set; } + [Required, MaxLength(100)] public string? Fonction { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/Warehouse.cs b/PyroFetes/Models/Warehouse.cs new file mode 100644 index 0000000..8d014e7 --- /dev/null +++ b/PyroFetes/Models/Warehouse.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations; + +namespace PyroFetes.Models; + +public class Warehouse +{ + [Key] public int Id {get; set;} + [Required, MaxLength(100)] public string? Name {get; set;} + [Required] public int MaxWeight {get; set;} + [Required] public int Current {get; set;} + [Required] public int MinWeight {get; set;} + [Required, MaxLength(100)] public string? Address { get; set; } + [Required] public int ZipCode { get; set; } + [Required, MaxLength(100)] public string? City { get; set; } + + public List? WarehouseProducts { get; set; } + + public List? MaterialWarehouses {get; set;} + + public List? MovementsSource { get; set; } + public List? MovementsDestination { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Models/WarehouseProduct.cs b/PyroFetes/Models/WarehouseProduct.cs new file mode 100644 index 0000000..fe89d36 --- /dev/null +++ b/PyroFetes/Models/WarehouseProduct.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ProductId), nameof(WarehouseId))] +public class WarehouseProduct +{ + [Required] public int ProductId { get; set; } + public Product? Product { get; set; } + [Required] public int WarehouseId { get; set; } + public Warehouse? Warehouse { get; set; } + + [Required] public int Quantity { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs new file mode 100644 index 0000000..e610bf4 --- /dev/null +++ b/PyroFetes/Program.cs @@ -0,0 +1,20 @@ +using API; +using FastEndpoints; +using FastEndpoints.Swagger; +using PyroFetes; + +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); + +// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet +builder.Services.AddFastEndpoints().SwaggerDocument(); + +// On ajoute ici la configuration de la base de données +builder.Services.AddDbContext(); + +// On construit l'application en lui donnant vie +WebApplication app = builder.Build(); +app.UseFastEndpoints().UseSwaggerGen(); + +app.UseHttpsRedirection(); + +app.Run(); \ No newline at end of file diff --git a/PyroFetes/PyroFetesDbContext.cs b/PyroFetes/PyroFetesDbContext.cs new file mode 100644 index 0000000..b5ce8c7 --- /dev/null +++ b/PyroFetes/PyroFetesDbContext.cs @@ -0,0 +1,93 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.Models; +using ServiceProvider = PyroFetes.Models.ServiceProvider; + +namespace PyroFetes; + +public class PyroFetesDbContext : DbContext +{ + // Entities + public DbSet Availabilities { get; set; } + public DbSet Brands { get; set; } + public DbSet Classifications { get; set; } + public DbSet Colors { get; set; } + public DbSet Communications { get; set; } + public DbSet Contacts { get; set; } + public DbSet Customers { get; set; } + public DbSet CustomerTypes { get; set; } + public DbSet Deliverers { get; set; } + public DbSet DeliveryNotes { get; set; } + public DbSet Effects { get; set; } + public DbSet ExperienceLevels { get; set; } + public DbSet HistoryOfApprovals { get; set; } + public DbSet Materials { get; set; } + public DbSet Movements { get; set; } + public DbSet Prices { get; set; } + public DbSet Products { get; set; } + public DbSet ProductCategories { get; set; } + public DbSet ProductColors { get; set; } + public DbSet ProductDeliveries { get; set; } + public DbSet ProductEffects { get; set; } + public DbSet Providers { get; set; } + public DbSet ProviderContacts { get; set; } + public DbSet ProviderTypes { get; set; } + public DbSet PurchaseOrders { get; set; } + public DbSet PurchaseProducts { get; set; } + public DbSet Quotations { get; set; } + public DbSet QuotationProducts { get; set; } + public DbSet Settings { get; set; } + public DbSet Shows { get; set; } + public DbSet Sounds { get; set; } + public DbSet SoundCategories { get; set; } + public DbSet SoundTimecodes { get; set; } + public DbSet Staffs { get; set; } + public DbSet StaffAvailabilities { get; set; } + public DbSet StaffContacts { get; set; } + public DbSet StaffHistoryOfApprovals { get; set; } + public DbSet Suppliers { get; set; } + public DbSet Trucks { get; set; } + public DbSet Users { get; set; } + public DbSet Warehouses { get; set; } + public DbSet WarehouseProducts { get; set; } + + // Database configuration + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + string connectionString = + "Server=romaric-thibault.fr;" + + "Database=PyroFetes;" + + "User Id=pyrofetes;" + + "Password=Crablike8-Fringe-Swimmable;" + + "TrustServerCertificate=true;"; + + optionsBuilder.UseSqlServer(connectionString); + } + + // Models customization + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasOne(m => m.SourceWarehouse) + .WithMany(w => w.MovementsSource) + .HasForeignKey(m => m.SourceWarehouseId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(m => m.DestinationWarehouse) + .WithMany(w => w.MovementsDestination) + .HasForeignKey(m => m.DestinationWarehouseId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(mw => mw.Material) + .WithMany(m => m.MaterialWarehouses) + .HasForeignKey(mw => mw.MaterialId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(mw => mw.Warehouse) + .WithMany(w => w.MaterialWarehouses) + .HasForeignKey(mw => mw.WarehouseId) + .OnDelete(DeleteBehavior.Restrict); + } +} \ No newline at end of file