From 0e19ef1ab74edf6bd5c939e5fd7a654226fda825 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 9 Oct 2025 17:10:51 +0200 Subject: [PATCH 1/5] Initial commit From 4e64112a317e10cda74a64a3f80ee17da044bdc9 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 9 Oct 2025 17:12:17 +0200 Subject: [PATCH 2/5] First Commit 09/10 # Conflicts: # PyroFetes/PyroFetes.csproj --- .../.idea/.idea.PyroFetes/.idea/encodings.xml | 4 ++ .../.idea.PyroFetes/.idea/indexLayout.xml | 8 +++ .../.idea/projectSettingsUpdater.xml | 8 +++ .../.idea/.idea.PyroFetes/.idea/workspace.xml | 66 +++++++++++++++++++ .../Request/CreateAvailabilityDto.cs | 9 +++ .../Request/GetAvailabilityRequest.cs | 6 ++ .../Request/UpdateAvailabilityDto.cs | 10 +++ .../Response/GetAvailabilityDto.cs | 10 +++ .../Request/CreateCommunicationDto.cs | 6 ++ .../Request/GetCommunicationRequest.cs | 6 ++ .../Request/UpdateCommunicationDto.cs | 6 ++ .../Response/GetCommunicationDto.cs | 8 +++ .../DTO/Contact/Request/CreateContactDto.cs | 11 ++++ .../DTO/Contact/Request/GetContactRequest.cs | 6 ++ .../DTO/Contact/Request/UpdateContactDto.cs | 12 ++++ .../DTO/Contact/Response/GetContactDto.cs | 12 ++++ .../Request/CreateExperienceLevelDto.cs | 6 ++ .../Request/GetExperienceLevelRequest.cs | 6 ++ .../Request/UpdateExperienceLevelDto.cs | 7 ++ .../Response/GetExperienceLevelDto.cs | 7 ++ .../Request/CreateHistoryOfApprovalDto.cs | 7 ++ .../Request/GetHistoryOfApprovalRequest.cs | 6 ++ .../Request/UpdateHistoryOfApprovalDto.cs | 8 +++ .../Response/GetHistoryOfApprovalDto.cs | 8 +++ PyroFetes/DTO/Staff/Request/CreateStaffDto.cs | 7 ++ .../DTO/Staff/Request/GetStaffRequest.cs | 6 ++ PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs | 8 +++ PyroFetes/DTO/Staff/Response/GetStaffDto.cs | 6 ++ .../CreateAvailabilityEndpoint.cs | 38 +++++++++++ .../DeleteAvailabilityEndpoint.cs | 30 +++++++++ .../GetAllAvailabilitiesEndpoint.cs | 28 ++++++++ .../Availability/GetAvailabilityEndpoint.cs | 37 +++++++++++ .../UpdateAvailabilityEndpoint.cs | 45 +++++++++++++ .../Contact/CreateContactEndpoint.cs | 42 ++++++++++++ .../Contact/DeleteContactEndpoint.cs | 30 +++++++++ .../Contact/GetAllContactsEndpoint.cs | 30 +++++++++ .../Endpoints/Contact/GetContactEndpoint.cs | 39 +++++++++++ .../Endpoints/Contact/UpdateContactRequest.cs | 49 ++++++++++++++ .../CreateExperienceLevelEndpoint.cs | 34 ++++++++++ .../DeleteExerienceLevelEndpoint.cs | 30 +++++++++ .../GetAllExperienceLevelsEndpoint.cs | 24 +++++++ .../GetExperienceLevelEndpoint.cs | 6 ++ .../UpdateExperienceLevelEndpoint.cs | 6 ++ .../CreateHistoryOfApprovalEndpoint.cs | 36 ++++++++++ .../DeleteHistoryOfApprovalEndpoint.cs | 30 +++++++++ .../GetAllHistoryOfApprovalEndpoint.cs | 26 ++++++++ .../GetHistoryOfApprovalEndpoint.cs | 35 ++++++++++ .../UpdateHistoryOfApprovalEndpoint.cs | 41 ++++++++++++ PyroFetes/PyroFetes.csproj | 2 + 49 files changed, 908 insertions(+) create mode 100644 PyroFetes/.idea/.idea.PyroFetes/.idea/encodings.xml create mode 100644 PyroFetes/.idea/.idea.PyroFetes/.idea/indexLayout.xml create mode 100644 PyroFetes/.idea/.idea.PyroFetes/.idea/projectSettingsUpdater.xml create mode 100644 PyroFetes/.idea/.idea.PyroFetes/.idea/workspace.xml create mode 100644 PyroFetes/DTO/Availability/Request/CreateAvailabilityDto.cs create mode 100644 PyroFetes/DTO/Availability/Request/GetAvailabilityRequest.cs create mode 100644 PyroFetes/DTO/Availability/Request/UpdateAvailabilityDto.cs create mode 100644 PyroFetes/DTO/Availability/Response/GetAvailabilityDto.cs create mode 100644 PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs create mode 100644 PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs create mode 100644 PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs create mode 100644 PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs create mode 100644 PyroFetes/DTO/Contact/Request/CreateContactDto.cs create mode 100644 PyroFetes/DTO/Contact/Request/GetContactRequest.cs create mode 100644 PyroFetes/DTO/Contact/Request/UpdateContactDto.cs create mode 100644 PyroFetes/DTO/Contact/Response/GetContactDto.cs create mode 100644 PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs create mode 100644 PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs create mode 100644 PyroFetes/DTO/ExperienceLevel/Request/UpdateExperienceLevelDto.cs create mode 100644 PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs create mode 100644 PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs create mode 100644 PyroFetes/DTO/HistoryOfApproval/Request/GetHistoryOfApprovalRequest.cs create mode 100644 PyroFetes/DTO/HistoryOfApproval/Request/UpdateHistoryOfApprovalDto.cs create mode 100644 PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs create mode 100644 PyroFetes/DTO/Staff/Request/CreateStaffDto.cs create mode 100644 PyroFetes/DTO/Staff/Request/GetStaffRequest.cs create mode 100644 PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs create mode 100644 PyroFetes/DTO/Staff/Response/GetStaffDto.cs create mode 100644 PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs create mode 100644 PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs create mode 100644 PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs create mode 100644 PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs create mode 100644 PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs create mode 100644 PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs create mode 100644 PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs create mode 100644 PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs create mode 100644 PyroFetes/Endpoints/Contact/GetContactEndpoint.cs create mode 100644 PyroFetes/Endpoints/Contact/UpdateContactRequest.cs create mode 100644 PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs create mode 100644 PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs create mode 100644 PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs create mode 100644 PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs create mode 100644 PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs create mode 100644 PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs create mode 100644 PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs create mode 100644 PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs create mode 100644 PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs create mode 100644 PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs diff --git a/PyroFetes/.idea/.idea.PyroFetes/.idea/encodings.xml b/PyroFetes/.idea/.idea.PyroFetes/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/PyroFetes/.idea/.idea.PyroFetes/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/PyroFetes/.idea/.idea.PyroFetes/.idea/indexLayout.xml b/PyroFetes/.idea/.idea.PyroFetes/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/PyroFetes/.idea/.idea.PyroFetes/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/PyroFetes/.idea/.idea.PyroFetes/.idea/projectSettingsUpdater.xml b/PyroFetes/.idea/.idea.PyroFetes/.idea/projectSettingsUpdater.xml new file mode 100644 index 0000000..ef20cb0 --- /dev/null +++ b/PyroFetes/.idea/.idea.PyroFetes/.idea/projectSettingsUpdater.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/PyroFetes/.idea/.idea.PyroFetes/.idea/workspace.xml b/PyroFetes/.idea/.idea.PyroFetes/.idea/workspace.xml new file mode 100644 index 0000000..1885d46 --- /dev/null +++ b/PyroFetes/.idea/.idea.PyroFetes/.idea/workspace.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + 1760014067675 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PyroFetes/DTO/Availability/Request/CreateAvailabilityDto.cs b/PyroFetes/DTO/Availability/Request/CreateAvailabilityDto.cs new file mode 100644 index 0000000..f5c053c --- /dev/null +++ b/PyroFetes/DTO/Availability/Request/CreateAvailabilityDto.cs @@ -0,0 +1,9 @@ +namespace PyroFetes.DTO.Availability.Request; + +public class CreateAvailabilityDto +{ + public DateOnly AvailabilityDate { get; set; } + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } + public DateOnly RenewalDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Availability/Request/GetAvailabilityRequest.cs b/PyroFetes/DTO/Availability/Request/GetAvailabilityRequest.cs new file mode 100644 index 0000000..9b82857 --- /dev/null +++ b/PyroFetes/DTO/Availability/Request/GetAvailabilityRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Availability.Request; + +public class GetAvailabilityRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Availability/Request/UpdateAvailabilityDto.cs b/PyroFetes/DTO/Availability/Request/UpdateAvailabilityDto.cs new file mode 100644 index 0000000..3b6ab9e --- /dev/null +++ b/PyroFetes/DTO/Availability/Request/UpdateAvailabilityDto.cs @@ -0,0 +1,10 @@ +namespace PyroFetes.DTO.Availability.Request; + +public class UpdateAvailabilityDto +{ + public int Id { get; set; } + public DateOnly AvailabilityDate { get; set; } + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } + public DateOnly RenewalDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Availability/Response/GetAvailabilityDto.cs b/PyroFetes/DTO/Availability/Response/GetAvailabilityDto.cs new file mode 100644 index 0000000..ed40c91 --- /dev/null +++ b/PyroFetes/DTO/Availability/Response/GetAvailabilityDto.cs @@ -0,0 +1,10 @@ +namespace PyroFetes.DTO.Availability.Response; + +public class GetAvailabilityDto +{ + public int Id { get; set; } + public DateOnly AvailabilityDate { get; set; } + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } + public DateOnly RenewalDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs new file mode 100644 index 0000000..cb8bbc2 --- /dev/null +++ b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Communication.Request; + +public class CreateCommunicationDto +{ + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs b/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs new file mode 100644 index 0000000..185f4d1 --- /dev/null +++ b/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Communication.Request; + +public class GetCommunicationRequest +{ + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs b/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs new file mode 100644 index 0000000..8cb9fcf --- /dev/null +++ b/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Communication.Request; + +public class UpdateCommunicationDto +{ + +} \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs b/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs new file mode 100644 index 0000000..de0f97d --- /dev/null +++ b/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Communication.Response; + +public class GetCommunicationRequest +{ + public string? Calling { get; set; } + public string? Email { get; set; } + public string? Meeting { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Request/CreateContactDto.cs b/PyroFetes/DTO/Contact/Request/CreateContactDto.cs new file mode 100644 index 0000000..f52343d --- /dev/null +++ b/PyroFetes/DTO/Contact/Request/CreateContactDto.cs @@ -0,0 +1,11 @@ +namespace PyroFetes.DTO.Contact.Request; + +public class CreateContactDto +{ + public string? LastName { get; set; } + public string? FirstName { get; set; } + public string? PhoneNumber { get; set; } + public string? Email { get; set; } + public string? Address { get; set; } + public string? Role { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Request/GetContactRequest.cs b/PyroFetes/DTO/Contact/Request/GetContactRequest.cs new file mode 100644 index 0000000..d62aa5a --- /dev/null +++ b/PyroFetes/DTO/Contact/Request/GetContactRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Contact.Request; + +public class GetContactRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs b/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs new file mode 100644 index 0000000..42ffd3d --- /dev/null +++ b/PyroFetes/DTO/Contact/Request/UpdateContactDto.cs @@ -0,0 +1,12 @@ +namespace PyroFetes.DTO.Contact.Request; + +public class UpdateContactDto +{ + public int Id { get; set; } + public string? LastName { get; set; } + public string? FirstName { get; set; } + public string? PhoneNumber { get; set; } + public string? Email { get; set; } + public string? Address { get; set; } + public string? Role { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Contact/Response/GetContactDto.cs b/PyroFetes/DTO/Contact/Response/GetContactDto.cs new file mode 100644 index 0000000..38a25d8 --- /dev/null +++ b/PyroFetes/DTO/Contact/Response/GetContactDto.cs @@ -0,0 +1,12 @@ +namespace PyroFetes.DTO.Contact.Response; + +public class GetContactDto +{ + public int Id { get; set; } + public string? LastName { get; set; } + public string? FirstName { get; set; } + public string? PhoneNumber { get; set; } + public string? Email { get; set; } + public string? Address { get; set; } + public string? Role { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs b/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs new file mode 100644 index 0000000..9e40ea6 --- /dev/null +++ b/PyroFetes/DTO/ExperienceLevel/Request/CreateExperienceLevelDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.ExperienceLevel.Request; + +public class CreateExperienceLevelDto +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs b/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs new file mode 100644 index 0000000..a9991e5 --- /dev/null +++ b/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.ExperienceLevel.Request; + +public class GetExperienceLevelRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ExperienceLevel/Request/UpdateExperienceLevelDto.cs b/PyroFetes/DTO/ExperienceLevel/Request/UpdateExperienceLevelDto.cs new file mode 100644 index 0000000..e0e69bd --- /dev/null +++ b/PyroFetes/DTO/ExperienceLevel/Request/UpdateExperienceLevelDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.ExperienceLevel.Request; + +public class UpdateExperienceLevelDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs b/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs new file mode 100644 index 0000000..8a14d3d --- /dev/null +++ b/PyroFetes/DTO/ExperienceLevel/Response/GetExperienceLevelDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.ExperienceLevel.Response; + +public class GetExperienceLevelDto +{ + public int Id { get; set; } + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs b/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs new file mode 100644 index 0000000..ba5a33e --- /dev/null +++ b/PyroFetes/DTO/HistoryOfApproval/Request/CreateHistoryOfApprovalDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.HistoryOfApproval.Request; + +public class CreateHistoryOfApprovalDto +{ + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Request/GetHistoryOfApprovalRequest.cs b/PyroFetes/DTO/HistoryOfApproval/Request/GetHistoryOfApprovalRequest.cs new file mode 100644 index 0000000..b2e692f --- /dev/null +++ b/PyroFetes/DTO/HistoryOfApproval/Request/GetHistoryOfApprovalRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.HistoryOfApproval.Request; + +public class GetHistoryOfApprovalRequest +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Request/UpdateHistoryOfApprovalDto.cs b/PyroFetes/DTO/HistoryOfApproval/Request/UpdateHistoryOfApprovalDto.cs new file mode 100644 index 0000000..cf8a30e --- /dev/null +++ b/PyroFetes/DTO/HistoryOfApproval/Request/UpdateHistoryOfApprovalDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.HistoryOfApproval.Request; + +public class UpdateHistoryOfApprovalDto +{ + public int Id { get; set; } + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs b/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs new file mode 100644 index 0000000..b216521 --- /dev/null +++ b/PyroFetes/DTO/HistoryOfApproval/Response/GetHistoryOfApprovalDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.HistoryOfApproval.Response; + +public class GetHistoryOfApprovalDto +{ + public int Id { get; set; } + public DateOnly DeliveryDate { get; set; } + public DateOnly ExpirationDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs new file mode 100644 index 0000000..8fdbdf5 --- /dev/null +++ b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs @@ -0,0 +1,7 @@ +namespace PyroFetes.DTO.Staff.Request; + +public class CreateStaffDto +{ + public string? F4T2NumberApproval { get; set; } + public string? F4T2ExpirationDate { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs b/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs new file mode 100644 index 0000000..b8b1799 --- /dev/null +++ b/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Staff.Request; + +public class GetStaffRequest +{ + public string? Label { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs b/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs new file mode 100644 index 0000000..82d0685 --- /dev/null +++ b/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs @@ -0,0 +1,8 @@ +namespace PyroFetes.DTO.Staff.Request; + +public class UpdateStaffDto +{ + public int Id { get; set; } + public string? F4T2NumberApproval { get; set; } + public string? 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 new file mode 100644 index 0000000..0e64206 --- /dev/null +++ b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.DTO.Staff.Response; + +public class GetStaffDto +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs new file mode 100644 index 0000000..73a41b8 --- /dev/null +++ b/PyroFetes/Endpoints/Availability/CreateAvailabilityEndpoint.cs @@ -0,0 +1,38 @@ +using FastEndpoints; +using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Availability.Response; + +namespace PyroFetes.Endpoints.Availability; + +public class CreateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/availabilities"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateAvailabilityDto req, CancellationToken ct) + { + Models.Availability availability = new() + { + AvailabilityDate = req.AvailabilityDate, + DeliveryDate = req.DeliveryDate, + ExpirationDate = req.ExpirationDate, + RenewallDate = req.RenewalDate, + }; + pyroFetesDbContext.Add(availability); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetAvailabilityDto response = new() + { + AvailabilityDate = availability.AvailabilityDate, + DeliveryDate = availability.DeliveryDate, + ExpirationDate = availability.ExpirationDate, + RenewalDate = availability.RenewallDate + }; + + await Send.OkAsync(response, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs new file mode 100644 index 0000000..17ce63b --- /dev/null +++ b/PyroFetes/Endpoints/Availability/DeleteAvailabilityEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Availability.Response; + +namespace PyroFetes.Endpoints.Availability; + +public class DeleteAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/availabilities/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetAvailabilityRequest req, CancellationToken ct) + { + Models.Availability? databaseAvailability = await pyroFetesDbContext.Availabilities.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseAvailability == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Availabilities.Remove(databaseAvailability); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs b/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs new file mode 100644 index 0000000..ce2a7eb --- /dev/null +++ b/PyroFetes/Endpoints/Availability/GetAllAvailabilitiesEndpoint.cs @@ -0,0 +1,28 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Response; + +namespace PyroFetes.Endpoints.Availability; + +public class GetAllAvailabilityxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/availabilities"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List availabilities = await pyroFetesDbContext.Availabilities.Select(x => new GetAvailabilityDto() + { + Id = x.Id, + AvailabilityDate = x.AvailabilityDate, + DeliveryDate = x.DeliveryDate, + ExpirationDate = x.ExpirationDate, + RenewalDate = x.RenewallDate + }).ToListAsync(ct); + + await Send.OkAsync(availabilities, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs new file mode 100644 index 0000000..d0bf0b0 --- /dev/null +++ b/PyroFetes/Endpoints/Availability/GetAvailabilityEndpoint.cs @@ -0,0 +1,37 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Availability.Response; + +namespace PyroFetes.Endpoints.Availability; + +public class GetAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/availabilities/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetAvailabilityRequest database, CancellationToken ct) + { + Models.Availability? databaseAvailability = await pyroFetesDbContext.Availabilities.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct); + + if (databaseAvailability == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetAvailabilityDto dto = new() + { + Id = databaseAvailability.Id, + AvailabilityDate = databaseAvailability.AvailabilityDate, + DeliveryDate = databaseAvailability.DeliveryDate, + ExpirationDate = databaseAvailability.ExpirationDate, + RenewalDate = databaseAvailability.RenewallDate + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs b/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs new file mode 100644 index 0000000..7386014 --- /dev/null +++ b/PyroFetes/Endpoints/Availability/UpdateAvailabilityEndpoint.cs @@ -0,0 +1,45 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Availability.Response; + +namespace PyroFetes.Endpoints.Availability; + +public class UpdateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/availabilities/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateAvailabilityDto req, CancellationToken ct) + { + Models.Availability? databaseAvailability = await pyroFetesDbContext.Availabilities.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseAvailability == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseAvailability.AvailabilityDate = req.AvailabilityDate; + databaseAvailability.DeliveryDate = req.DeliveryDate; + databaseAvailability.ExpirationDate = req.ExpirationDate; + databaseAvailability.RenewallDate = req.RenewalDate; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetAvailabilityDto dto = new() + { + Id = databaseAvailability.Id, + AvailabilityDate = req.AvailabilityDate, + DeliveryDate = req.DeliveryDate, + ExpirationDate = req.ExpirationDate, + RenewalDate = req.RenewalDate, + }; + + 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 new file mode 100644 index 0000000..e0a65fc --- /dev/null +++ b/PyroFetes/Endpoints/Contact/CreateContactEndpoint.cs @@ -0,0 +1,42 @@ +using FastEndpoints; +using PyroFetes.DTO.Contact.Request; +using PyroFetes.DTO.Contact.Response; + +namespace PyroFetes.Endpoints.Contact; + +public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/contacts"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateContactDto req, CancellationToken ct) + { + Models.Contact contact = new() + { + LastName = req.LastName, + FirstName = req.FirstName, + PhoneNumber = req.PhoneNumber, + Email = req.Email, + Address = req.Address, + Role = req.Role, + }; + pyroFetesDbContext.Add(contact); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetContactDto response = new() + { + LastName = contact.LastName, + FirstName = contact.FirstName, + PhoneNumber = contact.PhoneNumber, + Email = contact.Email, + Address = contact.Address, + Role = contact.Role, + }; + + await Send.OkAsync(response, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs new file mode 100644 index 0000000..51a965c --- /dev/null +++ b/PyroFetes/Endpoints/Contact/DeleteContactEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Contact.Request; +using PyroFetes.DTO.Contact.Response; + +namespace PyroFetes.Endpoints.Contact; + +public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/Contacts/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetContactRequest req, CancellationToken ct) + { + Models.Contact? databaseContact = await pyroFetesDbContext.Contacts.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseContact == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Contacts.Remove(databaseContact); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs new file mode 100644 index 0000000..e7339d9 --- /dev/null +++ b/PyroFetes/Endpoints/Contact/GetAllContactsEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Contact.Response; + +namespace PyroFetes.Endpoints.Contact; + +public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/contacts"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List contacts = await pyroFetesDbContext.Contacts.Select(x => new GetContactDto() + { + Id = x.Id, + LastName = x.LastName, + FirstName = x.FirstName, + PhoneNumber = x.PhoneNumber, + Email = x.Email, + Address = x.Address, + Role = x.Role, + }).ToListAsync(ct); + + await Send.OkAsync(contacts, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs b/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs new file mode 100644 index 0000000..04a4e5e --- /dev/null +++ b/PyroFetes/Endpoints/Contact/GetContactEndpoint.cs @@ -0,0 +1,39 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Contact.Request; +using PyroFetes.DTO.Contact.Response; + +namespace PyroFetes.Endpoints.Contact; + +public class GetContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/contacts/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetContactRequest database, CancellationToken ct) + { + Models.Contact? databaseContact = await pyroFetesDbContext.Contacts.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct); + + if (databaseContact == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetContactDto dto = new() + { + Id = databaseContact.Id, + LastName = databaseContact.LastName, + FirstName = databaseContact.FirstName, + PhoneNumber = databaseContact.PhoneNumber, + Email = databaseContact.Email, + Address = databaseContact.Address, + Role = databaseContact.Role, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs b/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs new file mode 100644 index 0000000..8fec9d1 --- /dev/null +++ b/PyroFetes/Endpoints/Contact/UpdateContactRequest.cs @@ -0,0 +1,49 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Contact.Request; +using PyroFetes.DTO.Contact.Response; + +namespace PyroFetes.Endpoints.Contact; + +public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/contacts/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateContactDto req, CancellationToken ct) + { + Models.Contact? databaseContact = await pyroFetesDbContext.Contacts.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseContact == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseContact.LastName = req.LastName; + databaseContact.FirstName = req.FirstName; + databaseContact.PhoneNumber = req.PhoneNumber; + databaseContact.Email = req.Email; + databaseContact.Address = req.Address; + databaseContact.Role = req.Role; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetContactDto dto = new() + { + Id = databaseContact.Id, + LastName = req.LastName, + FirstName = req.FirstName, + PhoneNumber = req.PhoneNumber, + Email = req.Email, + Address = req.Address, + Role = req.Role, + }; + + 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 new file mode 100644 index 0000000..ef4ccc6 --- /dev/null +++ b/PyroFetes/Endpoints/ExperienceLevel/CreateExperienceLevelEndpoint.cs @@ -0,0 +1,34 @@ + +using FastEndpoints; +using PyroFetes.DTO.ExperienceLevel.Response; +using PyroFetes.DTO.ExperienceLevel.Request; + +namespace PyroFetes.Endpoints.ExperienceLevel; + +public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/ExperienceLevels"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CreateExperienceLevelDto req, CancellationToken ct) + { + Models.ExperienceLevel experienceLevel = new() + { + Label = req.Label + }; + pyroFetesDbContext.Add(experienceLevel); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetExperienceLevelDto response = new() + { + Id = experienceLevel.Id, + Label = experienceLevel.Label, + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs new file mode 100644 index 0000000..5b5792d --- /dev/null +++ b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ExperienceLevel.Request; +using PyroFetes.DTO.ExperienceLevel.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.ExperienceLevel; + +public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct) + { + Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseExperienceLevel == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.ExperienceLevels.Remove(databaseExperienceLevel); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs new file mode 100644 index 0000000..449cfca --- /dev/null +++ b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ExperienceLevel.Response; + +namespace PyroFetes.Endpoints.ExperienceLevel; +using FastEndpoints; + +public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/experienceLevels"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List experienceLevels= await pyroFetesDbContext.ExperienceLevels.Select(x => new GetExperienceLevelDto() + { + Id = x.Id, + }).ToListAsync(ct); + + await Send.OkAsync(experienceLevels, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs new file mode 100644 index 0000000..2123855 --- /dev/null +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.Endpoints.ExperienceLevel; + +public class GetExperienceLevelEndpoint +{ + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs new file mode 100644 index 0000000..d2aa8a2 --- /dev/null +++ b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs @@ -0,0 +1,6 @@ +namespace PyroFetes.Endpoints.ExperienceLevel; + +public class UpdateExperienceLevelEndpoint +{ + +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs new file mode 100644 index 0000000..d5251ae --- /dev/null +++ b/PyroFetes/Endpoints/HistoryOfApproval/CreateHistoryOfApprovalEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using PyroFetes.DTO.HistoryOfApproval.Request; +using PyroFetes.DTO.HistoryOfApproval.Response; + +namespace PyroFetes.Endpoints.HistoryOfApproval; + +public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/HistoryOfApprovals"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateHistoryOfApprovalDto req, CancellationToken ct) + { + Models.HistoryOfApproval historyOfApproval = new() + { + DeliveryDate = req.DeliveryDate, + ExpirationDate = req.ExpirationDate + }; + pyroFetesDbContext.Add(historyOfApproval); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetHistoryOfApprovalDto response = new() + { + Id = historyOfApproval.Id, + DeliveryDate = historyOfApproval.DeliveryDate, + ExpirationDate = historyOfApproval.ExpirationDate + }; + + await Send.OkAsync(response, ct); + + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs new file mode 100644 index 0000000..0095177 --- /dev/null +++ b/PyroFetes/Endpoints/HistoryOfApproval/DeleteHistoryOfApprovalEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.HistoryOfApproval.Request; +using PyroFetes.DTO.HistoryOfApproval.Response; + +namespace PyroFetes.Endpoints.HistoryOfApproval; + +public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetHistoryOfApprovalRequest req, CancellationToken ct) + { + Models.HistoryOfApproval? databaseHistoryOfApproval = await pyroFetesDbContext.HistoryOfApprovals.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseHistoryOfApproval == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.HistoryOfApprovals.Remove(databaseHistoryOfApproval); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs new file mode 100644 index 0000000..cc0cd48 --- /dev/null +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetAllHistoryOfApprovalEndpoint.cs @@ -0,0 +1,26 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.HistoryOfApproval.Response; + +namespace PyroFetes.Endpoints.HistoryOfApproval; + +public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/HistoryOfApprovals"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List historyOfApprovals= await pyroFetesDbContext.HistoryOfApprovals.Select(x => new GetHistoryOfApprovalDto() + { + Id = x.Id, + DeliveryDate = x.DeliveryDate, + ExpirationDate = x.ExpirationDate, + }).ToListAsync(ct); + + await Send.OkAsync(historyOfApprovals, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs new file mode 100644 index 0000000..eb3f70c --- /dev/null +++ b/PyroFetes/Endpoints/HistoryOfApproval/GetHistoryOfApprovalEndpoint.cs @@ -0,0 +1,35 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.HistoryOfApproval.Request; +using PyroFetes.DTO.HistoryOfApproval.Response; + +namespace PyroFetes.Endpoints.HistoryOfApproval; + +public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetHistoryOfApprovalRequest req, CancellationToken ct) + { + Models.HistoryOfApproval? databaseHistoryOfApproval = await pyroFetesDbContext.HistoryOfApprovals.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseHistoryOfApproval == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetHistoryOfApprovalDto dto = new() + { + Id = databaseHistoryOfApproval.Id, + DeliveryDate = databaseHistoryOfApproval.DeliveryDate, + ExpirationDate = databaseHistoryOfApproval.ExpirationDate + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs new file mode 100644 index 0000000..e5c98e6 --- /dev/null +++ b/PyroFetes/Endpoints/HistoryOfApproval/UpdateHistoryOfApprovalEndpoint.cs @@ -0,0 +1,41 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.HistoryOfApproval.Request; +using PyroFetes.DTO.HistoryOfApproval.Response; + +namespace PyroFetes.Endpoints.HistoryOfApproval; + +public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateHistoryOfApprovalDto req, CancellationToken ct) + { + Models.HistoryOfApproval? databaseHistoryOfApproval = await pyroFetesDbContext.HistoryOfApprovals.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseHistoryOfApproval == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseHistoryOfApproval.DeliveryDate = req.DeliveryDate; + databaseHistoryOfApproval.ExpirationDate = req.ExpirationDate; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetHistoryOfApprovalDto dto = new() + { + Id = databaseHistoryOfApproval.Id, + DeliveryDate = req.DeliveryDate, + ExpirationDate = req.ExpirationDate + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index 60e4770..b301a92 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -7,6 +7,8 @@ + + From df81c7b12d89b4f93701f801c66b8dfd2352a029 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 9 Oct 2025 17:19:05 +0200 Subject: [PATCH 3/5] ExperienceLevel Finished (API) 09/10 --- .../GetAllExperienceLevelsEndpoint.cs | 2 + .../GetExperienceLevelEndpoint.cs | 32 +++++++++++++++- .../UpdateExperienceLevelEndpoint.cs | 37 ++++++++++++++++++- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs index 449cfca..c04d6e7 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetAllExperienceLevelsEndpoint.cs @@ -17,6 +17,8 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex List experienceLevels= await pyroFetesDbContext.ExperienceLevels.Select(x => new GetExperienceLevelDto() { Id = x.Id, + Label = x.Label, + }).ToListAsync(ct); await Send.OkAsync(experienceLevels, ct); diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs index 2123855..3ba32ce 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -1,6 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ExperienceLevel.Request; +using PyroFetes.DTO.ExperienceLevel.Response; +using FastEndpoints; + namespace PyroFetes.Endpoints.ExperienceLevel; -public class GetExperienceLevelEndpoint +public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { - + public override void Configure() + { + Get ("/api/experienceLevels/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct) + { + Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseExperienceLevel == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetExperienceLevelDto dto = new() + { + Id = databaseExperienceLevel.Id, + Label = databaseExperienceLevel.Label, + }; + + await Send.OkAsync(dto, ct); + } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs index d2aa8a2..e928e41 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/UpdateExperienceLevelEndpoint.cs @@ -1,6 +1,39 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.ExperienceLevel.Request; +using PyroFetes.DTO.ExperienceLevel.Response; + namespace PyroFetes.Endpoints.ExperienceLevel; -public class UpdateExperienceLevelEndpoint +public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { - + public override void Configure() + { + Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateExperienceLevelDto req, CancellationToken ct) + { + Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseExperienceLevel == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseExperienceLevel.Label = req.Label; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetExperienceLevelDto dto = new() + { + Id = databaseExperienceLevel.Id, + Label = req.Label, + }; + + await Send.OkAsync(dto, ct); + } } \ No newline at end of file From 5cbbfa14343f000c5c45ea05bfcc7e345435406a Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 9 Oct 2025 17:48:07 +0200 Subject: [PATCH 4/5] Staff DTO / Request Finished 09/10 --- PyroFetes/DTO/Staff/Request/CreateStaffDto.cs | 2 +- .../DTO/Staff/Request/GetStaffRequest.cs | 2 +- PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs | 2 +- PyroFetes/DTO/Staff/Response/GetStaffDto.cs | 2 + .../Endpoints/Staff/CreateStaffEndpoint.cs | 34 +++++++++++++++ .../Endpoints/Staff/DeleteStaffEndpoint.cs | 30 ++++++++++++++ .../Endpoints/Staff/GetAllStaffsEndpoint.cs | 27 ++++++++++++ PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs | 35 ++++++++++++++++ .../Endpoints/Staff/UpdateStaffRequest.cs | 41 +++++++++++++++++++ 9 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs create mode 100644 PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs create mode 100644 PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs create mode 100644 PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs create mode 100644 PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs diff --git a/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs index 8fdbdf5..63e33ad 100644 --- a/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs +++ b/PyroFetes/DTO/Staff/Request/CreateStaffDto.cs @@ -3,5 +3,5 @@ namespace PyroFetes.DTO.Staff.Request; public class CreateStaffDto { public string? F4T2NumberApproval { get; set; } - public string? F4T2ExpirationDate { get; set; } + public DateOnly F4T2ExpirationDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs b/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs index b8b1799..83fbbab 100644 --- a/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs +++ b/PyroFetes/DTO/Staff/Request/GetStaffRequest.cs @@ -2,5 +2,5 @@ namespace PyroFetes.DTO.Staff.Request; public class GetStaffRequest { - public string? Label { get; set; } + public int Id { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs b/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs index 82d0685..7a580ca 100644 --- a/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs +++ b/PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs @@ -4,5 +4,5 @@ public class UpdateStaffDto { public int Id { get; set; } public string? F4T2NumberApproval { get; set; } - public string? F4T2ExpirationDate { 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 0e64206..ae10f74 100644 --- a/PyroFetes/DTO/Staff/Response/GetStaffDto.cs +++ b/PyroFetes/DTO/Staff/Response/GetStaffDto.cs @@ -3,4 +3,6 @@ namespace PyroFetes.DTO.Staff.Response; public class GetStaffDto { public int Id { get; set; } + public string? F4T2NumberApproval { get; set; } + public DateOnly F4T2ExpirationDate { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs new file mode 100644 index 0000000..06f6e64 --- /dev/null +++ b/PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs @@ -0,0 +1,34 @@ +using FastEndpoints; +using PyroFetes.DTO.Staff.Request; +using PyroFetes.DTO.Staff.Response; + +namespace PyroFetes.Endpoints.Staff; + +public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/availabilities"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct) + { + Models.Staff staff = new() + { + F4T2NumberApproval = req.F4T2NumberApproval, + F4T2ExpirationDate = req.F4T2ExpirationDate, + }; + pyroFetesDbContext.Add(staff); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetStaffDto response = new() + { + F4T2NumberApproval = staff.F4T2NumberApproval, + F4T2ExpirationDate = staff.F4T2ExpirationDate, + }; + + await Send.OkAsync(response, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs new file mode 100644 index 0000000..1af08ee --- /dev/null +++ b/PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Staff.Request; +using PyroFetes.DTO.Staff.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Staff; + +public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/staff/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetStaffRequest req, CancellationToken ct) + { + Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseStaff == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Staffs.Remove(databaseStaff); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs new file mode 100644 index 0000000..479b670 --- /dev/null +++ b/PyroFetes/Endpoints/Staff/GetAllStaffsEndpoint.cs @@ -0,0 +1,27 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Staff.Response; + +namespace PyroFetes.Endpoints.Staff; + +public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/availabilities"); + 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); + + 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 new file mode 100644 index 0000000..73e95fe --- /dev/null +++ b/PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Staff.Request; +using PyroFetes.DTO.Staff.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Staff; + +public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Get ("/api/Staffs/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(GetStaffRequest database, CancellationToken ct) + { + Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct); + + if (databaseStaff == null) + { + await Send.NotFoundAsync(ct); + return; + } + + GetStaffDto dto = new() + { + Id = databaseStaff.Id, + F4T2NumberApproval = databaseStaff.F4T2NumberApproval, + F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs new file mode 100644 index 0000000..eb9ef7f --- /dev/null +++ b/PyroFetes/Endpoints/Staff/UpdateStaffRequest.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Staff.Request; +using PyroFetes.DTO.Staff.Response; +using FastEndpoints; + +namespace PyroFetes.Endpoints.Staff; + +public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Put ("/api/Staffs/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public override async Task HandleAsync(UpdateStaffDto req, CancellationToken ct) + { + Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseStaff == null) + { + await Send.NotFoundAsync(ct); + return; + } + else + { + databaseStaff.F4T2NumberApproval = req.F4T2NumberApproval; + databaseStaff.F4T2ExpirationDate = req.F4T2ExpirationDate; + } + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetStaffDto dto = new() + { + Id = databaseStaff.Id, + F4T2NumberApproval = req.F4T2NumberApproval, + F4T2ExpirationDate = req.F4T2ExpirationDate, + }; + + await Send.OkAsync(dto, ct); + } +} \ No newline at end of file From df622c92328108db29d0f8000dc6d4e046960321 Mon Sep 17 00:00:00 2001 From: carteronm Date: Thu, 16 Oct 2025 17:05:52 +0200 Subject: [PATCH 5/5] Adding Comunication --- .../Request/CreateCommunicationDto.cs | 4 ++- .../Request/GetCommunicationRequest.cs | 2 +- .../Request/UpdateCommunicationDto.cs | 5 ++- .../Response/GetCommunicationDto.cs | 3 +- ...velRequest.cs => GetExperienceLevelDTO.cs} | 2 +- .../CreateCommunicationEndpoint.cs | 36 +++++++++++++++++++ .../DeleteCommunicationEndpoint.cs | 30 ++++++++++++++++ .../Communication/GetCommunicationEndpoint.cs | 28 +++++++++++++++ .../DeleteExerienceLevelEndpoint.cs | 4 +-- .../GetExperienceLevelEndpoint.cs | 4 +-- 10 files changed, 109 insertions(+), 9 deletions(-) rename PyroFetes/DTO/ExperienceLevel/Request/{GetExperienceLevelRequest.cs => GetExperienceLevelDTO.cs} (68%) create mode 100644 PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs create mode 100644 PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs create mode 100644 PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs diff --git a/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs index cb8bbc2..47fa206 100644 --- a/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs +++ b/PyroFetes/DTO/Communication/Request/CreateCommunicationDto.cs @@ -2,5 +2,7 @@ namespace PyroFetes.DTO.Communication.Request; public class CreateCommunicationDto { - + public string? Calling { get; set; } + public string? Email { get; set; } + public string? Meeting { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs b/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs index 185f4d1..bcea23c 100644 --- a/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs +++ b/PyroFetes/DTO/Communication/Request/GetCommunicationRequest.cs @@ -2,5 +2,5 @@ namespace PyroFetes.DTO.Communication.Request; public class GetCommunicationRequest { - + public int Id { get; set; } } \ No newline at end of file diff --git a/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs b/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs index 8cb9fcf..071832f 100644 --- a/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs +++ b/PyroFetes/DTO/Communication/Request/UpdateCommunicationDto.cs @@ -2,5 +2,8 @@ namespace PyroFetes.DTO.Communication.Request; public class UpdateCommunicationDto { - + public int Id { get; set; } + public string? Calling { get; set; } + public string? Email { get; set; } + public string? Meeting { 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 de0f97d..ea0432d 100644 --- a/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs +++ b/PyroFetes/DTO/Communication/Response/GetCommunicationDto.cs @@ -1,7 +1,8 @@ namespace PyroFetes.DTO.Communication.Response; -public class GetCommunicationRequest +public class GetCommunicationDto { + public int Id { get; set; } public string? Calling { get; set; } public string? Email { get; set; } public string? Meeting { get; set; } diff --git a/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs b/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelDTO.cs similarity index 68% rename from PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs rename to PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelDTO.cs index a9991e5..c64b436 100644 --- a/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelRequest.cs +++ b/PyroFetes/DTO/ExperienceLevel/Request/GetExperienceLevelDTO.cs @@ -1,6 +1,6 @@ namespace PyroFetes.DTO.ExperienceLevel.Request; -public class GetExperienceLevelRequest +public class GetExperienceLevelDTO { public int Id { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs new file mode 100644 index 0000000..3429d20 --- /dev/null +++ b/PyroFetes/Endpoints/Communication/CreateCommunicationEndpoint.cs @@ -0,0 +1,36 @@ +using FastEndpoints; +using PyroFetes.DTO.Communication.Request; +using PyroFetes.DTO.Communication.Response; + +namespace PyroFetes.Endpoints.Communication; + +public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Post("/api/communications"); + AllowAnonymous(); + } + + + public override async Task HandleAsync(CreateCommunicationDto req, CancellationToken ct) + { + Models.Communication communication = new() + { + Calling = req.Calling, + Email = req.Email, + Meeting = req.Meeting + }; + pyroFetesDbContext.Add(communication); + await pyroFetesDbContext.SaveChangesAsync(ct); + + GetCommunicationDto response = new() + { + Calling = req.Calling, + Email = req.Email, + Meeting = req.Meeting + }; + + await Send.OkAsync(response, ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs new file mode 100644 index 0000000..b707b4b --- /dev/null +++ b/PyroFetes/Endpoints/Communication/DeleteCommunicationEndpoint.cs @@ -0,0 +1,30 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Request; +using PyroFetes.DTO.Communication.Response; + +namespace PyroFetes.Endpoints.Communication; + +public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +{ + public override void Configure() + { + Delete ("/api/availabilities/{@Id}", x => new { x.Id }); + AllowAnonymous(); + } + + public async Task HandleAsync(GetAvailabilityRequest req, CancellationToken ct) + { + Models.Availability? databaseAvailability = await pyroFetesDbContext.Availabilities.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); + + if (databaseAvailability == null) + { + await Send.NotFoundAsync(ct); + return; + } + pyroFetesDbContext.Availabilities.Remove(databaseAvailability); + await pyroFetesDbContext.SaveChangesAsync(ct); + + await Send.NoContentAsync(ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs new file mode 100644 index 0000000..cb58367 --- /dev/null +++ b/PyroFetes/Endpoints/Communication/GetCommunicationEndpoint.cs @@ -0,0 +1,28 @@ +using FastEndpoints; +using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Availability.Response; +using PyroFetes.DTO.Communication.Response; + +namespace PyroFetes.Endpoints.Communication; + +public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest> +{ + public override void Configure() + { + Get ("/api/availabilities"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + List communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto() + { + Id = x.Id, + Calling = x.Calling, + Email = x.Email, + Meeting = x.Meeting, + }).ToListAsync(ct); + + await Send.OkAsync(communications, ct); + } +} diff --git a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs index 5b5792d..2fc0a96 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/DeleteExerienceLevelEndpoint.cs @@ -5,7 +5,7 @@ using FastEndpoints; namespace PyroFetes.Endpoints.ExperienceLevel; -public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { @@ -13,7 +13,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) AllowAnonymous(); } - public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct) + public override async Task HandleAsync(GetExperienceLevelDTO req, CancellationToken ct) { Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); diff --git a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs index 3ba32ce..9236f07 100644 --- a/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs +++ b/PyroFetes/Endpoints/ExperienceLevel/GetExperienceLevelEndpoint.cs @@ -5,7 +5,7 @@ using FastEndpoints; namespace PyroFetes.Endpoints.ExperienceLevel; -public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint +public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { @@ -13,7 +13,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : AllowAnonymous(); } - public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct) + public override async Task HandleAsync(GetExperienceLevelDTO req, CancellationToken ct) { Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);