Merge vers master
This commit is contained in:
@@ -5,4 +5,5 @@ public class CreateCommunicationDto
|
|||||||
public string? Calling { get; set; }
|
public string? Calling { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Meeting { get; set; }
|
public string? Meeting { get; set; }
|
||||||
|
public int ContactId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,11 @@ public class GetCommunicationDto
|
|||||||
public string? Calling { get; set; }
|
public string? Calling { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Meeting { 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; }
|
||||||
}
|
}
|
||||||
@@ -7,5 +7,7 @@ public class CreateContactDto
|
|||||||
public string? PhoneNumber { get; set; }
|
public string? PhoneNumber { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
public string? City { get; set; }
|
||||||
public string? Role { get; set; }
|
public string? Role { get; set; }
|
||||||
|
public int? CustomerId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -8,5 +8,7 @@ public class UpdateContactDto
|
|||||||
public string? PhoneNumber { get; set; }
|
public string? PhoneNumber { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
public string? City { get; set; }
|
||||||
public string? Role { get; set; }
|
public string? Role { get; set; }
|
||||||
|
public int? CustomerTypeId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -8,5 +8,7 @@ public class GetContactDto
|
|||||||
public string? PhoneNumber { get; set; }
|
public string? PhoneNumber { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
public string? City { get; set; }
|
||||||
public string? Role { 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; }
|
||||||
|
}
|
||||||
@@ -3,4 +3,5 @@ namespace PyroFetes.DTO.ExperienceLevel.Request;
|
|||||||
public class CreateExperienceLevelDto
|
public class CreateExperienceLevelDto
|
||||||
{
|
{
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
|
public int? StaffId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,6 @@ public class GetExperienceLevelDto
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
|
|
||||||
|
public int? StaffId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,5 @@ public class CreateHistoryOfApprovalDto
|
|||||||
{
|
{
|
||||||
public DateOnly DeliveryDate { get; set; }
|
public DateOnly DeliveryDate { get; set; }
|
||||||
public DateOnly ExpirationDate { get; set; }
|
public DateOnly ExpirationDate { get; set; }
|
||||||
|
public int StaffId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,6 @@ public class GetHistoryOfApprovalDto
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateOnly DeliveryDate { get; set; }
|
public DateOnly DeliveryDate { get; set; }
|
||||||
public DateOnly ExpirationDate { 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; }
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@ namespace PyroFetes.DTO.Staff.Request;
|
|||||||
|
|
||||||
public class CreateStaffDto
|
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 string? F4T2NumberApproval { get; set; }
|
||||||
public DateOnly F4T2ExpirationDate { get; set; }
|
public DateOnly F4T2ExpirationDate { get; set; }
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,12 @@ namespace PyroFetes.DTO.Staff.Response;
|
|||||||
public class GetStaffDto
|
public class GetStaffDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
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 string? F4T2NumberApproval { get; set; }
|
||||||
public DateOnly F4T2ExpirationDate { get; set; }
|
public DateOnly F4T2ExpirationDate { get; set; }
|
||||||
|
public string? ExperienceLevel { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ public class CreateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/availabilities");
|
Post("/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
|
Delete ("/availabilities/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllAvailabilityxuest(PyroFetesDbContext pyroFetesDbContext) : En
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/availabilities");
|
Get ("/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/availabilities/{@Id}", x => new { x.Id });
|
Get ("/availabilities/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/api/availabilities/{@Id}", x => new { x.Id });
|
Put ("/availabilities/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/communications");
|
Post("/communications");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,16 +19,22 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
|||||||
{
|
{
|
||||||
Calling = req.Calling,
|
Calling = req.Calling,
|
||||||
Email = req.Email,
|
Email = req.Email,
|
||||||
Meeting = req.Meeting
|
Meeting = req.Meeting,
|
||||||
|
ContactId = req.ContactId
|
||||||
};
|
};
|
||||||
pyroFetesDbContext.Add(communication);
|
pyroFetesDbContext.Add(communication);
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetCommunicationDto response = new()
|
GetCommunicationDto response = new()
|
||||||
{
|
{
|
||||||
Calling = req.Calling,
|
Calling = communication.Calling,
|
||||||
Email = req.Email,
|
Email = communication.Email,
|
||||||
Meeting = req.Meeting
|
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);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Availability.Request;
|
using PyroFetes.DTO.Availability.Request;
|
||||||
|
using PyroFetes.DTO.Communication.Request;
|
||||||
using PyroFetes.DTO.Communication.Response;
|
using PyroFetes.DTO.Communication.Response;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Communication;
|
namespace PyroFetes.Endpoints.Communication;
|
||||||
|
|
||||||
public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationDto, GetCommunicationEndpoint>
|
public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationRequest, GetCommunicationDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
|
Delete ("/communications/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,36 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Availability.Response;
|
using PyroFetes.DTO.Communication.Request;
|
||||||
using PyroFetes.DTO.Communication.Response;
|
using PyroFetes.DTO.Communication.Response;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Communication;
|
namespace PyroFetes.Endpoints.Communication;
|
||||||
|
|
||||||
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCommunicationDto>>
|
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationRequest, GetCommunicationDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/availabilities");
|
Get ("/communications/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(GetCommunicationRequest database, CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto()
|
Models.Communication? databaseCommunications = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct);
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
Calling = x.Calling,
|
|
||||||
Email = x.Email,
|
|
||||||
Meeting = x.Meeting,
|
|
||||||
}).ToListAsync(ct);
|
|
||||||
|
|
||||||
await Send.OkAsync(communications, ct);
|
if (databaseCommunications == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetCommunicationDto dto = new()
|
||||||
|
{
|
||||||
|
Id = databaseCommunications.Id,
|
||||||
|
Calling = databaseCommunications.Calling,
|
||||||
|
Email = databaseCommunications.Email,
|
||||||
|
Meeting = databaseCommunications.Meeting
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(dto, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Contact.Request;
|
using PyroFetes.DTO.Contact.Request;
|
||||||
using PyroFetes.DTO.Contact.Response;
|
using PyroFetes.DTO.Contact.Response;
|
||||||
|
|
||||||
@@ -8,13 +9,22 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/contacts");
|
Post("/contacts");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateContactDto req, CancellationToken ct)
|
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()
|
Models.Contact contact = new()
|
||||||
{
|
{
|
||||||
LastName = req.LastName,
|
LastName = req.LastName,
|
||||||
@@ -22,7 +32,9 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
PhoneNumber = req.PhoneNumber,
|
PhoneNumber = req.PhoneNumber,
|
||||||
Email = req.Email,
|
Email = req.Email,
|
||||||
Address = req.Address,
|
Address = req.Address,
|
||||||
|
City = req.City,
|
||||||
Role = req.Role,
|
Role = req.Role,
|
||||||
|
CustomerId = databaseCustomer.Id,
|
||||||
};
|
};
|
||||||
pyroFetesDbContext.Add(contact);
|
pyroFetesDbContext.Add(contact);
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
@@ -34,7 +46,9 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
PhoneNumber = contact.PhoneNumber,
|
PhoneNumber = contact.PhoneNumber,
|
||||||
Email = contact.Email,
|
Email = contact.Email,
|
||||||
Address = contact.Address,
|
Address = contact.Address,
|
||||||
|
City = contact.City,
|
||||||
Role = contact.Role,
|
Role = contact.Role,
|
||||||
|
CustomerId = databaseCustomer.Id,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(response, ct);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/Contacts/{@Id}", x => new { x.Id });
|
Delete ("/contacts/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ using PyroFetes.DTO.Contact.Response;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Contact;
|
namespace PyroFetes.Endpoints.Contact;
|
||||||
|
|
||||||
public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
|
public class GetAllContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/contacts");
|
Get ("/contacts");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/contacts/{@Id}", x => new { x.Id });
|
Get ("/contacts/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -5,11 +5,11 @@ using PyroFetes.DTO.Contact.Response;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Contact;
|
namespace PyroFetes.Endpoints.Contact;
|
||||||
|
|
||||||
public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
|
public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/api/contacts/{@Id}", x => new { x.Id });
|
Put ("/contacts/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo
|
|||||||
databaseContact.PhoneNumber = req.PhoneNumber;
|
databaseContact.PhoneNumber = req.PhoneNumber;
|
||||||
databaseContact.Email = req.Email;
|
databaseContact.Email = req.Email;
|
||||||
databaseContact.Address = req.Address;
|
databaseContact.Address = req.Address;
|
||||||
|
databaseContact.City = req.City;
|
||||||
databaseContact.Role = req.Role;
|
databaseContact.Role = req.Role;
|
||||||
}
|
}
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
@@ -41,6 +42,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo
|
|||||||
PhoneNumber = req.PhoneNumber,
|
PhoneNumber = req.PhoneNumber,
|
||||||
Email = req.Email,
|
Email = req.Email,
|
||||||
Address = req.Address,
|
Address = req.Address,
|
||||||
|
City = req.City,
|
||||||
Role = req.Role,
|
Role = req.Role,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.ExperienceLevel.Response;
|
using PyroFetes.DTO.ExperienceLevel.Response;
|
||||||
using PyroFetes.DTO.ExperienceLevel.Request;
|
using PyroFetes.DTO.ExperienceLevel.Request;
|
||||||
|
|
||||||
@@ -9,15 +10,26 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/ExperienceLevels");
|
Post("/experiencelevels");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateExperienceLevelDto req, CancellationToken ct)
|
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()
|
Models.ExperienceLevel experienceLevel = new()
|
||||||
{
|
{
|
||||||
Label = req.Label
|
Label = req.Label,
|
||||||
|
StaffId = databaseStaff.Id,
|
||||||
};
|
};
|
||||||
pyroFetesDbContext.Add(experienceLevel);
|
pyroFetesDbContext.Add(experienceLevel);
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
@@ -26,6 +38,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
|||||||
{
|
{
|
||||||
Id = experienceLevel.Id,
|
Id = experienceLevel.Id,
|
||||||
Label = experienceLevel.Label,
|
Label = experienceLevel.Label,
|
||||||
|
StaffId = experienceLevel.StaffId
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(response, ct);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id });
|
Delete ("/experiencelevels/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/experienceLevels");
|
Get ("/experiencelevels");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/experienceLevels/{@Id}", x => new { x.Id });
|
Get ("/experiencelevels/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id });
|
Put ("/experiencelevels/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.HistoryOfApproval.Request;
|
using PyroFetes.DTO.HistoryOfApproval.Request;
|
||||||
using PyroFetes.DTO.HistoryOfApproval.Response;
|
using PyroFetes.DTO.HistoryOfApproval.Response;
|
||||||
|
|
||||||
@@ -8,17 +9,28 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/HistoryOfApprovals");
|
Post("/historyofapprovals");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateHistoryOfApprovalDto req, CancellationToken ct)
|
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()
|
Models.HistoryOfApproval historyOfApproval = new()
|
||||||
{
|
{
|
||||||
DeliveryDate = req.DeliveryDate,
|
DeliveryDate = req.DeliveryDate,
|
||||||
ExpirationDate = req.ExpirationDate
|
ExpirationDate = req.ExpirationDate,
|
||||||
|
StaffId = databaseStaff.Id,
|
||||||
};
|
};
|
||||||
pyroFetesDbContext.Add(historyOfApproval);
|
pyroFetesDbContext.Add(historyOfApproval);
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
@@ -27,7 +39,8 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
Id = historyOfApproval.Id,
|
Id = historyOfApproval.Id,
|
||||||
DeliveryDate = historyOfApproval.DeliveryDate,
|
DeliveryDate = historyOfApproval.DeliveryDate,
|
||||||
ExpirationDate = historyOfApproval.ExpirationDate
|
ExpirationDate = historyOfApproval.ExpirationDate,
|
||||||
|
StaffId = historyOfApproval.StaffId,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(response, ct);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
|
Delete ("/historyofapprovals/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/HistoryOfApprovals");
|
Get ("/historyofapprovals");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
DeliveryDate = x.DeliveryDate,
|
DeliveryDate = x.DeliveryDate,
|
||||||
ExpirationDate = x.ExpirationDate,
|
ExpirationDate = x.ExpirationDate,
|
||||||
|
StaffId = x.StaffId,
|
||||||
}).ToListAsync(ct);
|
}).ToListAsync(ct);
|
||||||
|
|
||||||
await Send.OkAsync(historyOfApprovals, ct);
|
await Send.OkAsync(historyOfApprovals, ct);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
|
Get ("/historyofapprovals/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
|
Put ("/historyofapprovals/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/api/availabilities");
|
Post("/staffs");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,6 +17,10 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
{
|
{
|
||||||
Models.Staff staff = new()
|
Models.Staff staff = new()
|
||||||
{
|
{
|
||||||
|
FirstName = req.FirstName,
|
||||||
|
LastName = req.LastName,
|
||||||
|
Profession = req.Profession,
|
||||||
|
Email = req.Email,
|
||||||
F4T2NumberApproval = req.F4T2NumberApproval,
|
F4T2NumberApproval = req.F4T2NumberApproval,
|
||||||
F4T2ExpirationDate = req.F4T2ExpirationDate,
|
F4T2ExpirationDate = req.F4T2ExpirationDate,
|
||||||
};
|
};
|
||||||
@@ -25,6 +29,10 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
|
|
||||||
GetStaffDto response = new()
|
GetStaffDto response = new()
|
||||||
{
|
{
|
||||||
|
FirstName = staff.FirstName,
|
||||||
|
LastName = staff.LastName,
|
||||||
|
Profession = staff.Profession,
|
||||||
|
Email = staff.Email,
|
||||||
F4T2NumberApproval = staff.F4T2NumberApproval,
|
F4T2NumberApproval = staff.F4T2NumberApproval,
|
||||||
F4T2ExpirationDate = staff.F4T2ExpirationDate,
|
F4T2ExpirationDate = staff.F4T2ExpirationDate,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/api/staff/{@Id}", x => new { x.Id });
|
Delete ("/staffs/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,21 +7,28 @@ namespace PyroFetes.Endpoints.Staff;
|
|||||||
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
|
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/availabilities");
|
Get("/staffs");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
|
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs
|
||||||
{
|
.Include(x => x.ExperienceLevel)
|
||||||
Id = x.Id,
|
.Select(x => new GetStaffDto()
|
||||||
F4T2NumberApproval = x.F4T2NumberApproval,
|
{
|
||||||
F4T2ExpirationDate = x.F4T2ExpirationDate,
|
Id = x.Id,
|
||||||
|
FirstName = x.FirstName,
|
||||||
}).ToListAsync(ct);
|
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);
|
await Send.OkAsync(staff, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/api/Staffs/{@Id}", x => new { x.Id });
|
Get ("/staffs/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +26,10 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint
|
|||||||
GetStaffDto dto = new()
|
GetStaffDto dto = new()
|
||||||
{
|
{
|
||||||
Id = databaseStaff.Id,
|
Id = databaseStaff.Id,
|
||||||
|
FirstName = databaseStaff.FirstName,
|
||||||
|
LastName = databaseStaff.LastName,
|
||||||
|
Profession = databaseStaff.Profession,
|
||||||
|
Email = databaseStaff.Email,
|
||||||
F4T2NumberApproval = databaseStaff.F4T2NumberApproval,
|
F4T2NumberApproval = databaseStaff.F4T2NumberApproval,
|
||||||
F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate,
|
F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate,
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-2
@@ -5,11 +5,11 @@ using FastEndpoints;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
|
public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/api/Staffs/{@Id}", x => new { x.Id });
|
Put ("/staffs/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +32,10 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
GetStaffDto dto = new()
|
GetStaffDto dto = new()
|
||||||
{
|
{
|
||||||
Id = databaseStaff.Id,
|
Id = databaseStaff.Id,
|
||||||
|
FirstName = databaseStaff.FirstName,
|
||||||
|
LastName = databaseStaff.LastName,
|
||||||
|
Profession = databaseStaff.Profession,
|
||||||
|
Email = databaseStaff.Email,
|
||||||
F4T2NumberApproval = req.F4T2NumberApproval,
|
F4T2NumberApproval = req.F4T2NumberApproval,
|
||||||
F4T2ExpirationDate = req.F4T2ExpirationDate,
|
F4T2ExpirationDate = req.F4T2ExpirationDate,
|
||||||
};
|
};
|
||||||
+1953
File diff suppressed because it is too large
Load Diff
@@ -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"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Calling")
|
b.Property<string>("Calling")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(100)
|
.HasMaxLength(100)
|
||||||
.HasColumnType("nvarchar(100)");
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
@@ -144,12 +143,10 @@ namespace PyroFetes.Migrations
|
|||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(100)
|
.HasMaxLength(100)
|
||||||
.HasColumnType("nvarchar(100)");
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
b.Property<string>("Meeting")
|
b.Property<string>("Meeting")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(300)
|
.HasMaxLength(300)
|
||||||
.HasColumnType("nvarchar(300)");
|
.HasColumnType("nvarchar(300)");
|
||||||
|
|
||||||
@@ -377,7 +374,8 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("StaffId");
|
b.HasIndex("StaffId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("ExperienceLevels");
|
b.ToTable("ExperienceLevels");
|
||||||
});
|
});
|
||||||
@@ -396,6 +394,9 @@ namespace PyroFetes.Migrations
|
|||||||
b.Property<DateOnly>("ExpirationDate")
|
b.Property<DateOnly>("ExpirationDate")
|
||||||
.HasColumnType("date");
|
.HasColumnType("date");
|
||||||
|
|
||||||
|
b.Property<int>("StaffId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("HistoryOfApprovals");
|
b.ToTable("HistoryOfApprovals");
|
||||||
@@ -780,7 +781,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ProviderTypeId");
|
b.HasIndex("ProviderTypeId");
|
||||||
|
|
||||||
b.ToTable("Providers");
|
b.ToTable("ServiceProviders");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
|
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
|
||||||
@@ -1332,8 +1333,8 @@ namespace PyroFetes.Migrations
|
|||||||
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
|
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("PyroFetes.Models.Staff", "Staff")
|
b.HasOne("PyroFetes.Models.Staff", "Staff")
|
||||||
.WithMany("ExperienceLevels")
|
.WithOne("ExperienceLevel")
|
||||||
.HasForeignKey("StaffId")
|
.HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
@@ -1910,7 +1911,8 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
|
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ExperienceLevels");
|
b.Navigation("ExperienceLevel")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("ShowStaffs");
|
b.Navigation("ShowStaffs");
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ namespace PyroFetes.Models;
|
|||||||
public class Communication
|
public class Communication
|
||||||
{
|
{
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Calling { get; set; }
|
[MaxLength(100)] public string? Calling { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Email { get; set; }
|
[MaxLength(100)] public string? Email { get; set; }
|
||||||
[Required, MaxLength(300)] public string? Meeting { get; set; }
|
[MaxLength(300)] public string? Meeting { get; set; }
|
||||||
|
|
||||||
[Required] public int ContactId { get; set; }
|
[Required] public int ContactId { get; set; }
|
||||||
public Contact? Contact { get; set; }
|
public Contact? Contact { get; set; }
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
}
|
||||||
@@ -8,5 +8,7 @@ public class HistoryOfApproval
|
|||||||
[Required] public DateOnly DeliveryDate { get; set; }
|
[Required] public DateOnly DeliveryDate { get; set; }
|
||||||
[Required] public DateOnly ExpirationDate { get; set; }
|
[Required] public DateOnly ExpirationDate { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public int StaffId { get; set; }
|
||||||
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
|
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ public class Staff
|
|||||||
[Required] public DateOnly F4T2ExpirationDate { get; set; }
|
[Required] public DateOnly F4T2ExpirationDate { get; set; }
|
||||||
|
|
||||||
public List<ShowStaff>? ShowStaffs { get; set; }
|
public List<ShowStaff>? ShowStaffs { get; set; }
|
||||||
public List<ExperienceLevel>? ExperienceLevels { get; set; }
|
public ExperienceLevel ExperienceLevel { get; set; }
|
||||||
public List<StaffAvailability>? StaffAvailabilities { get; set; }
|
public List<StaffAvailability>? StaffAvailabilities { get; set; }
|
||||||
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
|
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
|
||||||
public List<StaffContact>? StaffContacts { get; set; }
|
public List<StaffContact>? StaffContacts { get; set; }
|
||||||
|
|||||||
+36
-12
@@ -1,19 +1,43 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
using PyroFetes;
|
||||||
|
using FastEndpoints;
|
||||||
|
using FastEndpoints.Swagger;
|
||||||
|
using FastEndpoints.Security;
|
||||||
|
|
||||||
// Add services to the container.
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||||
|
builder.Services
|
||||||
|
.AddAuthenticationJwtBearer(s => s.SigningKey = "zewsxrdctfvgybuhbgyvftrcdtfvgbyuhn")
|
||||||
|
.AddAuthorization()
|
||||||
|
.AddFastEndpoints().SwaggerDocument(options => { options.ShortSchemaNames = true;});
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// On ajoute ici la configuration de la base de données
|
||||||
if (app.Environment.IsDevelopment())
|
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||||
{
|
|
||||||
app.UseSwagger();
|
//On ajoute le CORS au code
|
||||||
app.UseSwaggerUI();
|
builder.Services.AddCors(options =>
|
||||||
}
|
{ options.AddDefaultPolicy(policyBuilder =>
|
||||||
|
{
|
||||||
|
policyBuilder
|
||||||
|
.WithOrigins("http://localhost:4200")
|
||||||
|
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
|
||||||
|
.AllowAnyHeader();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// On construit l'application en lui donnant vie
|
||||||
|
WebApplication app = builder.Build();
|
||||||
|
app.UseAuthentication()
|
||||||
|
.UseAuthorization()
|
||||||
|
.UseFastEndpoints(options =>
|
||||||
|
{
|
||||||
|
options.Endpoints.RoutePrefix = "API";
|
||||||
|
options.Endpoints.ShortNames = true;
|
||||||
|
}
|
||||||
|
).UseSwaggerGen();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
||||||
|
<PackageReference Include="FastEndpoints.Security" Version="7.0.1" />
|
||||||
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class PyroFetesDbContext : DbContext
|
|||||||
public DbSet<ProductColor> ProductColors { get; set; }
|
public DbSet<ProductColor> ProductColors { get; set; }
|
||||||
public DbSet<ProductDelivery> ProductDeliveries { get; set; }
|
public DbSet<ProductDelivery> ProductDeliveries { get; set; }
|
||||||
public DbSet<ProductEffect> ProductEffects { get; set; }
|
public DbSet<ProductEffect> ProductEffects { get; set; }
|
||||||
public DbSet<ServiceProvider> Providers { get; set; }
|
public DbSet<ServiceProvider> ServiceProviders { get; set; }
|
||||||
public DbSet<ProviderContact> ProviderContacts { get; set; }
|
public DbSet<ProviderContact> ProviderContacts { get; set; }
|
||||||
public DbSet<ProviderType> ProviderTypes { get; set; }
|
public DbSet<ProviderType> ProviderTypes { get; set; }
|
||||||
public DbSet<PurchaseOrder> PurchaseOrders { get; set; }
|
public DbSet<PurchaseOrder> PurchaseOrders { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user