From 0a001e15e364245b94ee05963bc07c98a02d5e19 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 15:03:10 +0100 Subject: [PATCH 01/17] add missed dto/enbdpoints --- .../DTO/Customer/Request/CreateCustomerDto.cs | 6 +++ .../Customer/Request/GetCustomerRequest.cs | 6 +++ .../DTO/Customer/Request/UpdateCustomerDto.cs | 7 ++++ .../DTO/Customer/Response/GetCustomerDto.cs | 7 ++++ .../Request/CreateCustomerTypeDto.cs | 6 +++ .../Request/GetCustomerTypeRequest.cs | 6 +++ .../Request/UpdateCustomerTypeDto.cs | 7 ++++ .../Response/GetCustomerTypeDto.cs | 7 ++++ .../DTO/Provider/Request/CreateProviderDto.cs | 6 +++ .../Provider/Request/GetProviderRequest.cs | 6 +++ .../DTO/Provider/Request/UpdateProviderDto.cs | 7 ++++ .../DTO/Provider/Response/GetProviderDto.cs | 7 ++++ .../Request/CreateProviderTypeDto.cs | 6 +++ .../Request/GetProviderTypeRequest.cs | 6 +++ .../Request/UpdateProviderTypeDto.cs | 7 ++++ .../Response/GetProviderTypeDto.cs | 7 ++++ .../Customer/CreateCustomerEndpoint.cs | 34 +++++++++++++++++ .../Customer/DeleteCustomerEndpoint.cs | 30 +++++++++++++++ .../Customer/GetAllCustomerEndpoint.cs | 25 ++++++++++++ .../Endpoints/Customer/GetCustomerEndpoint.cs | 34 +++++++++++++++++ .../Customer/UpdateCustomerEndpoint.cs | 38 +++++++++++++++++++ .../CreateCustomerTypeEndpoint.cs | 34 +++++++++++++++++ .../DeleteCustomerTypeEndpoint.cs | 32 ++++++++++++++++ .../GetAllCustomerTypeEndpoint.cs | 25 ++++++++++++ .../CustomerType/GetCustomerTypeEndpoint.cs | 34 +++++++++++++++++ .../CustomerType/UpdateCustomerEndpoint.cs | 38 +++++++++++++++++++ 26 files changed, 428 insertions(+) create mode 100644 PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs create mode 100644 PyroFetes/DTO/Customer/Request/GetCustomerRequest.cs create mode 100644 PyroFetes/DTO/Customer/Request/UpdateCustomerDto.cs create mode 100644 PyroFetes/DTO/Customer/Response/GetCustomerDto.cs create mode 100644 PyroFetes/DTO/CustomerType/Request/CreateCustomerTypeDto.cs create mode 100644 PyroFetes/DTO/CustomerType/Request/GetCustomerTypeRequest.cs create mode 100644 PyroFetes/DTO/CustomerType/Request/UpdateCustomerTypeDto.cs create mode 100644 PyroFetes/DTO/CustomerType/Response/GetCustomerTypeDto.cs create mode 100644 PyroFetes/DTO/Provider/Request/CreateProviderDto.cs create mode 100644 PyroFetes/DTO/Provider/Request/GetProviderRequest.cs create mode 100644 PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs create mode 100644 PyroFetes/DTO/Provider/Response/GetProviderDto.cs create mode 100644 PyroFetes/DTO/ProviderType/Request/CreateProviderTypeDto.cs create mode 100644 PyroFetes/DTO/ProviderType/Request/GetProviderTypeRequest.cs create mode 100644 PyroFetes/DTO/ProviderType/Request/UpdateProviderTypeDto.cs create mode 100644 PyroFetes/DTO/ProviderType/Response/GetProviderTypeDto.cs create mode 100644 PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs create mode 100644 PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs create mode 100644 PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs create mode 100644 PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs create mode 100644 PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs create mode 100644 PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs diff --git a/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs b/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs new file mode 100644 index 0000000..6a90c75 --- /dev/null +++ b/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Customer.Request; + +public class CreateCustomerDto +{ + public string? Note { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Customer/Request/GetCustomerRequest.cs b/PyroFetes/DTO/Customer/Request/GetCustomerRequest.cs new file mode 100644 index 0000000..e31bd35 --- /dev/null +++ b/PyroFetes/DTO/Customer/Request/GetCustomerRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Customer.Request; + +public class GetCustomerRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Customer/Request/UpdateCustomerDto.cs b/PyroFetes/DTO/Customer/Request/UpdateCustomerDto.cs new file mode 100644 index 0000000..2e18b07 --- /dev/null +++ b/PyroFetes/DTO/Customer/Request/UpdateCustomerDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Customer.Request; + +public class UpdateCustomerDto +{ + public int Id { get; set; } + public string? Note { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs new file mode 100644 index 0000000..53a00c5 --- /dev/null +++ b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Customer.Response; + +public class GetCustomerDto +{ + public int Id { get; set; } + public string? Note { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/CustomerType/Request/CreateCustomerTypeDto.cs b/PyroFetes/DTO/CustomerType/Request/CreateCustomerTypeDto.cs new file mode 100644 index 0000000..8ccffe0 --- /dev/null +++ b/PyroFetes/DTO/CustomerType/Request/CreateCustomerTypeDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.CustomerType.Request; + +public class CreateCustomerTypeDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/CustomerType/Request/GetCustomerTypeRequest.cs b/PyroFetes/DTO/CustomerType/Request/GetCustomerTypeRequest.cs new file mode 100644 index 0000000..ce7d70f --- /dev/null +++ b/PyroFetes/DTO/CustomerType/Request/GetCustomerTypeRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.CustomerType.Request; + +public class GetCustomerTypeRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/CustomerType/Request/UpdateCustomerTypeDto.cs b/PyroFetes/DTO/CustomerType/Request/UpdateCustomerTypeDto.cs new file mode 100644 index 0000000..a0cd25b --- /dev/null +++ b/PyroFetes/DTO/CustomerType/Request/UpdateCustomerTypeDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.CustomerType.Request; + +public class UpdateCustomerTypeDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/CustomerType/Response/GetCustomerTypeDto.cs b/PyroFetes/DTO/CustomerType/Response/GetCustomerTypeDto.cs new file mode 100644 index 0000000..ba06dfe --- /dev/null +++ b/PyroFetes/DTO/CustomerType/Response/GetCustomerTypeDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.CustomerType.Response; + +public class GetCustomerTypeDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs new file mode 100644 index 0000000..2f548d9 --- /dev/null +++ b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Provider.Request; + +public class CreateProviderDto +{ + public int? Price { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Request/GetProviderRequest.cs b/PyroFetes/DTO/Provider/Request/GetProviderRequest.cs new file mode 100644 index 0000000..7af3e05 --- /dev/null +++ b/PyroFetes/DTO/Provider/Request/GetProviderRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Provider.Request; + +public class GetProviderRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs b/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs new file mode 100644 index 0000000..8b7c0a6 --- /dev/null +++ b/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Provider.Request; + +public class UpdateProviderDto +{ + public int Id { get; set; } + public int? Price { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs new file mode 100644 index 0000000..1a5c3ca --- /dev/null +++ b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Provider.Response; + +public class GetProviderDto +{ + public int Id { get; set; } + public int? Price { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProviderType/Request/CreateProviderTypeDto.cs b/PyroFetes/DTO/ProviderType/Request/CreateProviderTypeDto.cs new file mode 100644 index 0000000..ad598b4 --- /dev/null +++ b/PyroFetes/DTO/ProviderType/Request/CreateProviderTypeDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.ProviderType.Request; + +public class CreateProviderTypeDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProviderType/Request/GetProviderTypeRequest.cs b/PyroFetes/DTO/ProviderType/Request/GetProviderTypeRequest.cs new file mode 100644 index 0000000..897aac3 --- /dev/null +++ b/PyroFetes/DTO/ProviderType/Request/GetProviderTypeRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.ProviderType.Request; + +public class GetProviderTypeRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProviderType/Request/UpdateProviderTypeDto.cs b/PyroFetes/DTO/ProviderType/Request/UpdateProviderTypeDto.cs new file mode 100644 index 0000000..ee1d894 --- /dev/null +++ b/PyroFetes/DTO/ProviderType/Request/UpdateProviderTypeDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.ProviderType.Request; + +public class UpdateProviderTypeDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProviderType/Response/GetProviderTypeDto.cs b/PyroFetes/DTO/ProviderType/Response/GetProviderTypeDto.cs new file mode 100644 index 0000000..eb569b5 --- /dev/null +++ b/PyroFetes/DTO/ProviderType/Response/GetProviderTypeDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.ProviderType.Response; + +public class GetProviderTypeDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs new file mode 100644 index 0000000..0d92c29 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using PyroFetes.DTO.Customer.Request; +using PyroFetes.DTO.Customer.Response; + +namespace PyroFetes.Endpoints.Customer; + +public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/Customer"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateCustomerDto req, CancellationToken ct) + { + var customer = new Models.Customer + { + Note = req.Note + }; + pyroFetesDbContext.Add(customer); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCustomerDto response = new GetCustomerDto() + { + Id = customer.Id, + Note = customer.Note + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs new file mode 100644 index 0000000..aa434d8 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Customer.Request; +using PyroFetes.DTO.Customer.Response; + +namespace PyroFetes.Endpoints.Customer; + +public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/Customer/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetCustomerRequest req, CancellationToken ct) + { + Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomer == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Customers.Remove(databaseCustomer); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs new file mode 100644 index 0000000..216f8d8 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -0,0 +1,25 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Customer.Response; + +namespace PyroFetes.Endpoints.Customer; + +public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/Customer"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List customer= await pyroFetesDbContext.Customers.Select(x => new GetCustomerDto() + { + Id = x.Id, + Note = x.Note, + }).ToListAsync(ct); + + await Send.OkAsync(customer, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs new file mode 100644 index 0000000..0c9de44 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Customer.Request; +using PyroFetes.DTO.Customer.Response; + +namespace PyroFetes.Endpoints.Customer; + +public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/Customer/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetCustomerRequest req, CancellationToken ct) + { + Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomer == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetCustomerDto dto = new() + { + Id = databaseCustomer.Id, + Note = databaseCustomer.Note, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs new file mode 100644 index 0000000..9cdcaf8 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Customer.Request; +using PyroFetes.DTO.Customer.Response; + +namespace PyroFetes.Endpoints.Customer; + +public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/Customer/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateCustomerDto req, CancellationToken ct) + { + Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomer == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseCustomer.Note = req.Note; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCustomerDto dto = new() + { + Id = databaseCustomer.Id, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs new file mode 100644 index 0000000..096f773 --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using PyroFetes.DTO.CustomerType.Response; +using PyroFetes.DTO.CustomerType.Request; + +namespace PyroFetes.Endpoints.CustomerType; + +public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/CustomerType"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateCustomerTypeDto req, CancellationToken ct) + { + var customerType = new Models.CustomerType + { + Label = req.Label + }; + pyroFetesDbContext.Add(customerType); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCustomerTypeDto response = new GetCustomerTypeDto() + { + Id = customerType.Id, + Label = customerType.Label + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs new file mode 100644 index 0000000..9e67e81 --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -0,0 +1,32 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Customer.Request; +using PyroFetes.DTO.Customer.Response; +using PyroFetes.DTO.CustomerType.Request; +using PyroFetes.DTO.CustomerType.Response; + +namespace PyroFetes.Endpoints.CustomerType; + +public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/CustomerType/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetCustomerRequest req, CancellationToken ct) + { + Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomer == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Customers.Remove(databaseCustomer); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs new file mode 100644 index 0000000..449aa9f --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs @@ -0,0 +1,25 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.CustomerType.Response; + +namespace PyroFetes.Endpoints.CustomerType; + +public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/CustomerType"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List customerType= await pyroFetesDbContext.CustomerTypes.Select(x => new GetCustomerTypeDto() + { + Id = x.Id, + Label = x.Label, + }).ToListAsync(ct); + + await Send.OkAsync(customerType, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs new file mode 100644 index 0000000..c1f7599 --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.CustomerType.Request; +using PyroFetes.DTO.CustomerType.Response; + +namespace PyroFetes.Endpoints.CustomerType; + +public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/CustomerType/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetCustomerTypeRequest req, CancellationToken ct) + { + Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomerType == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetCustomerTypeDto dto = new() + { + Id = databaseCustomerType.Id, + Label = databaseCustomerType.Label, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs new file mode 100644 index 0000000..0c8a362 --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.CustomerType.Request; +using PyroFetes.DTO.CustomerType.Response; + +namespace PyroFetes.Endpoints.CustomerType; + +public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/CustomerType/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateCustomerTypeDto req, CancellationToken ct) + { + Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCustomerType == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseCustomerType.Label = req.Label; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCustomerTypeDto dto = new() + { + Id = databaseCustomerType.Id, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file From df0756ff504c519b0b7391c0a9138205ca123279 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 15:29:23 +0100 Subject: [PATCH 02/17] change route --- .../Contact/DeleteContactEndpoint.cs | 2 +- .../Customer/CreateCustomerEndpoint.cs | 2 +- .../Customer/DeleteCustomerEndpoint.cs | 2 +- .../Customer/GetAllCustomerEndpoint.cs | 2 +- .../Endpoints/Customer/GetCustomerEndpoint.cs | 2 +- .../Customer/UpdateCustomerEndpoint.cs | 2 +- .../CreateCustomerTypeEndpoint.cs | 2 +- .../DeleteCustomerTypeEndpoint.cs | 2 +- .../GetAllCustomerTypeEndpoint.cs | 2 +- .../CustomerType/GetCustomerTypeEndpoint.cs | 2 +- .../CustomerType/UpdateCustomerEndpoint.cs | 2 +- .../CreateExperienceLevelEndpoint.cs | 2 +- .../DeleteExerienceLevelEndpoint.cs | 2 +- .../GetAllExperienceLevelsEndpoint.cs | 2 +- .../GetExperienceLevelEndpoint.cs | 2 +- .../UpdateExperienceLevelEndpoint.cs | 2 +- .../CreateHistoryOfApprovalEndpoint.cs | 2 +- .../DeleteHistoryOfApprovalEndpoint.cs | 2 +- .../GetAllHistoryOfApprovalEndpoint.cs | 2 +- .../GetHistoryOfApprovalEndpoint.cs | 2 +- .../UpdateHistoryOfApprovalEndpoint.cs | 2 +- .../Endpoints/Staff/CreateStaffEndpoint.cs | 2 +- .../Endpoints/Staff/DeleteStaffEndpoint.cs | 2 +- .../Endpoints/Staff/GetAllStaffsEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs | 2 +- .../Endpoints/Staff/UpdateStaffRequest.cs | 2 +- PyroFetes/Program.cs | 48 ++++++++++++++----- PyroFetes/PyroFetes.csproj | 2 + 28 files changed, 64 insertions(+), 38 deletions(-) diff --git a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs index 51a965c..530417d 100644 --- a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp { public override void Configure() { - Delete ("/api/Contacts/{@Id}", x => new { x.Id }); + Delete ("/api/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs index 0d92c29..3b51b5b 100644 --- a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/api/Customer"); + Post("/api/customer"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs index aa434d8..a812115 100644 --- a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/api/Customer/{@Id}", x => new { x.Id }); + Delete ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs index 216f8d8..d96f3dc 100644 --- a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Get ("/api/Customer"); + Get ("/api/customer"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs index 0c9de44..be1d2e0 100644 --- a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/api/Customer/{@Id}", x => new { x.Id }); + Get ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs index 9cdcaf8..4f4c22b 100644 --- a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint new { x.Id }); + Put ("/api/customer/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs index 096f773..b0d00d7 100644 --- a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/CustomerType"); + Post("/api/customertype"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs index 9e67e81..48d2982 100644 --- a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -11,7 +11,7 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/CustomerType/{@Id}", x => new { x.Id }); + Delete ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs index 449aa9f..5dba9e7 100644 --- a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/CustomerType"); + Get ("/api/customertype"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs index c1f7599..e5047f4 100644 --- a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/CustomerType/{@Id}", x => new { x.Id }); + Get ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs index 0c8a362..981953f 100644 --- a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/CustomerType/{@Id}", x => new { x.Id }); + Put ("/api/customertype/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs index ef4ccc6..a87fc05 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Post("/api/ExperienceLevels"); + Post("/api/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs index 2fc0a96..8f0190f 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + Delete ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs index c04d6e7..f51e754 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex { public override void Configure() { - Get ("/api/experienceLevels"); + Get ("/api/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs index 9236f07..aca625a 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/experienceLevels/{@Id}", x => new { x.Id }); + Get ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs index e928e41..932b878 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + Put ("/api/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs index d5251ae..f2a845d 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Post("/api/HistoryOfApprovals"); + Post("/api/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs index 0095177..7cc5fa7 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Delete ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs index cc0cd48..843d200 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Get ("/api/HistoryOfApprovals"); + Get ("/api/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs index eb3f70c..d00bc12 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Get ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs index e5c98e6..3d37d7c 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + Put ("/api/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs index 06f6e64..bdaec96 100644 --- a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs @@ -8,7 +8,7 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Post("/api/availabilities"); + Post("/api/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs index 1af08ee..b57e85d 100644 --- a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Delete ("/api/staff/{@Id}", x => new { x.Id }); + Delete ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs index 479b670..e06c013 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo { public override void Configure() { - Get ("/api/availabilities"); + Get ("/api/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs index 73e95fe..2f208e3 100644 --- a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs @@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { - Get ("/api/Staffs/{@Id}", x => new { x.Id }); + Get ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs index eb9ef7f..a17012e 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs @@ -9,7 +9,7 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/Staffs/{@Id}", x => new { x.Id }); + Put ("/api/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index d127d73..03ac2b2 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -1,19 +1,43 @@ -var builder = WebApplication.CreateBuilder(args); +using PyroFetes; +using FastEndpoints; +using FastEndpoints.Swagger; +using FastEndpoints.Security; -// Add services to the container. -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); -var app = builder.Build(); +// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet +builder.Services + .AddAuthenticationJwtBearer(s => s.SigningKey = "zewsxrdctfvgybuhbgyvftrcdtfvgbyuhn") + .AddAuthorization() + .AddFastEndpoints().SwaggerDocument(options => { options.ShortSchemaNames = true;}); -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} +// On ajoute ici la configuration de la base de données +builder.Services.AddDbContext(); + +//On ajoute le CORS au code +builder.Services.AddCors(options => +{ options.AddDefaultPolicy(policyBuilder => + { + policyBuilder + .WithOrigins("http://localhost:4200") + .WithMethods("GET", "POST", "PUT", "PATCH", "DELETE") + .AllowAnyHeader(); + }); +}); + +// On construit l'application en lui donnant vie +WebApplication app = builder.Build(); +app.UseAuthentication() + .UseAuthorization() + .UseFastEndpoints(options => + { + options.Endpoints.RoutePrefix = "API"; + options.Endpoints.ShortNames = true; + } + ).UseSwaggerGen(); app.UseHttpsRedirection(); +app.UseCors(); + app.Run(); \ No newline at end of file diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index b301a92..ed5ce50 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -7,7 +7,9 @@ + + From 604dd77fed70eca02933956975429cdf59396ef1 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 15:32:25 +0100 Subject: [PATCH 03/17] change name --- .../Endpoints/Communication/DeleteCommunicationEndpoint.cs | 2 +- PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs index b707b4b..5c1eb67 100644 --- a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Delete ("/api/availabilities/{@Id}", x => new { x.Id }); + Delete ("/api/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs index cb58367..18a8fc0 100644 --- a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs @@ -9,7 +9,7 @@ public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : E { public override void Configure() { - Get ("/api/availabilities"); + Get ("/api/communications"); AllowAnonymous(); } From fc736e8525fb95bfc2b6f0b1d87c92ec5b8d6e76 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 15:56:02 +0100 Subject: [PATCH 04/17] provider added --- .../DTO/Provider/Request/CreateProviderDto.cs | 2 +- .../DTO/Provider/Request/UpdateProviderDto.cs | 2 +- .../DTO/Provider/Response/GetProviderDto.cs | 2 +- .../Provider/CreateProviderEndpoint.cs | 34 +++++++++++++++++ .../Provider/DeleteProviderEndpoint.cs | 30 +++++++++++++++ .../Provider/GetAllProvidersEndpoint.cs | 25 ++++++++++++ .../Endpoints/Provider/GetProviderEndpoint.cs | 34 +++++++++++++++++ .../Provider/UpdateProviderEndpoint.cs | 38 +++++++++++++++++++ 8 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs create mode 100644 PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs create mode 100644 PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs create mode 100644 PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs create mode 100644 PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs diff --git a/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs index 2f548d9..ea0df6a 100644 --- a/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs +++ b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs @@ -2,5 +2,5 @@ namespace PyroFetes.DTO.Provider.Request; public class CreateProviderDto { - public int? Price { get; set; } + public decimal Price { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs b/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs index 8b7c0a6..216dc68 100644 --- a/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs +++ b/PyroFetes/DTO/Provider/Request/UpdateProviderDto.cs @@ -3,5 +3,5 @@ namespace PyroFetes.DTO.Provider.Request; public class UpdateProviderDto { public int Id { get; set; } - public int? Price { get; set; } + public decimal Price { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs index 1a5c3ca..99eeab0 100644 --- a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs +++ b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs @@ -3,5 +3,5 @@ namespace PyroFetes.DTO.Provider.Response; public class GetProviderDto { public int Id { get; set; } - public int? Price { get; set; } + public decimal Price { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs new file mode 100644 index 0000000..f7f3e99 --- /dev/null +++ b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using PyroFetes.DTO.Provider.Request; +using PyroFetes.DTO.Provider.Response; + +namespace PyroFetes.Endpoints.Provider; + +public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/providers"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateProviderDto req, CancellationToken ct) + { + var provider = new Models.ServiceProvider() + { + Price = req.Price + }; + pyroFetesDbContext.Add(provider); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetProviderDto response = new GetProviderDto() + { + Id = provider.Id, + Price = provider.Price + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs new file mode 100644 index 0000000..7668675 --- /dev/null +++ b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Provider.Request; +using PyroFetes.DTO.Provider.Response; + +namespace PyroFetes.Endpoints.Provider; + +public class DeleteProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/providers/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct) + { + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProvider == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Providers.Remove(databaseProvider); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs new file mode 100644 index 0000000..0ab3848 --- /dev/null +++ b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs @@ -0,0 +1,25 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Provider.Response; + +namespace PyroFetes.Endpoints.Provider; + +public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/providers"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List customer= await pyroFetesDbContext.Providers.Select(x => new GetProviderDto() + { + Id = x.Id, + Price = x.Price, + }).ToListAsync(ct); + + await Send.OkAsync(customer, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs new file mode 100644 index 0000000..ecad2f8 --- /dev/null +++ b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Provider.Request; +using PyroFetes.DTO.Provider.Response; + +namespace PyroFetes.Endpoints.Provider; + +public class GetProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/providers/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct) + { + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProvider == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetProviderDto dto = new() + { + Id = databaseProvider.Id, + Price = databaseProvider.Price, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs new file mode 100644 index 0000000..9b425a9 --- /dev/null +++ b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Provider.Request; +using PyroFetes.DTO.Provider.Response; + +namespace PyroFetes.Endpoints.Provider; + +public class UpdateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/providers/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateProviderDto req, CancellationToken ct) + { + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProvider == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseProvider.Price = req.Price; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetProviderDto dto = new() + { + Id = databaseProvider.Id, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file From a554693e9ca91761a53cc3096dab3ae547cde900 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 16:31:52 +0100 Subject: [PATCH 05/17] =?UTF-8?q?Provider=20typ=C3=AA=20added=20+=20delete?= =?UTF-8?q?=20customer=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeleteCustomerTypeEndpoint.cs | 12 +++--- .../CreateProviderTypeEndpoint.cs | 34 +++++++++++++++++ .../DeleteProviderTypeEndpoint.cs | 30 +++++++++++++++ .../GetAllProviderTypesEndpoint.cs | 25 ++++++++++++ .../ProviderType/GetProviderTypeEndpoint.cs | 34 +++++++++++++++++ .../UpdateProviderTypeEndpoint.cs | 38 +++++++++++++++++++ 6 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs create mode 100644 PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs create mode 100644 PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs index 48d2982..820271d 100644 --- a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -1,13 +1,11 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.Customer.Request; -using PyroFetes.DTO.Customer.Response; using PyroFetes.DTO.CustomerType.Request; using PyroFetes.DTO.CustomerType.Response; namespace PyroFetes.Endpoints.CustomerType; -public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { @@ -15,16 +13,16 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : AllowAnonymous(); } - public override async Task HandleAsync(GetCustomerRequest req, CancellationToken ct) + public override async Task HandleAsync(GetCustomerTypeRequest req, CancellationToken ct) { - Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); - if (databaseCustomer == null) + if (databaseCustomerType == null) { await Send.NotFoundAsync(ct); return; } - pyroFetesDbContext.Customers.Remove(databaseCustomer); + pyroFetesDbContext.CustomerTypes.Remove(databaseCustomerType); await pyroFetesDbContext.SaveChangesAsync(ct); await Send.NoContentAsync(ct); diff --git a/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs new file mode 100644 index 0000000..a82ae38 --- /dev/null +++ b/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using PyroFetes.DTO.ProviderType.Request; +using PyroFetes.DTO.ProviderType.Response; + +namespace PyroFetes.Endpoints.ProviderType; + +public class CreateProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/providertypes"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateProviderTypeDto req, CancellationToken ct) + { + var providerType = new Models.ProviderType + { + Label = req.Label + }; + pyroFetesDbContext.Add(providerType); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetProviderTypeDto response = new GetProviderTypeDto() + { + Id = providerType.Id, + Label = providerType.Label + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs new file mode 100644 index 0000000..c075a21 --- /dev/null +++ b/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ProviderType.Request; +using PyroFetes.DTO.ProviderType.Response; + +namespace PyroFetes.Endpoints.ProviderType; + +public class DeleteProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/providertypes/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderTypeRequest req, CancellationToken ct) + { + Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProviderType == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.ProviderTypes.Remove(databaseProviderType); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs new file mode 100644 index 0000000..61f454e --- /dev/null +++ b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs @@ -0,0 +1,25 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ProviderType.Response; + +namespace PyroFetes.Endpoints.ProviderType; + +public class GetAllProviderTypesEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/providertype"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List providerType= await pyroFetesDbContext.ProviderTypes.Select(x => new GetProviderTypeDto() + { + Id = x.Id, + Label = x.Label, + }).ToListAsync(ct); + + await Send.OkAsync(providerType, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs new file mode 100644 index 0000000..79a01f1 --- /dev/null +++ b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ProviderType.Request; +using PyroFetes.DTO.ProviderType.Response; + +namespace PyroFetes.Endpoints.ProviderType; + +public class GetProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/providertype/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderTypeRequest req, CancellationToken ct) + { + Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProviderType == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetProviderTypeDto dto = new() + { + Id = databaseProviderType.Id, + Label = databaseProviderType.Label, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs new file mode 100644 index 0000000..ce0fb83 --- /dev/null +++ b/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ProviderType.Request; +using PyroFetes.DTO.ProviderType.Response; + +namespace PyroFetes.Endpoints.ProviderType; + +public class UpdateProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/providertypes/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateProviderTypeDto req, CancellationToken ct) + { + Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseProviderType == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseProviderType.Label = req.Label; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetProviderTypeDto dto = new() + { + Id = databaseProviderType.Id, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file From 6908112755c7ef020f8276bb4eadb9b40d27cea7 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 16:42:15 +0100 Subject: [PATCH 06/17] customer type + communication added --- .../DeleteCommunicationEndpoint.cs | 2 +- .../GetAllCommunicationsEndpoint.cs | 27 ++++++++++++ .../Communication/GetCommunicationEndpoint.cs | 34 +++++++++------ .../UpdateCommunicationEndpoint.cs | 43 +++++++++++++++++++ .../Customer/CreateCustomerEndpoint.cs | 2 +- .../Customer/DeleteCustomerEndpoint.cs | 2 +- .../Customer/GetAllCustomerEndpoint.cs | 2 +- .../Endpoints/Customer/GetCustomerEndpoint.cs | 2 +- .../Customer/UpdateCustomerEndpoint.cs | 2 +- .../CreateCustomerTypeEndpoint.cs | 2 +- .../DeleteCustomerTypeEndpoint.cs | 2 +- .../GetAllCustomerTypeEndpoint.cs | 2 +- .../CustomerType/GetCustomerTypeEndpoint.cs | 2 +- .../CustomerType/UpdateCustomerEndpoint.cs | 2 +- 14 files changed, 102 insertions(+), 24 deletions(-) create mode 100644 PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs create mode 100644 PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs diff --git a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs index 5c1eb67..7cac0f3 100644 --- a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -5,7 +5,7 @@ using PyroFetes.DTO.Communication.Response; namespace PyroFetes.Endpoints.Communication; -public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { diff --git a/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs new file mode 100644 index 0000000..6ff4e27 --- /dev/null +++ b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs @@ -0,0 +1,27 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Communication.Response; + +namespace PyroFetes.Endpoints.Communication; + +public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/communications"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto() + { + Id = x.Id, + Calling = x.Calling, + Email = x.Email, + Meeting = x.Meeting, + }).ToListAsync(ct); + + await Send.OkAsync(communications, ct); + } +} diff --git a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs index 18a8fc0..e860621 100644 --- a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs @@ -1,28 +1,36 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.Availability.Response; +using PyroFetes.DTO.Communication.Request; using PyroFetes.DTO.Communication.Response; namespace PyroFetes.Endpoints.Communication; -public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { - Get ("/api/communications"); + Get ("/api/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } - public override async Task HandleAsync(CancellationToken ct) + public override async Task HandleAsync(GetCommunicationRequest database, CancellationToken ct) { - List communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto() - { - Id = x.Id, - Calling = x.Calling, - Email = x.Email, - Meeting = x.Meeting, - }).ToListAsync(ct); + Models.Communication? databaseCommunications = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct); - await Send.OkAsync(communications, ct); + if (databaseCommunications == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetCommunicationDto dto = new() + { + Id = databaseCommunications.Id, + Calling = databaseCommunications.Calling, + Email = databaseCommunications.Email, + Meeting = databaseCommunications.Meeting + }; + + await Send.OkAsync(dto, ct); } -} +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs new file mode 100644 index 0000000..f44731f --- /dev/null +++ b/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs @@ -0,0 +1,43 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Communication.Request; +using PyroFetes.DTO.Communication.Response; + +namespace PyroFetes.Endpoints.Communication; + +public class UpdateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/communications/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateCommunicationDto req, CancellationToken ct) + { + Models.Communication? databaseCommunication = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseCommunication == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseCommunication.Calling = req.Calling; + databaseCommunication.Email = req.Email; + databaseCommunication.Meeting = req.Meeting; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCommunicationDto dto = new() + { + Id = databaseCommunication.Id, + Calling = req.Calling, + Email = req.Email, + Meeting = req.Meeting, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs index 3b51b5b..6bce1f4 100644 --- a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/api/customer"); + Post("/api/customers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs index a812115..703ee11 100644 --- a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/api/customer/{@Id}", x => new { x.Id }); + Delete ("/api/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs index d96f3dc..be9ea63 100644 --- a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Get ("/api/customer"); + Get ("/api/customers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs index be1d2e0..30bd36f 100644 --- a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/api/customer/{@Id}", x => new { x.Id }); + Get ("/api/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs index 4f4c22b..0ea7848 100644 --- a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint new { x.Id }); + Put ("/api/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs index b0d00d7..8be7f1e 100644 --- a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/customertype"); + Post("/api/customertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs index 820271d..9849ad2 100644 --- a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/customertype/{@Id}", x => new { x.Id }); + Delete ("/api/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs index 5dba9e7..e78b1bd 100644 --- a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/customertype"); + Get ("/api/customertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs index e5047f4..25648d1 100644 --- a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/customertype/{@Id}", x => new { x.Id }); + Get ("/api/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs index 981953f..53f1741 100644 --- a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/customertype/{@Id}", x => new { x.Id }); + Put ("/api/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } From 0cc0eeb43933115670adc592fa86b54b840497ae Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 16:43:16 +0100 Subject: [PATCH 07/17] 2nd update provider type --- PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs index 79a01f1..783771c 100644 --- a/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/providertype/{@Id}", x => new { x.Id }); + Get ("/api/providertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } From 2b4b2b50df26073be78ec7c62beeed0ec2103961 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 16:53:00 +0100 Subject: [PATCH 08/17] routes updated --- PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs | 2 +- PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs | 2 +- .../Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs | 2 +- PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs | 2 +- PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs | 2 +- .../Endpoints/Communication/CreateCommunicationEndpoint.cs | 2 +- .../Endpoints/Communication/DeleteCommunicationEndpoint.cs | 2 +- .../Endpoints/Communication/GetAllCommunicationsEndpoint.cs | 2 +- PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs | 2 +- .../Endpoints/Communication/UpdateCommunicationEndpoint.cs | 2 +- PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs | 2 +- PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs | 2 +- PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs | 2 +- PyroFetes/Endpoints/Contact/GetContactEndpoint.cs | 2 +- PyroFetes/Endpoints/Contact/UpdateContactRequest.cs | 2 +- PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs | 2 +- PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs | 2 +- PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs | 2 +- PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs | 2 +- PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs | 2 +- PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs | 2 +- .../Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs | 2 +- .../Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs | 2 +- .../Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs | 2 +- .../Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs | 2 +- .../Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs | 2 +- .../HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs | 2 +- .../HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs | 2 +- .../HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs | 2 +- .../Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs | 2 +- .../HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs | 2 +- PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs | 2 +- PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs | 2 +- PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs | 2 +- PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs | 2 +- PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs | 2 +- PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs | 2 +- PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs | 2 +- PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs | 2 +- PyroFetes/Program.cs | 2 +- 51 files changed, 51 insertions(+), 51 deletions(-) diff --git a/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs index 73a41b8..3ab763c 100644 --- a/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs +++ b/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs @@ -8,7 +8,7 @@ public class CreateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/availabilities"); + Post("/availabilities"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs index 17ce63b..0786de7 100644 --- a/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs +++ b/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/availabilities/{@Id}", x => new { x.Id }); + Delete ("/availabilities/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs b/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs index ce2a7eb..48d7007 100644 --- a/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs +++ b/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllAvailabilityxuest(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/availabilities"); + Get ("/availabilities"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs index d0bf0b0..ab37496 100644 --- a/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs +++ b/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs @@ -9,7 +9,7 @@ public class GetAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/availabilities/{@Id}", x => new { x.Id }); + Get ("/availabilities/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs index 7386014..78d2b16 100644 --- a/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs +++ b/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Put ("/api/availabilities/{@Id}", x => new { x.Id }); + Put ("/availabilities/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs index 3429d20..052c400 100644 --- a/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Post("/api/communications"); + Post("/communications"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs index 7cac0f3..99f66b9 100644 --- a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Delete ("/api/communications/{@Id}", x => new { x.Id }); + Delete ("/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs index 6ff4e27..a9b6d30 100644 --- a/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/api/communications"); + Get ("/communications"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs index e860621..728370f 100644 --- a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs @@ -9,7 +9,7 @@ public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : E { public override void Configure() { - Get ("/api/communications/{@Id}", x => new { x.Id }); + Get ("/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs index f44731f..8fcbc13 100644 --- a/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/UpdateCommunicationEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Put ("/api/communications/{@Id}", x => new { x.Id }); + Put ("/communications/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs index e0a65fc..7710266 100644 --- a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs @@ -8,7 +8,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp { public override void Configure() { - Post("/api/contacts"); + Post("/contacts"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs index 530417d..1f561d6 100644 --- a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp { public override void Configure() { - Delete ("/api/contacts/{@Id}", x => new { x.Id }); + Delete ("/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs index e7339d9..acf0739 100644 --- a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Get ("/api/contacts"); + Get ("/contacts"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs b/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs index 04a4e5e..97f3014 100644 --- a/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs @@ -9,7 +9,7 @@ public class GetContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Get ("/api/contacts/{@Id}", x => new { x.Id }); + Get ("/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs b/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs index 8fec9d1..a57948b 100644 --- a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs +++ b/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs @@ -9,7 +9,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo { public override void Configure() { - Put ("/api/contacts/{@Id}", x => new { x.Id }); + Put ("/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs index 6bce1f4..c2d88ee 100644 --- a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/api/customers"); + Post("/customers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs index 703ee11..997ceb7 100644 --- a/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/DeleteCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/api/customers/{@Id}", x => new { x.Id }); + Delete ("/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs index be9ea63..0d79b76 100644 --- a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Get ("/api/customers"); + Get ("/customers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs index 30bd36f..a1cbda2 100644 --- a/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/api/customers/{@Id}", x => new { x.Id }); + Get ("/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs index 0ea7848..4b2ba99 100644 --- a/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomer(PyroFetesDbContext pyroFetesDbContext) : Endpoint new { x.Id }); + Put ("/customers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs index 8be7f1e..dbe9aa1 100644 --- a/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/CreateCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class CreateCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/customertypes"); + Post("/customertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs index 9849ad2..49da728 100644 --- a/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/customertypes/{@Id}", x => new { x.Id }); + Delete ("/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs index e78b1bd..7a0e931 100644 --- a/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetAllCustomerTypeEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/customertypes"); + Get ("/customertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs index 25648d1..87026e5 100644 --- a/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/GetCustomerTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/customertypes/{@Id}", x => new { x.Id }); + Get ("/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs index 53f1741..446a9bd 100644 --- a/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/CustomerType/UpdateCustomerEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateCustomerType(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/customertypes/{@Id}", x => new { x.Id }); + Put ("/customertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs index a87fc05..dca8ade 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Post("/api/experiencelevels"); + Post("/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs index 8f0190f..a51ff5d 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Delete ("/api/experiencelevels/{@Id}", x => new { x.Id }); + Delete ("/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs index f51e754..29a6f3a 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex { public override void Configure() { - Get ("/api/experiencelevels"); + Get ("/experiencelevels"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs index aca625a..5d6630b 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Get ("/api/experiencelevels/{@Id}", x => new { x.Id }); + Get ("/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs index 932b878..0158e0c 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Put ("/api/experiencelevels/{@Id}", x => new { x.Id }); + Put ("/experiencelevels/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs index f2a845d..59a98b9 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Post("/api/historyofapprovals"); + Post("/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs index 7cc5fa7..8206ba9 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Delete ("/api/historyofapprovals/{@Id}", x => new { x.Id }); + Delete ("/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs index 843d200..f86f6a0 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Get ("/api/historyofapprovals"); + Get ("/historyofapprovals"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs index d00bc12..2e5107d 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/api/historyofapprovals/{@Id}", x => new { x.Id }); + Get ("/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs index 3d37d7c..6ef9ca0 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Put ("/api/historyofapprovals/{@Id}", x => new { x.Id }); + Put ("/historyofapprovals/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs index f7f3e99..316fede 100644 --- a/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs @@ -8,7 +8,7 @@ public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/api/providers"); + Post("/providers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs index 7668675..d5648d4 100644 --- a/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/api/providers/{@Id}", x => new { x.Id }); + Delete ("/providers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs index 0ab3848..21275c1 100644 --- a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/providers"); + Get ("/providers"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs index ecad2f8..ae46248 100644 --- a/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs @@ -9,7 +9,7 @@ public class GetProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/api/providers/{@Id}", x => new { x.Id }); + Get ("/providers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs index 9b425a9..f7de9fc 100644 --- a/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Put ("/api/providers/{@Id}", x => new { x.Id }); + Put ("/providers/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs index a82ae38..1e92cc2 100644 --- a/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs @@ -8,7 +8,7 @@ public class CreateProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Post("/api/providertypes"); + Post("/providertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs index c075a21..4f05db7 100644 --- a/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/DeleteProviderTypeEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Delete ("/api/providertypes/{@Id}", x => new { x.Id }); + Delete ("/providertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs index 61f454e..9eef2e3 100644 --- a/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllProviderTypesEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/api/providertype"); + Get ("/providertype"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs index 783771c..4c93387 100644 --- a/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/GetProviderTypeEndpoint.cs @@ -9,7 +9,7 @@ public class GetProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/api/providertypes/{@Id}", x => new { x.Id }); + Get ("/providertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs index ce0fb83..af596f8 100644 --- a/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/UpdateProviderTypeEndpoint.cs @@ -9,7 +9,7 @@ public class UpdateProviderTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : { public override void Configure() { - Put ("/api/providertypes/{@Id}", x => new { x.Id }); + Put ("/providertypes/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs index bdaec96..b3b3e45 100644 --- a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs @@ -8,7 +8,7 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Post("/api/staffs"); + Post("/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs index b57e85d..4cc5f35 100644 --- a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs @@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Delete ("/api/staffs/{@Id}", x => new { x.Id }); + Delete ("/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs index e06c013..67c0a36 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo { public override void Configure() { - Get ("/api/staffs"); + Get ("/staffs"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs index 2f208e3..1f57b83 100644 --- a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs @@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { - Get ("/api/staffs/{@Id}", x => new { x.Id }); + Get ("/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs index a17012e..1e6701d 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs @@ -9,7 +9,7 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin { public override void Configure() { - Put ("/api/staffs/{@Id}", x => new { x.Id }); + Put ("/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index 03ac2b2..213d784 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -19,7 +19,7 @@ builder.Services.AddCors(options => { options.AddDefaultPolicy(policyBuilder => { policyBuilder - .WithOrigins("http://localhost:4200") + .WithOrigins("http://localhost:5298") .WithMethods("GET", "POST", "PUT", "PATCH", "DELETE") .AllowAnyHeader(); }); From 0beb5f344676f8dc6aba7f4331131755058c7898 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 4 Dec 2025 17:45:06 +0100 Subject: [PATCH 09/17] contact updated --- .../DTO/Contact/Request/CreateContactDto.cs | 2 ++ .../DTO/Contact/Request/UpdateContactDto.cs | 2 ++ .../DTO/Contact/Response/GetContactDto.cs | 2 ++ .../DTO/Customer/Request/CreateCustomerDto.cs | 1 + .../DTO/Customer/Response/GetCustomerDto.cs | 2 ++ .../Contact/CreateContactEndpoint.cs | 14 ++++++++++++++ .../Customer/CreateCustomerEndpoint.cs | 19 ++++++++++++++++--- PyroFetes/Models/ContactCustomer.cs | 14 ++++++++++++++ 8 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 PyroFetes/Models/ContactCustomer.cs diff --git a/PyroFetes/DTO/Contact/Request/CreateContactDto.cs b/PyroFetes/DTO/Contact/Request/CreateContactDto.cs index f52343d..d163b2c 100644 --- a/PyroFetes/DTO/Contact/Request/CreateContactDto.cs +++ b/PyroFetes/DTO/Contact/Request/CreateContactDto.cs @@ -7,5 +7,7 @@ public class CreateContactDto public string? PhoneNumber { get; set; } public string? Email { get; set; } public string? Address { get; set; } + public string? City { get; set; } public string? Role { get; set; } + public int? CustomerId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs b/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs index 42ffd3d..500b3ea 100644 --- a/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs +++ b/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs @@ -8,5 +8,7 @@ public class UpdateContactDto public string? PhoneNumber { get; set; } public string? Email { get; set; } public string? Address { get; set; } + public string? City { get; set; } public string? Role { get; set; } + public int? CustomerTypeId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Response/GetContactDto.cs b/PyroFetes/DTO/Contact/Response/GetContactDto.cs index 38a25d8..c8e2cb9 100644 --- a/PyroFetes/DTO/Contact/Response/GetContactDto.cs +++ b/PyroFetes/DTO/Contact/Response/GetContactDto.cs @@ -8,5 +8,7 @@ public class GetContactDto public string? PhoneNumber { get; set; } public string? Email { get; set; } public string? Address { get; set; } + public string? City { get; set; } public string? Role { get; set; } + public int? CustomerId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs b/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs index 6a90c75..6627c54 100644 --- a/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs +++ b/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs @@ -3,4 +3,5 @@ namespace PyroFetes.DTO.Customer.Request; public class CreateCustomerDto { public string? Note { get; set; } + public int CustomerTypeId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs index 53a00c5..54fb346 100644 --- a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs +++ b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs @@ -4,4 +4,6 @@ public class GetCustomerDto { public int Id { get; set; } public string? Note { get; set; } + + public int CustomerTypeId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs index 7710266..768cb2f 100644 --- a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs @@ -1,4 +1,5 @@ using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Contact.Request; using PyroFetes.DTO.Contact.Response; @@ -15,6 +16,15 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp public override async Task HandleAsync(CreateContactDto req, CancellationToken ct) { + Models.Customer? databaseCustomer = await pyroFetesDbContext.Customers.SingleOrDefaultAsync(x => x.Id == req.CustomerId, cancellationToken: ct); + + if (databaseCustomer == null) + { + await Send.NotFoundAsync(ct); + Console.WriteLine("Customer not found"); + return; + } + Models.Contact contact = new() { LastName = req.LastName, @@ -22,7 +32,9 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp PhoneNumber = req.PhoneNumber, Email = req.Email, Address = req.Address, + City = req.City, Role = req.Role, + CustomerId = databaseCustomer.Id, }; pyroFetesDbContext.Add(contact); await pyroFetesDbContext.SaveChangesAsync(ct); @@ -34,7 +46,9 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp PhoneNumber = contact.PhoneNumber, Email = contact.Email, Address = contact.Address, + City = contact.City, Role = contact.Role, + CustomerId = contact.CustomerId, }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs index c2d88ee..c454f85 100644 --- a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -1,4 +1,5 @@ using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Customer.Request; using PyroFetes.DTO.Customer.Response; @@ -15,9 +16,20 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End public override async Task HandleAsync(CreateCustomerDto req, CancellationToken ct) { - var customer = new Models.Customer + Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.CustomerTypeId, cancellationToken: ct); + + if (databaseCustomerType == null) { - Note = req.Note + await Send.NotFoundAsync(ct); + Console.WriteLine("Customer Type not found"); + return; + } + + Models.Customer customer = new() + { + Note = req.Note, + CustomerTypeId = databaseCustomerType.Id, + }; pyroFetesDbContext.Add(customer); await pyroFetesDbContext.SaveChangesAsync(ct); @@ -25,7 +37,8 @@ public class CreateCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End GetCustomerDto response = new GetCustomerDto() { Id = customer.Id, - Note = customer.Note + Note = customer.Note, + CustomerTypeId = customer.CustomerTypeId }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Models/ContactCustomer.cs b/PyroFetes/Models/ContactCustomer.cs new file mode 100644 index 0000000..9d110d3 --- /dev/null +++ b/PyroFetes/Models/ContactCustomer.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.EntityFrameworkCore; + +namespace PyroFetes.Models; + +[PrimaryKey(nameof(ContactId), nameof(CustomerId))] +public class ContactCustomer +{ + [Required] public int ContactId { get; set; } + [Required] public int CustomerId { get; set; } + + public Contact? Contact { get; set; } + public Customer? Customer { get; set; } +} \ No newline at end of file From cea2c8cf470fe88d01ec8adf40916f4ef3f8ddde Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 11 Dec 2025 14:31:57 +0100 Subject: [PATCH 10/17] correcting CORS error --- PyroFetes/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index 213d784..03ac2b2 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -19,7 +19,7 @@ builder.Services.AddCors(options => { options.AddDefaultPolicy(policyBuilder => { policyBuilder - .WithOrigins("http://localhost:5298") + .WithOrigins("http://localhost:4200") .WithMethods("GET", "POST", "PUT", "PATCH", "DELETE") .AllowAnyHeader(); }); From 7da7c26a2e77fb78f8706ad534f483270c15ec87 Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Tue, 2 Jun 2026 18:11:55 +0200 Subject: [PATCH 11/17] modifs mineures --- PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs | 2 +- .../{UpdateContactRequest.cs => UpdateContactEndpoint.cs} | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) rename PyroFetes/Endpoints/Contact/{UpdateContactRequest.cs => UpdateContactEndpoint.cs} (88%) diff --git a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs index acf0739..b92d37b 100644 --- a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs @@ -4,7 +4,7 @@ using PyroFetes.DTO.Contact.Response; namespace PyroFetes.Endpoints.Contact; -public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +public class GetAllContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> { public override void Configure() { diff --git a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs b/PyroFetes/Endpoints/Contact/UpdateContactEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/Contact/UpdateContactRequest.cs rename to PyroFetes/Endpoints/Contact/UpdateContactEndpoint.cs index a57948b..cea7654 100644 --- a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs +++ b/PyroFetes/Endpoints/Contact/UpdateContactEndpoint.cs @@ -5,7 +5,7 @@ using PyroFetes.DTO.Contact.Response; namespace PyroFetes.Endpoints.Contact; -public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { @@ -29,6 +29,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo databaseContact.PhoneNumber = req.PhoneNumber; databaseContact.Email = req.Email; databaseContact.Address = req.Address; + databaseContact.City = req.City; databaseContact.Role = req.Role; } await pyroFetesDbContext.SaveChangesAsync(ct); @@ -41,6 +42,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo PhoneNumber = req.PhoneNumber, Email = req.Email, Address = req.Address, + City = req.City, Role = req.Role, }; From af215916699c0818f170a7d3ec6f5544e56b18dd Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Sun, 7 Jun 2026 19:06:45 +0200 Subject: [PATCH 12/17] Modifs de noms et providers --- .../DTO/Provider/Request/CreateProviderDto.cs | 1 + .../DTO/Provider/Response/GetProviderDto.cs | 2 ++ PyroFetes/DTO/Staff/Request/CreateStaffDto.cs | 4 ++++ PyroFetes/DTO/Staff/Response/GetStaffDto.cs | 4 ++++ .../Provider/CreateProviderEndpoint.cs | 20 +++++++++++++++---- .../Provider/DeleteProviderEndpoint.cs | 6 +++--- .../Provider/GetAllProvidersEndpoint.cs | 7 ++++--- .../Endpoints/Provider/GetProviderEndpoint.cs | 4 ++-- .../Provider/UpdateProviderEndpoint.cs | 4 ++-- .../GetAllProviderTypesEndpoint.cs | 2 +- .../Endpoints/Staff/CreateStaffEndpoint.cs | 8 ++++++++ .../Endpoints/Staff/GetAllStaffsEndpoint.cs | 4 ++++ PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs | 4 ++++ .../Endpoints/Staff/UpdateStaffRequest.cs | 4 ++++ PyroFetes/PyroFetesDbContext.cs | 2 +- 15 files changed, 60 insertions(+), 16 deletions(-) diff --git a/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs index ea0df6a..7919e85 100644 --- a/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs +++ b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs @@ -3,4 +3,5 @@ namespace PyroFetes.DTO.Provider.Request; public class CreateProviderDto { public decimal Price { get; set; } + public int ProviderTypeId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs index 99eeab0..1df8137 100644 --- a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs +++ b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs @@ -4,4 +4,6 @@ public class GetProviderDto { public int Id { get; set; } public decimal Price { get; set; } + + public int ProviderTypeId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs index 63e33ad..4f82c36 100644 --- a/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs +++ b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs @@ -2,6 +2,10 @@ namespace PyroFetes.DTO.Staff.Request; public class CreateStaffDto { + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string? Profession { get; set; } + public string? Email { get; set; } public string? F4T2NumberApproval { get; set; } public DateOnly F4T2ExpirationDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs index ae10f74..fbf1108 100644 --- a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs +++ b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs @@ -3,6 +3,10 @@ namespace PyroFetes.DTO.Staff.Response; public class GetStaffDto { public int Id { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string? Profession { get; set; } + public string? Email { get; set; } public string? F4T2NumberApproval { get; set; } public DateOnly F4T2ExpirationDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs index 316fede..f60029b 100644 --- a/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs @@ -1,4 +1,5 @@ using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Provider.Request; using PyroFetes.DTO.Provider.Response; @@ -8,16 +9,26 @@ public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Post("/providers"); + Post("/serviceproviders"); AllowAnonymous(); } public override async Task HandleAsync(CreateProviderDto req, CancellationToken ct) { - var provider = new Models.ServiceProvider() + Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.ProviderTypeId, cancellationToken: ct); + + if (databaseProviderType == null) { - Price = req.Price + await Send.NotFoundAsync(ct); + Console.WriteLine("Customer Type not found"); + return; + } + + Models.ServiceProvider provider = new() + { + Price = req.Price, + ProviderTypeId = req.ProviderTypeId }; pyroFetesDbContext.Add(provider); await pyroFetesDbContext.SaveChangesAsync(ct); @@ -25,7 +36,8 @@ public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End GetProviderDto response = new GetProviderDto() { Id = provider.Id, - Price = provider.Price + Price = provider.Price, + ProviderTypeId = provider.ProviderTypeId }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs index d5648d4..521ff74 100644 --- a/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/DeleteProviderEndpoint.cs @@ -9,20 +9,20 @@ public class DeleteProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Delete ("/providers/{@Id}", x => new { x.Id }); + Delete ("/serviceproviders/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct) { - Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.ServiceProviders.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); if (databaseProvider == null) { await Send.NotFoundAsync(ct); return; } - pyroFetesDbContext.Providers.Remove(databaseProvider); + pyroFetesDbContext.ServiceProviders.Remove(databaseProvider); await pyroFetesDbContext.SaveChangesAsync(ct); await Send.NoContentAsync(ct); diff --git a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs index 21275c1..fcafa10 100644 --- a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs @@ -8,18 +8,19 @@ public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : En { public override void Configure() { - Get ("/providers"); + Get ("/serviceproviders"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { - List customer= await pyroFetesDbContext.Providers.Select(x => new GetProviderDto() + List provider= await pyroFetesDbContext.ServiceProviders.Select(x => new GetProviderDto() { Id = x.Id, Price = x.Price, + ProviderTypeId = x.ProviderTypeId, }).ToListAsync(ct); - await Send.OkAsync(customer, ct); + await Send.OkAsync(provider, ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs index ae46248..df07a06 100644 --- a/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/GetProviderEndpoint.cs @@ -9,13 +9,13 @@ public class GetProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { public override void Configure() { - Get ("/providers/{@Id}", x => new { x.Id }); + Get ("/serviceproviders/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct) { - Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.ServiceProviders.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); if (databaseProvider == null) { diff --git a/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs index f7de9fc..8b567fb 100644 --- a/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/UpdateProviderEndpoint.cs @@ -9,13 +9,13 @@ public class UpdateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End { public override void Configure() { - Put ("/providers/{@Id}", x => new { x.Id }); + Put ("/serviceproviders/{@Id}", x => new { x.Id }); AllowAnonymous(); } public override async Task HandleAsync(UpdateProviderDto req, CancellationToken ct) { - Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.ServiceProviders.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); if (databaseProvider == null) { diff --git a/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs index 9eef2e3..610ccce 100644 --- a/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs +++ b/PyroFetes/Endpoints/ProviderType/GetAllProviderTypesEndpoint.cs @@ -8,7 +8,7 @@ public class GetAllProviderTypesEndpoint(PyroFetesDbContext pyroFetesDbContext) { public override void Configure() { - Get ("/providertype"); + Get ("/providertypes"); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs index b3b3e45..a975d2c 100644 --- a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs @@ -17,6 +17,10 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi { Models.Staff staff = new() { + FirstName = req.FirstName, + LastName = req.LastName, + Profession = req.Profession, + Email = req.Email, F4T2NumberApproval = req.F4T2NumberApproval, F4T2ExpirationDate = req.F4T2ExpirationDate, }; @@ -25,6 +29,10 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi GetStaffDto response = new() { + FirstName = staff.FirstName, + LastName = staff.LastName, + Profession = staff.Profession, + Email = staff.Email, F4T2NumberApproval = staff.F4T2NumberApproval, F4T2ExpirationDate = staff.F4T2ExpirationDate, }; diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs index 67c0a36..166792f 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -17,6 +17,10 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo List staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto() { Id = x.Id, + FirstName = x.FirstName, + LastName = x.LastName, + Profession = x.Profession, + Email = x.Email, F4T2NumberApproval = x.F4T2NumberApproval, F4T2ExpirationDate = x.F4T2ExpirationDate, diff --git a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs index 1f57b83..24d299b 100644 --- a/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs @@ -26,6 +26,10 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint GetStaffDto dto = new() { Id = databaseStaff.Id, + FirstName = databaseStaff.FirstName, + LastName = databaseStaff.LastName, + Profession = databaseStaff.Profession, + Email = databaseStaff.Email, F4T2NumberApproval = databaseStaff.F4T2NumberApproval, F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate, }; diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs index 1e6701d..a794fb6 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs @@ -32,6 +32,10 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin GetStaffDto dto = new() { Id = databaseStaff.Id, + FirstName = databaseStaff.FirstName, + LastName = databaseStaff.LastName, + Profession = databaseStaff.Profession, + Email = databaseStaff.Email, F4T2NumberApproval = req.F4T2NumberApproval, F4T2ExpirationDate = req.F4T2ExpirationDate, }; diff --git a/PyroFetes/PyroFetesDbContext.cs b/PyroFetes/PyroFetesDbContext.cs index b5ce8c7..02fcaac 100644 --- a/PyroFetes/PyroFetesDbContext.cs +++ b/PyroFetes/PyroFetesDbContext.cs @@ -28,7 +28,7 @@ public class PyroFetesDbContext : DbContext public DbSet ProductColors { get; set; } public DbSet ProductDeliveries { get; set; } public DbSet ProductEffects { get; set; } - public DbSet Providers { get; set; } + public DbSet ServiceProviders { get; set; } public DbSet ProviderContacts { get; set; } public DbSet ProviderTypes { get; set; } public DbSet PurchaseOrders { get; set; } From 57adafae16743c703ff4e0d4f8446c0276c595e4 Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Mon, 8 Jun 2026 14:31:27 +0200 Subject: [PATCH 13/17] Renommage d'un endpoint --- .../Staff/{UpdateStaffRequest.cs => UpdateStaffEndpoint.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename PyroFetes/Endpoints/Staff/{UpdateStaffRequest.cs => UpdateStaffEndpoint.cs} (92%) diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs similarity index 92% rename from PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs rename to PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs index a794fb6..82b7d95 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs @@ -5,7 +5,7 @@ using FastEndpoints; namespace PyroFetes.Endpoints.Staff; -public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { From 7071910dc4e3b053bcfcfc2478270f8e039c01f9 Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Mon, 8 Jun 2026 16:02:06 +0200 Subject: [PATCH 14/17] Modifs de nom --- .../Endpoints/Communication/DeleteCommunicationEndpoint.cs | 3 ++- PyroFetes/Models/Communication.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs index 99f66b9..ce1055e 100644 --- a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -1,11 +1,12 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Communication.Request; using PyroFetes.DTO.Communication.Response; namespace PyroFetes.Endpoints.Communication; -public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { diff --git a/PyroFetes/Models/Communication.cs b/PyroFetes/Models/Communication.cs index a3dd0d2..61b002b 100644 --- a/PyroFetes/Models/Communication.cs +++ b/PyroFetes/Models/Communication.cs @@ -5,9 +5,9 @@ namespace PyroFetes.Models; public class Communication { [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; } + [MaxLength(100)] public string? Calling { get; set; } + [MaxLength(100)] public string? Email { get; set; } + [MaxLength(300)] public string? Meeting { get; set; } [Required] public int ContactId { get; set; } public Contact? Contact { get; set; } From a88ce4cc7e38208bba0e1eb7bdb195b7abb5e5e5 Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Tue, 9 Jun 2026 13:29:58 +0200 Subject: [PATCH 15/17] Modifs communication --- .../Request/CreateCommunicationDto.cs | 1 + .../Communication/Response/GetCommunicationDto.cs | 7 +++++++ .../Communication/CreateCommunicationEndpoint.cs | 14 ++++++++++---- .../Communication/GetAllCommunicationsEndpoint.cs | 7 ++++++- .../Endpoints/Contact/CreateContactEndpoint.cs | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs index 47fa206..dfc7dde 100644 --- a/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs +++ b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs @@ -5,4 +5,5 @@ public class CreateCommunicationDto public string? Calling { get; set; } public string? Email { get; set; } public string? Meeting { get; set; } + public int ContactId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs b/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs index ea0432d..9faf06c 100644 --- a/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs +++ b/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs @@ -6,4 +6,11 @@ public class GetCommunicationDto public string? Calling { get; set; } public string? Email { get; set; } public string? Meeting { get; set; } + + public int ContactId { get; set; } + + public string? ContactFirstName { get; set; } + public string? ContactLastName { get; set; } + public string? ContactEmail { get; set; } + public string? ContactPhoneNumber { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs index 052c400..744ab77 100644 --- a/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs @@ -19,16 +19,22 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) { Calling = req.Calling, Email = req.Email, - Meeting = req.Meeting + Meeting = req.Meeting, + ContactId = req.ContactId }; pyroFetesDbContext.Add(communication); await pyroFetesDbContext.SaveChangesAsync(ct); GetCommunicationDto response = new() { - Calling = req.Calling, - Email = req.Email, - Meeting = req.Meeting + Calling = communication.Calling, + Email = communication.Email, + Meeting = communication.Meeting, + ContactId = communication.ContactId, + ContactFirstName = communication.Contact?.FirstName, + ContactLastName = communication.Contact?.LastName, + ContactEmail = communication.Contact?.Email, + ContactPhoneNumber = communication.Contact?.PhoneNumber, }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs index a9b6d30..c1544fe 100644 --- a/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs @@ -14,12 +14,17 @@ public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext) public override async Task HandleAsync(CancellationToken ct) { - List communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto() + List communications = await pyroFetesDbContext.Communications.Include(x => x.Contact).Select(x => new GetCommunicationDto() { Id = x.Id, Calling = x.Calling, Email = x.Email, Meeting = x.Meeting, + ContactId = x.ContactId, + ContactFirstName = x.Contact.FirstName, + ContactLastName = x.Contact.LastName, + ContactPhoneNumber = x.Contact.PhoneNumber, + ContactEmail = x.Contact.Email, }).ToListAsync(ct); await Send.OkAsync(communications, ct); diff --git a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs index 768cb2f..a2dd49b 100644 --- a/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs @@ -48,7 +48,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp Address = contact.Address, City = contact.City, Role = contact.Role, - CustomerId = contact.CustomerId, + CustomerId = databaseCustomer.Id, }; await Send.OkAsync(response, ct); From 35c99928ad17bbbbf77f4c4c6047c4f7f5354cb9 Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Wed, 10 Jun 2026 21:43:38 +0200 Subject: [PATCH 16/17] =?UTF-8?q?customer=20type=20affich=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyroFetes/DTO/Customer/Response/GetCustomerDto.cs | 2 ++ PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs index 54fb346..91021b4 100644 --- a/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs +++ b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs @@ -6,4 +6,6 @@ public class GetCustomerDto public string? Note { get; set; } public int CustomerTypeId { get; set; } + + public string? CustomerType { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs index 0d79b76..d3337ed 100644 --- a/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -14,10 +14,11 @@ public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : End public override async Task HandleAsync(CancellationToken ct) { - List customer= await pyroFetesDbContext.Customers.Select(x => new GetCustomerDto() + List customer= await pyroFetesDbContext.Customers.Include(x => x.CustomerType).Select(x => new GetCustomerDto() { Id = x.Id, Note = x.Note, + CustomerType = x.CustomerType.Label, }).ToListAsync(ct); await Send.OkAsync(customer, ct); From 5d16138ed887dba9de523f77f84c85163c592f6f Mon Sep 17 00:00:00 2001 From: MathieuCarteron Date: Thu, 11 Jun 2026 11:06:31 +0200 Subject: [PATCH 17/17] Ajout du niveau d'experience --- .../Request/CreateExperienceLevelDto.cs | 1 + .../Response/GetExperienceLevelDto.cs | 2 + .../Request/CreateHistoryOfApprovalDto.cs | 1 + .../Response/GetHistoryOfApprovalDto.cs | 2 + .../DTO/Provider/Response/GetProviderDto.cs | 2 + PyroFetes/DTO/Staff/Response/GetStaffDto.cs | 2 + .../CreateExperienceLevelEndpoint.cs | 15 +- .../CreateHistoryOfApprovalEndpoint.cs | 17 +- .../GetAllHistoryOfApprovalEndpoint.cs | 1 + .../Provider/GetAllProvidersEndpoint.cs | 3 +- .../Endpoints/Staff/GetAllStaffsEndpoint.cs | 29 +- .../Migrations/20260611085600_HOA.Designer.cs | 1953 +++++++++++++++++ PyroFetes/Migrations/20260611085600_HOA.cs | 246 +++ .../PyroFetesDbContextModelSnapshot.cs | 18 +- PyroFetes/Models/HistoryOfApproval.cs | 2 + PyroFetes/Models/Staff.cs | 2 +- 16 files changed, 2270 insertions(+), 26 deletions(-) create mode 100644 PyroFetes/Migrations/20260611085600_HOA.Designer.cs create mode 100644 PyroFetes/Migrations/20260611085600_HOA.cs diff --git a/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs b/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs index 9e40ea6..cf1aa51 100644 --- a/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs +++ b/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs @@ -3,4 +3,5 @@ namespace PyroFetes.DTO.ExperienceLevel.Request; public class CreateExperienceLevelDto { public string? Label { get; set; } + public int? StaffId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs b/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs index 8a14d3d..483cc01 100644 --- a/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs +++ b/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs @@ -4,4 +4,6 @@ public class GetExperienceLevelDto { public int Id { get; set; } public string? Label { get; set; } + + public int? StaffId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs b/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs index ba5a33e..219c8af 100644 --- a/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs +++ b/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs @@ -4,4 +4,5 @@ public class CreateHistoryOfApprovalDto { public DateOnly DeliveryDate { get; set; } public DateOnly ExpirationDate { get; set; } + public int StaffId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs b/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs index b216521..33f7637 100644 --- a/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs +++ b/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs @@ -5,4 +5,6 @@ public class GetHistoryOfApprovalDto public int Id { get; set; } public DateOnly DeliveryDate { get; set; } public DateOnly ExpirationDate { get; set; } + + public int StaffId { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs index 1df8137..2cbd8c8 100644 --- a/PyroFetes/DTO/Provider/Response/GetProviderDto.cs +++ b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs @@ -6,4 +6,6 @@ public class GetProviderDto public decimal Price { get; set; } public int ProviderTypeId { get; set; } + + public string? ProviderType { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs index fbf1108..85b83dc 100644 --- a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs +++ b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs @@ -9,4 +9,6 @@ public class GetStaffDto public string? Email { get; set; } public string? F4T2NumberApproval { get; set; } public DateOnly F4T2ExpirationDate { get; set; } + public string? ExperienceLevel { get; set; } + } \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs index dca8ade..6f83890 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs @@ -1,5 +1,6 @@ using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.ExperienceLevel.Response; using PyroFetes.DTO.ExperienceLevel.Request; @@ -15,9 +16,20 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext public override async Task HandleAsync(CreateExperienceLevelDto req, CancellationToken ct) { + Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.StaffId, cancellationToken: ct); + + if (databaseStaff == null) + { + await Send.NotFoundAsync(ct); + Console.WriteLine("Customer Type not found"); + return; + } + + Models.ExperienceLevel experienceLevel = new() { - Label = req.Label + Label = req.Label, + StaffId = databaseStaff.Id, }; pyroFetesDbContext.Add(experienceLevel); await pyroFetesDbContext.SaveChangesAsync(ct); @@ -26,6 +38,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { Id = experienceLevel.Id, Label = experienceLevel.Label, + StaffId = experienceLevel.StaffId }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs index 59a98b9..39d7b2c 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs @@ -1,4 +1,5 @@ using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.HistoryOfApproval.Request; using PyroFetes.DTO.HistoryOfApproval.Response; @@ -15,10 +16,21 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte public override async Task HandleAsync(CreateHistoryOfApprovalDto req, CancellationToken ct) { + Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.StaffId, cancellationToken: ct); + + if (databaseStaff == null) + { + await Send.NotFoundAsync(ct); + Console.WriteLine("Customer Type not found"); + return; + } + + Models.HistoryOfApproval historyOfApproval = new() { DeliveryDate = req.DeliveryDate, - ExpirationDate = req.ExpirationDate + ExpirationDate = req.ExpirationDate, + StaffId = databaseStaff.Id, }; pyroFetesDbContext.Add(historyOfApproval); await pyroFetesDbContext.SaveChangesAsync(ct); @@ -27,7 +39,8 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { Id = historyOfApproval.Id, DeliveryDate = historyOfApproval.DeliveryDate, - ExpirationDate = historyOfApproval.ExpirationDate + ExpirationDate = historyOfApproval.ExpirationDate, + StaffId = historyOfApproval.StaffId, }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs index f86f6a0..2ee4d19 100644 --- a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs @@ -19,6 +19,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte Id = x.Id, DeliveryDate = x.DeliveryDate, ExpirationDate = x.ExpirationDate, + StaffId = x.StaffId, }).ToListAsync(ct); await Send.OkAsync(historyOfApprovals, ct); diff --git a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs index fcafa10..e641bcb 100644 --- a/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs +++ b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs @@ -14,11 +14,12 @@ public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : En public override async Task HandleAsync(CancellationToken ct) { - List provider= await pyroFetesDbContext.ServiceProviders.Select(x => new GetProviderDto() + List provider= await pyroFetesDbContext.ServiceProviders.Include(x => x.ProviderType).Select(x => new GetProviderDto() { Id = x.Id, Price = x.Price, ProviderTypeId = x.ProviderTypeId, + ProviderType = x.ProviderType.Label, }).ToListAsync(ct); await Send.OkAsync(provider, ct); diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs index 166792f..f4fa5fd 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -7,25 +7,28 @@ namespace PyroFetes.Endpoints.Staff; public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> { public override void Configure() - { - Get ("/staffs"); + { + Get("/staffs"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { - List staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto() - { - Id = x.Id, - FirstName = x.FirstName, - LastName = x.LastName, - Profession = x.Profession, - Email = x.Email, - F4T2NumberApproval = x.F4T2NumberApproval, - F4T2ExpirationDate = x.F4T2ExpirationDate, - - }).ToListAsync(ct); + List staff = await pyroFetesDbContext.Staffs + .Include(x => x.ExperienceLevel) + .Select(x => new GetStaffDto() + { + Id = x.Id, + FirstName = x.FirstName, + LastName = x.LastName, + Profession = x.Profession, + Email = x.Email, + F4T2NumberApproval = x.F4T2NumberApproval, + F4T2ExpirationDate = x.F4T2ExpirationDate, + ExperienceLevel = x.ExperienceLevel.Label + }).ToListAsync(ct); await Send.OkAsync(staff, ct); } + } \ No newline at end of file diff --git a/PyroFetes/Migrations/20260611085600_HOA.Designer.cs b/PyroFetes/Migrations/20260611085600_HOA.Designer.cs new file mode 100644 index 0000000..b1d7c40 --- /dev/null +++ b/PyroFetes/Migrations/20260611085600_HOA.Designer.cs @@ -0,0 +1,1953 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PyroFetes; + +#nullable disable + +namespace PyroFetes.Migrations +{ + [DbContext(typeof(PyroFetesDbContext))] + [Migration("20260611085600_HOA")] + partial class HOA + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.20") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("PyroFetes.Models.Availability", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AvailabilityDate") + .HasColumnType("date"); + + b.Property("DeliveryDate") + .HasColumnType("date"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.Property("RenewallDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.ToTable("Availabilities"); + }); + + modelBuilder.Entity("PyroFetes.Models.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.ToTable("Brands"); + }); + + modelBuilder.Entity("PyroFetes.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("City"); + }); + + modelBuilder.Entity("PyroFetes.Models.Classification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Classifications"); + }); + + modelBuilder.Entity("PyroFetes.Models.Color", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Label") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Colors"); + }); + + modelBuilder.Entity("PyroFetes.Models.Communication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Calling") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ContactId") + .HasColumnType("int"); + + b.Property("Email") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Meeting") + .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") + .IsUnique(); + + 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.Property("StaffId") + .HasColumnType("int"); + + 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("ServiceProviders"); + }); + + modelBuilder.Entity("PyroFetes.Models.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ElectronicSignature") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("PyroFetes.Models.Show", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CityId") + .HasColumnType("int"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Place") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("nvarchar(120)"); + + b.Property("PyrotechnicImplementationPlan") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("CityId"); + + b.ToTable("Shows"); + }); + + modelBuilder.Entity("PyroFetes.Models.ShowMaterial", b => + { + b.Property("ShowId") + .HasColumnType("int"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.HasKey("ShowId", "MaterialId"); + + b.HasIndex("MaterialId"); + + b.ToTable("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") + .WithOne("ExperienceLevel") + .HasForeignKey("PyroFetes.Models.ExperienceLevel", "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("ExperienceLevel") + .IsRequired(); + + b.Navigation("ShowStaffs"); + + b.Navigation("StaffAvailabilities"); + + b.Navigation("StaffContacts"); + + b.Navigation("StaffHistoryOfApprovals"); + }); + + modelBuilder.Entity("PyroFetes.Models.Supplier", b => + { + b.Navigation("Prices"); + }); + + modelBuilder.Entity("PyroFetes.Models.Truck", b => + { + b.Navigation("ShowTrucks"); + }); + + modelBuilder.Entity("PyroFetes.Models.Warehouse", b => + { + b.Navigation("MaterialWarehouses"); + + b.Navigation("MovementsDestination"); + + b.Navigation("MovementsSource"); + + b.Navigation("WarehouseProducts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PyroFetes/Migrations/20260611085600_HOA.cs b/PyroFetes/Migrations/20260611085600_HOA.cs new file mode 100644 index 0000000..d3b88be --- /dev/null +++ b/PyroFetes/Migrations/20260611085600_HOA.cs @@ -0,0 +1,246 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PyroFetes.Migrations +{ + /// + public partial class HOA : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ContactServiceProvider_Providers_ServiceProviderId", + table: "ContactServiceProvider"); + + migrationBuilder.DropForeignKey( + name: "FK_Contract_Providers_ServiceProviderId", + table: "Contract"); + + migrationBuilder.DropForeignKey( + name: "FK_ProviderContacts_Providers_ProviderId", + table: "ProviderContacts"); + + migrationBuilder.DropForeignKey( + name: "FK_Providers_ProviderTypes_ProviderTypeId", + table: "Providers"); + + migrationBuilder.DropIndex( + name: "IX_ExperienceLevels_StaffId", + table: "ExperienceLevels"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Providers", + table: "Providers"); + + migrationBuilder.RenameTable( + name: "Providers", + newName: "ServiceProviders"); + + migrationBuilder.RenameIndex( + name: "IX_Providers_ProviderTypeId", + table: "ServiceProviders", + newName: "IX_ServiceProviders_ProviderTypeId"); + + migrationBuilder.AddColumn( + name: "StaffId", + table: "HistoryOfApprovals", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AlterColumn( + name: "Meeting", + table: "Communications", + type: "nvarchar(300)", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(300)", + oldMaxLength: 300); + + migrationBuilder.AlterColumn( + name: "Email", + table: "Communications", + type: "nvarchar(100)", + maxLength: 100, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100); + + migrationBuilder.AlterColumn( + name: "Calling", + table: "Communications", + type: "nvarchar(100)", + maxLength: 100, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100); + + migrationBuilder.AddPrimaryKey( + name: "PK_ServiceProviders", + table: "ServiceProviders", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_ExperienceLevels_StaffId", + table: "ExperienceLevels", + column: "StaffId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_ContactServiceProvider_ServiceProviders_ServiceProviderId", + table: "ContactServiceProvider", + column: "ServiceProviderId", + principalTable: "ServiceProviders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Contract_ServiceProviders_ServiceProviderId", + table: "Contract", + column: "ServiceProviderId", + principalTable: "ServiceProviders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ProviderContacts_ServiceProviders_ProviderId", + table: "ProviderContacts", + column: "ProviderId", + principalTable: "ServiceProviders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId", + table: "ServiceProviders", + column: "ProviderTypeId", + principalTable: "ProviderTypes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ContactServiceProvider_ServiceProviders_ServiceProviderId", + table: "ContactServiceProvider"); + + migrationBuilder.DropForeignKey( + name: "FK_Contract_ServiceProviders_ServiceProviderId", + table: "Contract"); + + migrationBuilder.DropForeignKey( + name: "FK_ProviderContacts_ServiceProviders_ProviderId", + table: "ProviderContacts"); + + migrationBuilder.DropForeignKey( + name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId", + table: "ServiceProviders"); + + migrationBuilder.DropIndex( + name: "IX_ExperienceLevels_StaffId", + table: "ExperienceLevels"); + + migrationBuilder.DropPrimaryKey( + name: "PK_ServiceProviders", + table: "ServiceProviders"); + + migrationBuilder.DropColumn( + name: "StaffId", + table: "HistoryOfApprovals"); + + migrationBuilder.RenameTable( + name: "ServiceProviders", + newName: "Providers"); + + migrationBuilder.RenameIndex( + name: "IX_ServiceProviders_ProviderTypeId", + table: "Providers", + newName: "IX_Providers_ProviderTypeId"); + + migrationBuilder.AlterColumn( + name: "Meeting", + table: "Communications", + type: "nvarchar(300)", + maxLength: 300, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(300)", + oldMaxLength: 300, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Email", + table: "Communications", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Calling", + table: "Communications", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100, + oldNullable: true); + + migrationBuilder.AddPrimaryKey( + name: "PK_Providers", + table: "Providers", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_ExperienceLevels_StaffId", + table: "ExperienceLevels", + column: "StaffId"); + + migrationBuilder.AddForeignKey( + name: "FK_ContactServiceProvider_Providers_ServiceProviderId", + table: "ContactServiceProvider", + column: "ServiceProviderId", + principalTable: "Providers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Contract_Providers_ServiceProviderId", + table: "Contract", + column: "ServiceProviderId", + principalTable: "Providers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ProviderContacts_Providers_ProviderId", + table: "ProviderContacts", + column: "ProviderId", + principalTable: "Providers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Providers_ProviderTypes_ProviderTypeId", + table: "Providers", + column: "ProviderTypeId", + principalTable: "ProviderTypes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs index 1f414fb..425ef38 100644 --- a/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs +++ b/PyroFetes/Migrations/PyroFetesDbContextModelSnapshot.cs @@ -136,7 +136,6 @@ namespace PyroFetes.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("Calling") - .IsRequired() .HasMaxLength(100) .HasColumnType("nvarchar(100)"); @@ -144,12 +143,10 @@ namespace PyroFetes.Migrations .HasColumnType("int"); b.Property("Email") - .IsRequired() .HasMaxLength(100) .HasColumnType("nvarchar(100)"); b.Property("Meeting") - .IsRequired() .HasMaxLength(300) .HasColumnType("nvarchar(300)"); @@ -377,7 +374,8 @@ namespace PyroFetes.Migrations b.HasKey("Id"); - b.HasIndex("StaffId"); + b.HasIndex("StaffId") + .IsUnique(); b.ToTable("ExperienceLevels"); }); @@ -396,6 +394,9 @@ namespace PyroFetes.Migrations b.Property("ExpirationDate") .HasColumnType("date"); + b.Property("StaffId") + .HasColumnType("int"); + b.HasKey("Id"); b.ToTable("HistoryOfApprovals"); @@ -781,7 +782,7 @@ namespace PyroFetes.Migrations b.HasIndex("ProviderTypeId"); - b.ToTable("Providers"); + b.ToTable("ServiceProviders"); }); modelBuilder.Entity("PyroFetes.Models.Setting", b => @@ -1333,8 +1334,8 @@ namespace PyroFetes.Migrations modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b => { b.HasOne("PyroFetes.Models.Staff", "Staff") - .WithMany("ExperienceLevels") - .HasForeignKey("StaffId") + .WithOne("ExperienceLevel") + .HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -1911,7 +1912,8 @@ namespace PyroFetes.Migrations modelBuilder.Entity("PyroFetes.Models.Staff", b => { - b.Navigation("ExperienceLevels"); + b.Navigation("ExperienceLevel") + .IsRequired(); b.Navigation("ShowStaffs"); diff --git a/PyroFetes/Models/HistoryOfApproval.cs b/PyroFetes/Models/HistoryOfApproval.cs index c8fd073..fae3fb2 100644 --- a/PyroFetes/Models/HistoryOfApproval.cs +++ b/PyroFetes/Models/HistoryOfApproval.cs @@ -8,5 +8,7 @@ public class HistoryOfApproval [Required] public DateOnly DeliveryDate { get; set; } [Required] public DateOnly ExpirationDate { get; set; } + + public int StaffId { get; set; } public List? StaffHistoryOfApprovals { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Models/Staff.cs b/PyroFetes/Models/Staff.cs index a95c455..9db3f73 100644 --- a/PyroFetes/Models/Staff.cs +++ b/PyroFetes/Models/Staff.cs @@ -13,7 +13,7 @@ public class Staff [Required] public DateOnly F4T2ExpirationDate { get; set; } public List? ShowStaffs { get; set; } - public List? ExperienceLevels { get; set; } + public ExperienceLevel ExperienceLevel { get; set; } public List? StaffAvailabilities { get; set; } public List? StaffHistoryOfApprovals { get; set; } public List? StaffContacts { get; set; }