Compare commits

..

22 Commits

Author SHA1 Message Date
carteronm 5d16138ed8 Ajout du niveau d'experience 2026-06-11 11:06:31 +02:00
carteronm 35c99928ad customer type affiché 2026-06-10 21:43:38 +02:00
carteronm a88ce4cc7e Modifs communication 2026-06-09 13:29:58 +02:00
carteronm 7071910dc4 Modifs de nom 2026-06-08 16:02:06 +02:00
carteronm 57adafae16 Renommage d'un endpoint 2026-06-08 14:31:27 +02:00
carteronm af21591669 Modifs de noms et providers 2026-06-07 19:06:45 +02:00
carteronm 7da7c26a2e modifs mineures 2026-06-02 18:11:55 +02:00
carteronm cea2c8cf47 correcting CORS error 2025-12-11 14:31:57 +01:00
carteronm 0beb5f3446 contact updated 2025-12-04 17:45:06 +01:00
carteronm 2b4b2b50df routes updated 2025-12-04 16:53:00 +01:00
carteronm 0cc0eeb439 2nd update provider type 2025-12-04 16:43:16 +01:00
carteronm 6908112755 customer type + communication added 2025-12-04 16:42:15 +01:00
carteronm a554693e9c Provider typê added + delete customer updated 2025-12-04 16:31:52 +01:00
carteronm fc736e8525 provider added 2025-12-04 15:56:02 +01:00
carteronm 604dd77fed change name 2025-12-04 15:32:25 +01:00
carteronm df0756ff50 change route 2025-12-04 15:29:23 +01:00
carteronm 0a001e15e3 add missed dto/enbdpoints 2025-12-04 15:03:10 +01:00
carteronm df622c9232 Adding Comunication 2025-10-16 17:34:58 +02:00
carteronm 5cbbfa1434 Staff DTO / Request Finished 09/10 2025-10-16 17:34:58 +02:00
carteronm df81c7b12d ExperienceLevel Finished (API) 09/10 2025-10-16 17:34:58 +02:00
carteronm 4e64112a31 First Commit 09/10
# Conflicts:
#	PyroFetes/PyroFetes.csproj
2025-10-16 17:34:55 +02:00
carteronm 0e19ef1ab7 Initial commit 2025-10-16 17:34:16 +02:00
104 changed files with 4480 additions and 25 deletions
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>
+66
View File
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d96e474d-65b4-4ba3-b29a-8b061521ff58" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="Toolset" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 5
}]]></component>
<component name="ProjectId" id="33pVanUBtZaJBGFUWpQVCbSMGAe" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "/home/carteronm@stsio.lan/Documents/Projet4/PyroFetes.sln",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d96e474d-65b4-4ba3-b29a-8b061521ff58" name="Changes" comment="" />
<created>1760014067675</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1760014067675</updated>
<workItem from="1760014069254" duration="39000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
<option name="timeStamp" value="1" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
<option name="timeStamp" value="2" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
@@ -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; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Availability.Request;
public class GetAvailabilityRequest
{
public int Id { get; set; }
}
@@ -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; }
}
@@ -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; }
}
@@ -0,0 +1,9 @@
namespace PyroFetes.DTO.Communication.Request;
public class CreateCommunicationDto
{
public string? Calling { get; set; }
public string? Email { get; set; }
public string? Meeting { get; set; }
public int ContactId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Communication.Request;
public class GetCommunicationRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,9 @@
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; }
}
@@ -0,0 +1,16 @@
namespace PyroFetes.DTO.Communication.Response;
public class GetCommunicationDto
{
public int Id { get; set; }
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; }
}
@@ -0,0 +1,13 @@
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? City { get; set; }
public string? Role { get; set; }
public int? CustomerId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Contact.Request;
public class GetContactRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,14 @@
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? City { get; set; }
public string? Role { get; set; }
public int? CustomerTypeId { get; set; }
}
@@ -0,0 +1,14 @@
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? City { get; set; }
public string? Role { get; set; }
public int? CustomerId { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Customer.Request;
public class CreateCustomerDto
{
public string? Note { get; set; }
public int CustomerTypeId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Customer.Request;
public class GetCustomerRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Customer.Request;
public class UpdateCustomerDto
{
public int Id { get; set; }
public string? Note { get; set; }
}
@@ -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; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class CreateCustomerTypeDto
{
public string? Label { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class GetCustomerTypeRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class UpdateCustomerTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.CustomerType.Response;
public class GetCustomerTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.ExperienceLevel.Request;
public class CreateExperienceLevelDto
{
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.ExperienceLevel.Request;
public class GetExperienceLevelDTO
{
public int Id { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.ExperienceLevel.Request;
public class UpdateExperienceLevelDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -0,0 +1,9 @@
namespace PyroFetes.DTO.ExperienceLevel.Response;
public class GetExperienceLevelDto
{
public int Id { get; set; }
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.HistoryOfApproval.Request;
public class CreateHistoryOfApprovalDto
{
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.HistoryOfApproval.Request;
public class GetHistoryOfApprovalRequest
{
public int Id { get; set; }
}
@@ -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; }
}
@@ -0,0 +1,10 @@
namespace PyroFetes.DTO.HistoryOfApproval.Response;
public class GetHistoryOfApprovalDto
{
public int Id { get; set; }
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Provider.Request;
public class CreateProviderDto
{
public decimal Price { get; set; }
public int ProviderTypeId { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Provider.Request;
public class GetProviderRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Provider.Request;
public class UpdateProviderDto
{
public int Id { get; set; }
public decimal Price { get; set; }
}
@@ -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; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class CreateProviderTypeDto
{
public string? Label { get; set; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class GetProviderTypeRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class UpdateProviderTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.ProviderType.Response;
public class GetProviderTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -0,0 +1,11 @@
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; }
}
@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Staff.Request;
public class GetStaffRequest
{
public int Id { get; set; }
}
@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.Staff.Request;
public class UpdateStaffDto
{
public int Id { get; set; }
public string? F4T2NumberApproval { get; set; }
public DateOnly F4T2ExpirationDate { get; set; }
}
@@ -0,0 +1,14 @@
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; }
}
@@ -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<CreateAvailabilityDto, GetAvailabilityDto>
{
public override void Configure()
{
Post("/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);
}
}
@@ -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 <GetAvailabilityRequest, GetAvailabilityDto>
{
public override void Configure()
{
Delete ("/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);
}
}
@@ -0,0 +1,28 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Availability.Response;
namespace PyroFetes.Endpoints.Availability;
public class GetAllAvailabilityxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetAvailabilityDto>>
{
public override void Configure()
{
Get ("/availabilities");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetAvailabilityDto> 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);
}
}
@@ -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 <GetAvailabilityRequest, GetAvailabilityDto>
{
public override void Configure()
{
Get ("/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);
}
}
@@ -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 <UpdateAvailabilityDto, GetAvailabilityDto>
{
public override void Configure()
{
Put ("/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);
}
}
@@ -0,0 +1,42 @@
using FastEndpoints;
using PyroFetes.DTO.Communication.Request;
using PyroFetes.DTO.Communication.Response;
namespace PyroFetes.Endpoints.Communication;
public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateCommunicationDto, GetCommunicationDto>
{
public override void Configure()
{
Post("/communications");
AllowAnonymous();
}
public override async Task HandleAsync(CreateCommunicationDto req, CancellationToken ct)
{
Models.Communication communication = new()
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting,
ContactId = req.ContactId
};
pyroFetesDbContext.Add(communication);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetCommunicationDto response = new()
{
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);
}
}
@@ -0,0 +1,31 @@
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 <GetCommunicationRequest, GetCommunicationDto>
{
public override void Configure()
{
Delete ("/communications/{@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);
}
}
@@ -0,0 +1,32 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Communication.Response;
namespace PyroFetes.Endpoints.Communication;
public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCommunicationDto>>
{
public override void Configure()
{
Get ("/communications");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetCommunicationDto> 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);
}
}
@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Communication.Request;
using PyroFetes.DTO.Communication.Response;
namespace PyroFetes.Endpoints.Communication;
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationRequest, GetCommunicationDto>
{
public override void Configure()
{
Get ("/communications/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetCommunicationRequest database, CancellationToken ct)
{
Models.Communication? databaseCommunications = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: 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);
}
}
@@ -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 <UpdateCommunicationDto, GetCommunicationDto>
{
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);
}
}
@@ -0,0 +1,56 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Contact.Request;
using PyroFetes.DTO.Contact.Response;
namespace PyroFetes.Endpoints.Contact;
public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateContactDto, GetContactDto>
{
public override void Configure()
{
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,
FirstName = req.FirstName,
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);
GetContactDto response = new()
{
LastName = contact.LastName,
FirstName = contact.FirstName,
PhoneNumber = contact.PhoneNumber,
Email = contact.Email,
Address = contact.Address,
City = contact.City,
Role = contact.Role,
CustomerId = databaseCustomer.Id,
};
await Send.OkAsync(response, ct);
}
}
@@ -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 <GetContactRequest, GetContactDto>
{
public override void Configure()
{
Delete ("/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);
}
}
@@ -0,0 +1,30 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Contact.Response;
namespace PyroFetes.Endpoints.Contact;
public class GetAllContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
{
public override void Configure()
{
Get ("/contacts");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetContactDto> 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);
}
}
@@ -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 <GetContactRequest, GetContactDto>
{
public override void Configure()
{
Get ("/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);
}
}
@@ -0,0 +1,51 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Contact.Request;
using PyroFetes.DTO.Contact.Response;
namespace PyroFetes.Endpoints.Contact;
public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
{
public override void Configure()
{
Put ("/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.City = req.City;
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,
City = req.City,
Role = req.Role,
};
await Send.OkAsync(dto, ct);
}
}
@@ -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<CreateCustomerDto, GetCustomerDto>
{
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);
}
}
@@ -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 <GetCustomerRequest, GetCustomerDto>
{
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);
}
}
@@ -0,0 +1,26 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Customer.Response;
namespace PyroFetes.Endpoints.Customer;
public class GetAllCustomerEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCustomerDto>>
{
public override void Configure()
{
Get ("/customers");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetCustomerDto> 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);
}
}
@@ -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 <GetCustomerRequest, GetCustomerDto>
{
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);
}
}
@@ -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 <UpdateCustomerDto, GetCustomerDto>
{
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);
}
}
@@ -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<CreateCustomerTypeDto, GetCustomerTypeDto>
{
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);
}
}
@@ -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 <GetCustomerTypeRequest, GetCustomerTypeDto>
{
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);
}
}
@@ -0,0 +1,25 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.CustomerType.Response;
namespace PyroFetes.Endpoints.CustomerType;
public class GetAllCustomerTypeEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCustomerTypeDto>>
{
public override void Configure()
{
Get ("/customertypes");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetCustomerTypeDto> customerType= await pyroFetesDbContext.CustomerTypes.Select(x => new GetCustomerTypeDto()
{
Id = x.Id,
Label = x.Label,
}).ToListAsync(ct);
await Send.OkAsync(customerType, ct);
}
}
@@ -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 <GetCustomerTypeRequest, GetCustomerTypeDto>
{
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);
}
}
@@ -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 <UpdateCustomerTypeDto, GetCustomerTypeDto>
{
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);
}
}
@@ -0,0 +1,47 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Response;
using PyroFetes.DTO.ExperienceLevel.Request;
namespace PyroFetes.Endpoints.ExperienceLevel;
public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateExperienceLevelDto, GetExperienceLevelDto>
{
public override void Configure()
{
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,
StaffId = databaseStaff.Id,
};
pyroFetesDbContext.Add(experienceLevel);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetExperienceLevelDto response = new()
{
Id = experienceLevel.Id,
Label = experienceLevel.Label,
StaffId = experienceLevel.StaffId
};
await Send.OkAsync(response, ct);
}
}
@@ -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 <GetExperienceLevelDTO, GetExperienceLevelDto>
{
public override void Configure()
{
Delete ("/experiencelevels/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetExperienceLevelDTO 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);
}
}
@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Response;
namespace PyroFetes.Endpoints.ExperienceLevel;
using FastEndpoints;
public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetExperienceLevelDto>>
{
public override void Configure()
{
Get ("/experiencelevels");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetExperienceLevelDto> experienceLevels= await pyroFetesDbContext.ExperienceLevels.Select(x => new GetExperienceLevelDto()
{
Id = x.Id,
Label = x.Label,
}).ToListAsync(ct);
await Send.OkAsync(experienceLevels, ct);
}
}
@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Request;
using PyroFetes.DTO.ExperienceLevel.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.ExperienceLevel;
public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetExperienceLevelDTO, GetExperienceLevelDto>
{
public override void Configure()
{
Get ("/experiencelevels/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetExperienceLevelDTO 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);
}
}
@@ -0,0 +1,39 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Request;
using PyroFetes.DTO.ExperienceLevel.Response;
namespace PyroFetes.Endpoints.ExperienceLevel;
public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateExperienceLevelDto, GetExperienceLevelDto>
{
public override void Configure()
{
Put ("/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);
}
}
@@ -0,0 +1,49 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Request;
using PyroFetes.DTO.HistoryOfApproval.Response;
namespace PyroFetes.Endpoints.HistoryOfApproval;
public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateHistoryOfApprovalDto, GetHistoryOfApprovalDto>
{
public override void Configure()
{
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,
StaffId = databaseStaff.Id,
};
pyroFetesDbContext.Add(historyOfApproval);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetHistoryOfApprovalDto response = new()
{
Id = historyOfApproval.Id,
DeliveryDate = historyOfApproval.DeliveryDate,
ExpirationDate = historyOfApproval.ExpirationDate,
StaffId = historyOfApproval.StaffId,
};
await Send.OkAsync(response, ct);
}
}
@@ -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 <GetHistoryOfApprovalRequest, GetHistoryOfApprovalDto>
{
public override void Configure()
{
Delete ("/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);
}
}
@@ -0,0 +1,27 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Response;
namespace PyroFetes.Endpoints.HistoryOfApproval;
public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetHistoryOfApprovalDto>>
{
public override void Configure()
{
Get ("/historyofapprovals");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetHistoryOfApprovalDto> historyOfApprovals= await pyroFetesDbContext.HistoryOfApprovals.Select(x => new GetHistoryOfApprovalDto()
{
Id = x.Id,
DeliveryDate = x.DeliveryDate,
ExpirationDate = x.ExpirationDate,
StaffId = x.StaffId,
}).ToListAsync(ct);
await Send.OkAsync(historyOfApprovals, ct);
}
}
@@ -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 <GetHistoryOfApprovalRequest, GetHistoryOfApprovalDto>
{
public override void Configure()
{
Get ("/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);
}
}
@@ -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 <UpdateHistoryOfApprovalDto, GetHistoryOfApprovalDto>
{
public override void Configure()
{
Put ("/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);
}
}
@@ -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<CreateProviderDto, GetProviderDto>
{
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);
}
}
@@ -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 <GetProviderRequest, GetProviderDto>
{
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);
}
}
@@ -0,0 +1,27 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Provider.Response;
namespace PyroFetes.Endpoints.Provider;
public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetProviderDto>>
{
public override void Configure()
{
Get ("/serviceproviders");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetProviderDto> 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);
}
}
@@ -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 <GetProviderRequest, GetProviderDto>
{
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);
}
}
@@ -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 <UpdateProviderDto, GetProviderDto>
{
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);
}
}
@@ -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<CreateProviderTypeDto, GetProviderTypeDto>
{
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);
}
}
@@ -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 <GetProviderTypeRequest, GetProviderTypeDto>
{
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);
}
}
@@ -0,0 +1,25 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ProviderType.Response;
namespace PyroFetes.Endpoints.ProviderType;
public class GetAllProviderTypesEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetProviderTypeDto>>
{
public override void Configure()
{
Get ("/providertypes");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetProviderTypeDto> providerType= await pyroFetesDbContext.ProviderTypes.Select(x => new GetProviderTypeDto()
{
Id = x.Id,
Label = x.Label,
}).ToListAsync(ct);
await Send.OkAsync(providerType, ct);
}
}
@@ -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 <GetProviderTypeRequest, GetProviderTypeDto>
{
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);
}
}
@@ -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 <UpdateProviderTypeDto, GetProviderTypeDto>
{
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);
}
}
@@ -0,0 +1,42 @@
using FastEndpoints;
using PyroFetes.DTO.Staff.Request;
using PyroFetes.DTO.Staff.Response;
namespace PyroFetes.Endpoints.Staff;
public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateStaffDto, GetStaffDto>
{
public override void Configure()
{
Post("/staffs");
AllowAnonymous();
}
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
{
Models.Staff staff = new()
{
FirstName = req.FirstName,
LastName = req.LastName,
Profession = req.Profession,
Email = req.Email,
F4T2NumberApproval = req.F4T2NumberApproval,
F4T2ExpirationDate = req.F4T2ExpirationDate,
};
pyroFetesDbContext.Add(staff);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetStaffDto response = new()
{
FirstName = staff.FirstName,
LastName = staff.LastName,
Profession = staff.Profession,
Email = staff.Email,
F4T2NumberApproval = staff.F4T2NumberApproval,
F4T2ExpirationDate = staff.F4T2ExpirationDate,
};
await Send.OkAsync(response, ct);
}
}
@@ -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 <GetStaffRequest, GetStaffDto>
{
public override void Configure()
{
Delete ("/staffs/{@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);
}
}
@@ -0,0 +1,34 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Staff.Response;
namespace PyroFetes.Endpoints.Staff;
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
{
public override void Configure()
{
Get("/staffs");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetStaffDto> 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);
}
}
@@ -0,0 +1,39 @@
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 <GetStaffRequest, GetStaffDto>
{
public override void Configure()
{
Get ("/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,
FirstName = databaseStaff.FirstName,
LastName = databaseStaff.LastName,
Profession = databaseStaff.Profession,
Email = databaseStaff.Email,
F4T2NumberApproval = databaseStaff.F4T2NumberApproval,
F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate,
};
await Send.OkAsync(dto, ct);
}
}
@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Staff.Request;
using PyroFetes.DTO.Staff.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Staff;
public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
{
public override void Configure()
{
Put ("/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,
FirstName = databaseStaff.FirstName,
LastName = databaseStaff.LastName,
Profession = databaseStaff.Profession,
Email = databaseStaff.Email,
F4T2NumberApproval = req.F4T2NumberApproval,
F4T2ExpirationDate = req.F4T2ExpirationDate,
};
await Send.OkAsync(dto, ct);
}
}
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PyroFetes.Migrations
{
/// <inheritdoc />
public partial class HOA : Migration
{
/// <inheritdoc />
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<int>(
name: "StaffId",
table: "HistoryOfApprovals",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AlterColumn<string>(
name: "Meeting",
table: "Communications",
type: "nvarchar(300)",
maxLength: 300,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(300)",
oldMaxLength: 300);
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
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);
}
/// <inheritdoc />
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<string>(
name: "Meeting",
table: "Communications",
type: "nvarchar(300)",
maxLength: 300,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(300)",
oldMaxLength: 300,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
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);
}
}
}
@@ -136,7 +136,6 @@ namespace PyroFetes.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Calling")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
@@ -144,12 +143,10 @@ namespace PyroFetes.Migrations
.HasColumnType("int");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("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<DateOnly>("ExpirationDate")
.HasColumnType("date");
b.Property<int>("StaffId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("HistoryOfApprovals");
@@ -781,7 +782,7 @@ namespace PyroFetes.Migrations
b.HasIndex("ProviderTypeId");
b.ToTable("Providers");
b.ToTable("ServiceProviders");
});
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
@@ -1333,8 +1334,8 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
{
b.HasOne("PyroFetes.Models.Staff", "Staff")
.WithMany("ExperienceLevels")
.HasForeignKey("StaffId")
.WithOne("ExperienceLevel")
.HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -1911,7 +1912,8 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
{
b.Navigation("ExperienceLevels");
b.Navigation("ExperienceLevel")
.IsRequired();
b.Navigation("ShowStaffs");
+3 -3
View File
@@ -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; }
+14
View File
@@ -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; }
}
+2
View File
@@ -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<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
}

Some files were not shown because too many files have changed in this diff Show More