Compare commits

..

5 Commits

Author SHA1 Message Date
carteronm 92e71e76b9 Adding Comunication 2025-10-16 17:05:52 +02:00
carteronm 91a5c63ff5 Staff DTO / Request Finished 09/10 2025-10-09 17:48:07 +02:00
carteronm 7d52b24ed8 ExperienceLevel Finished (API) 09/10 2025-10-09 17:19:05 +02:00
carteronm 8a9df1a4a1 First Commit 09/10 2025-10-09 17:12:17 +02:00
carteronm 1e9b458793 Initial commit 2025-10-09 17:10:51 +02:00
87 changed files with 83 additions and 3298 deletions
@@ -5,5 +5,4 @@ public class CreateCommunicationDto
public string? Calling { get; set; }
public string? Email { get; set; }
public string? Meeting { get; set; }
public int ContactId { get; set; }
}
@@ -6,11 +6,4 @@ public class GetCommunicationDto
public string? Calling { get; set; }
public string? Email { get; set; }
public string? Meeting { get; set; }
public int ContactId { get; set; }
public string? ContactFirstName { get; set; }
public string? ContactLastName { get; set; }
public string? ContactEmail { get; set; }
public string? ContactPhoneNumber { get; set; }
}
@@ -7,7 +7,5 @@ public class CreateContactDto
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? Role { get; set; }
public int? CustomerId { get; set; }
}
@@ -8,7 +8,5 @@ public class UpdateContactDto
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? Role { get; set; }
public int? CustomerTypeId { get; set; }
}
@@ -8,7 +8,5 @@ public class GetContactDto
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? Role { get; set; }
public int? CustomerId { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.Customer.Request;
public class CreateCustomerDto
{
public string? Note { get; set; }
public int CustomerTypeId { get; set; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.Customer.Request;
public class GetCustomerRequest
{
public int Id { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.Customer.Request;
public class UpdateCustomerDto
{
public int Id { get; set; }
public string? Note { get; set; }
}
@@ -1,11 +0,0 @@
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; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class CreateCustomerTypeDto
{
public string? Label { get; set; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class GetCustomerTypeRequest
{
public int Id { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.CustomerType.Request;
public class UpdateCustomerTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.CustomerType.Response;
public class GetCustomerTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -3,5 +3,4 @@ namespace PyroFetes.DTO.ExperienceLevel.Request;
public class CreateExperienceLevelDto
{
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -4,6 +4,4 @@ public class GetExperienceLevelDto
{
public int Id { get; set; }
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -4,5 +4,4 @@ public class CreateHistoryOfApprovalDto
{
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -5,6 +5,4 @@ public class GetHistoryOfApprovalDto
public int Id { get; set; }
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.Provider.Request;
public class CreateProviderDto
{
public decimal Price { get; set; }
public int ProviderTypeId { get; set; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.Provider.Request;
public class GetProviderRequest
{
public int Id { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.Provider.Request;
public class UpdateProviderDto
{
public int Id { get; set; }
public decimal Price { get; set; }
}
@@ -1,11 +0,0 @@
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; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class CreateProviderTypeDto
{
public string? Label { get; set; }
}
@@ -1,6 +0,0 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class GetProviderTypeRequest
{
public int Id { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.ProviderType.Request;
public class UpdateProviderTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -1,7 +0,0 @@
namespace PyroFetes.DTO.ProviderType.Response;
public class GetProviderTypeDto
{
public int Id { get; set; }
public string? Label { get; set; }
}
@@ -2,10 +2,6 @@ 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; }
}
@@ -3,12 +3,6 @@ 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; }
}
@@ -8,7 +8,7 @@ public class CreateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{
public override void Configure()
{
Post("/availabilities");
Post("/api/availabilities");
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class DeleteAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{
public override void Configure()
{
Delete ("/availabilities/{@Id}", x => new { x.Id });
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -8,7 +8,7 @@ public class GetAllAvailabilityxuest(PyroFetesDbContext pyroFetesDbContext) : En
{
public override void Configure()
{
Get ("/availabilities");
Get ("/api/availabilities");
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class GetAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
{
public override void Configure()
{
Get ("/availabilities/{@Id}", x => new { x.Id });
Get ("/api/availabilities/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class UpdateAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{
public override void Configure()
{
Put ("/availabilities/{@Id}", x => new { x.Id });
Put ("/api/availabilities/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -8,7 +8,7 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext)
{
public override void Configure()
{
Post("/communications");
Post("/api/communications");
AllowAnonymous();
}
@@ -19,22 +19,16 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext)
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting,
ContactId = req.ContactId
Meeting = req.Meeting
};
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,
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting
};
await Send.OkAsync(response, ct);
@@ -1,16 +1,15 @@
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 class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationDto, GetCommunicationEndpoint>
{
public override void Configure()
{
Delete ("/communications/{@Id}", x => new { x.Id });
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -1,32 +0,0 @@
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,36 +1,28 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Communication.Request;
using PyroFetes.DTO.Availability.Response;
using PyroFetes.DTO.Communication.Response;
namespace PyroFetes.Endpoints.Communication;
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationRequest, GetCommunicationDto>
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCommunicationDto>>
{
public override void Configure()
{
Get ("/communications/{@Id}", x => new { x.Id });
Get ("/api/availabilities");
AllowAnonymous();
}
public override async Task HandleAsync(GetCommunicationRequest database, CancellationToken ct)
public override async Task HandleAsync(CancellationToken ct)
{
Models.Communication? databaseCommunications = await pyroFetesDbContext.Communications.SingleOrDefaultAsync(x => x.Id == database.Id, cancellationToken: ct);
if (databaseCommunications == null)
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto()
{
await Send.NotFoundAsync(ct);
return;
}
Id = x.Id,
Calling = x.Calling,
Email = x.Email,
Meeting = x.Meeting,
}).ToListAsync(ct);
GetCommunicationDto dto = new()
{
Id = databaseCommunications.Id,
Calling = databaseCommunications.Calling,
Email = databaseCommunications.Email,
Meeting = databaseCommunications.Meeting
};
await Send.OkAsync(dto, ct);
await Send.OkAsync(communications, ct);
}
}
}
@@ -1,43 +0,0 @@
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,5 +1,4 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Contact.Request;
using PyroFetes.DTO.Contact.Response;
@@ -9,22 +8,13 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
{
public override void Configure()
{
Post("/contacts");
Post("/api/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,
@@ -32,9 +22,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
PhoneNumber = req.PhoneNumber,
Email = req.Email,
Address = req.Address,
City = req.City,
Role = req.Role,
CustomerId = databaseCustomer.Id,
};
pyroFetesDbContext.Add(contact);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -46,9 +34,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
PhoneNumber = contact.PhoneNumber,
Email = contact.Email,
Address = contact.Address,
City = contact.City,
Role = contact.Role,
CustomerId = databaseCustomer.Id,
};
await Send.OkAsync(response, ct);
@@ -9,7 +9,7 @@ public class DeleteContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
{
public override void Configure()
{
Delete ("/contacts/{@Id}", x => new { x.Id });
Delete ("/api/Contacts/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -4,11 +4,11 @@ using PyroFetes.DTO.Contact.Response;
namespace PyroFetes.Endpoints.Contact;
public class GetAllContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
{
public override void Configure()
{
Get ("/contacts");
Get ("/api/contacts");
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class GetContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
{
public override void Configure()
{
Get ("/contacts/{@Id}", x => new { x.Id });
Get ("/api/contacts/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -5,11 +5,11 @@ using PyroFetes.DTO.Contact.Response;
namespace PyroFetes.Endpoints.Contact;
public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
{
public override void Configure()
{
Put ("/contacts/{@Id}", x => new { x.Id });
Put ("/api/contacts/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -29,7 +29,6 @@ public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
databaseContact.PhoneNumber = req.PhoneNumber;
databaseContact.Email = req.Email;
databaseContact.Address = req.Address;
databaseContact.City = req.City;
databaseContact.Role = req.Role;
}
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -42,7 +41,6 @@ public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
PhoneNumber = req.PhoneNumber,
Email = req.Email,
Address = req.Address,
City = req.City,
Role = req.Role,
};
@@ -1,47 +0,0 @@
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);
}
}
@@ -1,30 +0,0 @@
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);
}
}
@@ -1,26 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,38 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,30 +0,0 @@
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);
}
}
@@ -1,25 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,38 +0,0 @@
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,6 +1,5 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Response;
using PyroFetes.DTO.ExperienceLevel.Request;
@@ -10,26 +9,15 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{
public override void Configure()
{
Post("/experiencelevels");
Post("/api/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,
Label = req.Label
};
pyroFetesDbContext.Add(experienceLevel);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -38,7 +26,6 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{
Id = experienceLevel.Id,
Label = experienceLevel.Label,
StaffId = experienceLevel.StaffId
};
await Send.OkAsync(response, ct);
@@ -9,7 +9,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext)
{
public override void Configure()
{
Delete ("/experiencelevels/{@Id}", x => new { x.Id });
Delete ("/api/ExperienceLevels/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -8,7 +8,7 @@ public class GetAllExperienceLevelsEndpoint(PyroFetesDbContext pyroFetesDbContex
{
public override void Configure()
{
Get ("/experiencelevels");
Get ("/api/experienceLevels");
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) :
{
public override void Configure()
{
Get ("/experiencelevels/{@Id}", x => new { x.Id });
Get ("/api/experienceLevels/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class UpdateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{
public override void Configure()
{
Put ("/experiencelevels/{@Id}", x => new { x.Id });
Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -1,5 +1,4 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Request;
using PyroFetes.DTO.HistoryOfApproval.Response;
@@ -9,28 +8,17 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
public override void Configure()
{
Post("/historyofapprovals");
Post("/api/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,
ExpirationDate = req.ExpirationDate
};
pyroFetesDbContext.Add(historyOfApproval);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -39,8 +27,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
Id = historyOfApproval.Id,
DeliveryDate = historyOfApproval.DeliveryDate,
ExpirationDate = historyOfApproval.ExpirationDate,
StaffId = historyOfApproval.StaffId,
ExpirationDate = historyOfApproval.ExpirationDate
};
await Send.OkAsync(response, ct);
@@ -9,7 +9,7 @@ public class DeleteHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
public override void Configure()
{
Delete ("/historyofapprovals/{@Id}", x => new { x.Id });
Delete ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -8,7 +8,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
public override void Configure()
{
Get ("/historyofapprovals");
Get ("/api/HistoryOfApprovals");
AllowAnonymous();
}
@@ -19,7 +19,6 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
Id = x.Id,
DeliveryDate = x.DeliveryDate,
ExpirationDate = x.ExpirationDate,
StaffId = x.StaffId,
}).ToListAsync(ct);
await Send.OkAsync(historyOfApprovals, ct);
@@ -9,7 +9,7 @@ public class GetHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbContext)
{
public override void Configure()
{
Get ("/historyofapprovals/{@Id}", x => new { x.Id });
Get ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -9,7 +9,7 @@ public class UpdateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
public override void Configure()
{
Put ("/historyofapprovals/{@Id}", x => new { x.Id });
Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -1,46 +0,0 @@
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);
}
}
@@ -1,30 +0,0 @@
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);
}
}
@@ -1,27 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,38 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,30 +0,0 @@
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);
}
}
@@ -1,25 +0,0 @@
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);
}
}
@@ -1,34 +0,0 @@
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);
}
}
@@ -1,38 +0,0 @@
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()
{
Post("/staffs");
Post("/api/availabilities");
AllowAnonymous();
}
@@ -17,10 +17,6 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
{
Models.Staff staff = new()
{
FirstName = req.FirstName,
LastName = req.LastName,
Profession = req.Profession,
Email = req.Email,
F4T2NumberApproval = req.F4T2NumberApproval,
F4T2ExpirationDate = req.F4T2ExpirationDate,
};
@@ -29,10 +25,6 @@ public class CreateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
GetStaffDto response = new()
{
FirstName = staff.FirstName,
LastName = staff.LastName,
Profession = staff.Profession,
Email = staff.Email,
F4T2NumberApproval = staff.F4T2NumberApproval,
F4T2ExpirationDate = staff.F4T2ExpirationDate,
};
@@ -9,7 +9,7 @@ public class DeleteStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
{
public override void Configure()
{
Delete ("/staffs/{@Id}", x => new { x.Id });
Delete ("/api/staff/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -7,28 +7,21 @@ namespace PyroFetes.Endpoints.Staff;
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
{
public override void Configure()
{
Get("/staffs");
{
Get ("/api/availabilities");
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);
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
{
Id = x.Id,
F4T2NumberApproval = x.F4T2NumberApproval,
F4T2ExpirationDate = x.F4T2ExpirationDate,
}).ToListAsync(ct);
await Send.OkAsync(staff, ct);
}
}
@@ -9,7 +9,7 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint
{
public override void Configure()
{
Get ("/staffs/{@Id}", x => new { x.Id });
Get ("/api/Staffs/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -26,10 +26,6 @@ public class GetStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint
GetStaffDto dto = new()
{
Id = databaseStaff.Id,
FirstName = databaseStaff.FirstName,
LastName = databaseStaff.LastName,
Profession = databaseStaff.Profession,
Email = databaseStaff.Email,
F4T2NumberApproval = databaseStaff.F4T2NumberApproval,
F4T2ExpirationDate = databaseStaff.F4T2ExpirationDate,
};
@@ -5,11 +5,11 @@ using FastEndpoints;
namespace PyroFetes.Endpoints.Staff;
public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
{
public override void Configure()
{
Put ("/staffs/{@Id}", x => new { x.Id });
Put ("/api/Staffs/{@Id}", x => new { x.Id });
AllowAnonymous();
}
@@ -32,10 +32,6 @@ public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
GetStaffDto dto = new()
{
Id = databaseStaff.Id,
FirstName = databaseStaff.FirstName,
LastName = databaseStaff.LastName,
Profession = databaseStaff.Profession,
Email = databaseStaff.Email,
F4T2NumberApproval = req.F4T2NumberApproval,
F4T2ExpirationDate = req.F4T2ExpirationDate,
};
File diff suppressed because it is too large Load Diff
-246
View File
@@ -1,246 +0,0 @@
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,6 +136,7 @@ namespace PyroFetes.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Calling")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
@@ -143,10 +144,12 @@ 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)");
@@ -374,8 +377,7 @@ namespace PyroFetes.Migrations
b.HasKey("Id");
b.HasIndex("StaffId")
.IsUnique();
b.HasIndex("StaffId");
b.ToTable("ExperienceLevels");
});
@@ -394,9 +396,6 @@ namespace PyroFetes.Migrations
b.Property<DateOnly>("ExpirationDate")
.HasColumnType("date");
b.Property<int>("StaffId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("HistoryOfApprovals");
@@ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b.HasIndex("ProviderTypeId");
b.ToTable("ServiceProviders");
b.ToTable("Providers");
});
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
@@ -1334,8 +1333,8 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
{
b.HasOne("PyroFetes.Models.Staff", "Staff")
.WithOne("ExperienceLevel")
.HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId")
.WithMany("ExperienceLevels")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -1912,8 +1911,7 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
{
b.Navigation("ExperienceLevel")
.IsRequired();
b.Navigation("ExperienceLevels");
b.Navigation("ShowStaffs");
+3 -3
View File
@@ -5,9 +5,9 @@ namespace PyroFetes.Models;
public class Communication
{
[Key] public int Id { get; set; }
[MaxLength(100)] public string? Calling { get; set; }
[MaxLength(100)] public string? Email { get; set; }
[MaxLength(300)] public string? Meeting { 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; }
[Required] public int ContactId { get; set; }
public Contact? Contact { get; set; }
-14
View File
@@ -1,14 +0,0 @@
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,7 +8,5 @@ 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; }
}
+1 -1
View File
@@ -13,7 +13,7 @@ public class Staff
[Required] public DateOnly F4T2ExpirationDate { get; set; }
public List<ShowStaff>? ShowStaffs { get; set; }
public ExperienceLevel ExperienceLevel { get; set; }
public List<ExperienceLevel>? ExperienceLevels { get; set; }
public List<StaffAvailability>? StaffAvailabilities { get; set; }
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
public List<StaffContact>? StaffContacts { get; set; }
+12 -36
View File
@@ -1,43 +1,19 @@
using PyroFetes;
using FastEndpoints;
using FastEndpoints.Swagger;
using FastEndpoints.Security;
var builder = WebApplication.CreateBuilder(args);
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// 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;});
var app = builder.Build();
// On ajoute ici la configuration de la base de données
builder.Services.AddDbContext<PyroFetesDbContext>();
//On ajoute le CORS au code
builder.Services.AddCors(options =>
{ options.AddDefaultPolicy(policyBuilder =>
{
policyBuilder
.WithOrigins("http://localhost:4200")
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
.AllowAnyHeader();
});
});
// On construit l'application en lui donnant vie
WebApplication app = builder.Build();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints(options =>
{
options.Endpoints.RoutePrefix = "API";
options.Endpoints.ShortNames = true;
}
).UseSwaggerGen();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseCors();
app.Run();
-2
View File
@@ -7,9 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<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="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
+1 -1
View File
@@ -28,7 +28,7 @@ public class PyroFetesDbContext : DbContext
public DbSet<ProductColor> ProductColors { get; set; }
public DbSet<ProductDelivery> ProductDeliveries { get; set; }
public DbSet<ProductEffect> ProductEffects { get; set; }
public DbSet<ServiceProvider> ServiceProviders { get; set; }
public DbSet<ServiceProvider> Providers { get; set; }
public DbSet<ProviderContact> ProviderContacts { get; set; }
public DbSet<ProviderType> ProviderTypes { get; set; }
public DbSet<PurchaseOrder> PurchaseOrders { get; set; }