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/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 new file mode 100644 index 0000000..6627c54 --- /dev/null +++ b/PyroFetes/DTO/Customer/Request/CreateCustomerDto.cs @@ -0,0 +1,7 @@ +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/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..91021b4 --- /dev/null +++ b/PyroFetes/DTO/Customer/Response/GetCustomerDto.cs @@ -0,0 +1,11 @@ +namespace PyroFetes.DTO.Customer.Response; + +public class GetCustomerDto +{ + public int Id { get; set; } + 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/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/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/Request/CreateProviderDto.cs b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs new file mode 100644 index 0000000..7919e85 --- /dev/null +++ b/PyroFetes/DTO/Provider/Request/CreateProviderDto.cs @@ -0,0 +1,7 @@ +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/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..216dc68 --- /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 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 new file mode 100644 index 0000000..2cbd8c8 --- /dev/null +++ b/PyroFetes/DTO/Provider/Response/GetProviderDto.cs @@ -0,0 +1,11 @@ +namespace PyroFetes.DTO.Provider.Response; + +public class GetProviderDto +{ + public int Id { get; set; } + 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/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/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..85b83dc 100644 --- a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs +++ b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs @@ -3,6 +3,12 @@ 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; } + public string? ExperienceLevel { get; set; } + } \ No newline at end of file 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..744ab77 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(); } @@ -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/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs index b707b4b..ce1055e 100644 --- a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -1,15 +1,16 @@ 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() { - Delete ("/api/availabilities/{@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 new file mode 100644 index 0000000..c1544fe --- /dev/null +++ b/PyroFetes/Endpoints/Communication/GetAllCommunicationsEndpoint.cs @@ -0,0 +1,32 @@ +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 ("/communications"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + 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/Communication/GetCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs index cb58367..728370f 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/availabilities"); + Get ("/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..8fcbc13 --- /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 ("/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/Contact/CreateContactEndpoint.cs b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs index e0a65fc..a2dd49b 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; @@ -8,13 +9,22 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp { public override void Configure() { - Post("/api/contacts"); + Post("/contacts"); AllowAnonymous(); } 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 = databaseCustomer.Id, }; await Send.OkAsync(response, ct); diff --git a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs index 51a965c..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..b92d37b 100644 --- a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs +++ b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs @@ -4,11 +4,11 @@ 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() { - 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/UpdateContactEndpoint.cs similarity index 84% rename from PyroFetes/Endpoints/Contact/UpdateContactRequest.cs rename to PyroFetes/Endpoints/Contact/UpdateContactEndpoint.cs index 8fec9d1..cea7654 100644 --- a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs +++ b/PyroFetes/Endpoints/Contact/UpdateContactEndpoint.cs @@ -5,11 +5,11 @@ 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() { - Put ("/api/contacts/{@Id}", x => new { x.Id }); + Put ("/contacts/{@Id}", x => new { x.Id }); AllowAnonymous(); } @@ -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, }; diff --git a/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs new file mode 100644 index 0000000..c454f85 --- /dev/null +++ b/PyroFetes/Endpoints/Customer/CreateCustomerEndpoint.cs @@ -0,0 +1,47 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +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("/customers"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateCustomerDto req, CancellationToken ct) + { + Models.CustomerType? databaseCustomerType = await pyroFetesDbContext.CustomerTypes.SingleOrDefaultAsync(x => x.Id == req.CustomerTypeId, cancellationToken: ct); + + if (databaseCustomerType == null) + { + 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); + + GetCustomerDto response = new GetCustomerDto() + { + Id = customer.Id, + Note = customer.Note, + CustomerTypeId = customer.CustomerTypeId + }; + + 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..997ceb7 --- /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 ("/customers/{@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..d3337ed --- /dev/null +++ b/PyroFetes/Endpoints/Customer/GetAllCustomerEndpoint.cs @@ -0,0 +1,26 @@ +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 ("/customers"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + 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); + } +} \ 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..a1cbda2 --- /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 ("/customers/{@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..4b2ba99 --- /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 ("/customers/{@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..dbe9aa1 --- /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("/customertypes"); + 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..49da728 --- /dev/null +++ b/PyroFetes/Endpoints/CustomerType/DeleteCustomerTypeEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +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 ("/customertypes/{@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; + } + pyroFetesDbContext.CustomerTypes.Remove(databaseCustomerType); + 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..7a0e931 --- /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 ("/customertypes"); + 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..87026e5 --- /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 ("/customertypes/{@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..446a9bd --- /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 ("/customertypes/{@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 diff --git a/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs index ef4ccc6..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; @@ -9,15 +10,26 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext { public override void Configure() { - Post("/api/ExperienceLevels"); + Post("/experiencelevels"); AllowAnonymous(); } 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/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs index 2fc0a96..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 c04d6e7..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 9236f07..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 e928e41..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 d5251ae..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; @@ -8,17 +9,28 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte { public override void Configure() { - Post("/api/HistoryOfApprovals"); + Post("/historyofapprovals"); AllowAnonymous(); } 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/DeleteHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs index 0095177..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 cc0cd48..2ee4d19 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(); } @@ -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/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs index eb3f70c..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 e5c98e6..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 new file mode 100644 index 0000000..f60029b --- /dev/null +++ b/PyroFetes/Endpoints/Provider/CreateProviderEndpoint.cs @@ -0,0 +1,46 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +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("/serviceproviders"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateProviderDto req, CancellationToken ct) + { + Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.ProviderTypeId, cancellationToken: ct); + + if (databaseProviderType == null) + { + 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); + + GetProviderDto response = new GetProviderDto() + { + Id = provider.Id, + Price = provider.Price, + ProviderTypeId = provider.ProviderTypeId + }; + + 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..521ff74 --- /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 ("/serviceproviders/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderRequest req, 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.ServiceProviders.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..e641bcb --- /dev/null +++ b/PyroFetes/Endpoints/Provider/GetAllProvidersEndpoint.cs @@ -0,0 +1,27 @@ +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 ("/serviceproviders"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + 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); + } +} \ 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..df07a06 --- /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 ("/serviceproviders/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct) + { + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.ServiceProviders.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..8b567fb --- /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 ("/serviceproviders/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateProviderDto req, CancellationToken ct) + { + Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.ServiceProviders.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 diff --git a/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs b/PyroFetes/Endpoints/ProviderType/CreateProviderTypeEndpoint.cs new file mode 100644 index 0000000..1e92cc2 --- /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("/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..4f05db7 --- /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 ("/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..610ccce --- /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 ("/providertypes"); + 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..4c93387 --- /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 ("/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; + } + + 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..af596f8 --- /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 ("/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 diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs index 06f6e64..a975d2c 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("/staffs"); AllowAnonymous(); } @@ -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/DeleteStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs index 1af08ee..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/staff/{@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 479b670..f4fa5fd 100644 --- a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -7,21 +7,28 @@ namespace PyroFetes.Endpoints.Staff; public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> { public override void Configure() - { - Get ("/api/availabilities"); + { + Get("/staffs"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { - List staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto() - { - Id = x.Id, - 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/Endpoints/Staff/GetStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs index 73e95fe..24d299b 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(); } @@ -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/UpdateStaffEndpoint.cs similarity index 75% rename from PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs rename to PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs index eb9ef7f..82b7d95 100644 --- a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs +++ b/PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs @@ -5,11 +5,11 @@ using FastEndpoints; namespace PyroFetes.Endpoints.Staff; -public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { - Put ("/api/Staffs/{@Id}", x => new { x.Id }); + Put ("/staffs/{@Id}", x => new { x.Id }); AllowAnonymous(); } @@ -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/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 27be969..d4ec9af 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"); @@ -780,7 +781,7 @@ namespace PyroFetes.Migrations b.HasIndex("ProviderTypeId"); - b.ToTable("Providers"); + b.ToTable("ServiceProviders"); }); modelBuilder.Entity("PyroFetes.Models.Setting", b => @@ -1332,8 +1333,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(); @@ -1910,7 +1911,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/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; } 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 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; } 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 @@ + + 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; }