Compare commits
5 Commits
master
..
92e71e76b9
| Author | SHA1 | Date | |
|---|---|---|---|
| 92e71e76b9 | |||
| 91a5c63ff5 | |||
| 7d52b24ed8 | |||
| 8a9df1a4a1 | |||
| 1e9b458793 |
@@ -5,5 +5,4 @@ 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,11 +6,4 @@ 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,7 +7,5 @@ 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,7 +8,5 @@ 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,7 +8,5 @@ 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; }
|
|
||||||
}
|
}
|
||||||
@@ -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 class CreateExperienceLevelDto
|
||||||
{
|
{
|
||||||
public string? Label { get; set; }
|
public string? Label { get; set; }
|
||||||
public int? StaffId { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,4 @@ 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,5 +4,4 @@ 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,6 +5,4 @@ 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; }
|
|
||||||
}
|
}
|
||||||
@@ -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 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,12 +3,6 @@ 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("/availabilities");
|
Post("/api/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class DeleteAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/availabilities/{@Id}", x => new { x.Id });
|
Delete ("/api/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 ("/availabilities");
|
Get ("/api/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetAvailabilityEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/availabilities/{@Id}", x => new { x.Id });
|
Get ("/api/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 ("/availabilities/{@Id}", x => new { x.Id });
|
Put ("/api/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("/communications");
|
Post("/api/communications");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,22 +19,16 @@ 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 = communication.Calling,
|
Calling = req.Calling,
|
||||||
Email = communication.Email,
|
Email = req.Email,
|
||||||
Meeting = communication.Meeting,
|
Meeting = req.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,16 +1,15 @@
|
|||||||
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 <GetCommunicationRequest, GetCommunicationDto>
|
public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationDto, GetCommunicationEndpoint>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Delete ("/communications/{@Id}", x => new { x.Id });
|
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
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 FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PyroFetes.DTO.Communication.Request;
|
using PyroFetes.DTO.Availability.Response;
|
||||||
using PyroFetes.DTO.Communication.Response;
|
using PyroFetes.DTO.Communication.Response;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Communication;
|
namespace PyroFetes.Endpoints.Communication;
|
||||||
|
|
||||||
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationRequest, GetCommunicationDto>
|
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCommunicationDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/communications/{@Id}", x => new { x.Id });
|
Get ("/api/availabilities");
|
||||||
AllowAnonymous();
|
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);
|
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto()
|
||||||
|
|
||||||
if (databaseCommunications == null)
|
|
||||||
{
|
{
|
||||||
await Send.NotFoundAsync(ct);
|
Id = x.Id,
|
||||||
return;
|
Calling = x.Calling,
|
||||||
}
|
Email = x.Email,
|
||||||
|
Meeting = x.Meeting,
|
||||||
|
}).ToListAsync(ct);
|
||||||
|
|
||||||
GetCommunicationDto dto = new()
|
await Send.OkAsync(communications, ct);
|
||||||
{
|
|
||||||
Id = databaseCommunications.Id,
|
|
||||||
Calling = databaseCommunications.Calling,
|
|
||||||
Email = databaseCommunications.Email,
|
|
||||||
Meeting = databaseCommunications.Meeting
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(dto, 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 FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PyroFetes.DTO.Contact.Request;
|
using PyroFetes.DTO.Contact.Request;
|
||||||
using PyroFetes.DTO.Contact.Response;
|
using PyroFetes.DTO.Contact.Response;
|
||||||
|
|
||||||
@@ -9,22 +8,13 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/contacts");
|
Post("/api/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,
|
||||||
@@ -32,9 +22,7 @@ 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);
|
||||||
@@ -46,9 +34,7 @@ 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 ("/contacts/{@Id}", x => new { x.Id });
|
Delete ("/api/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 GetAllContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
|
public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetContactDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/contacts");
|
Get ("/api/contacts");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/contacts/{@Id}", x => new { x.Id });
|
Get ("/api/contacts/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -5,11 +5,11 @@ using PyroFetes.DTO.Contact.Response;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Contact;
|
namespace PyroFetes.Endpoints.Contact;
|
||||||
|
|
||||||
public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
|
public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateContactDto, GetContactDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/contacts/{@Id}", x => new { x.Id });
|
Put ("/api/contacts/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ public class UpdateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
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);
|
||||||
@@ -42,7 +41,6 @@ public class UpdateContactEndpoint(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,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -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 FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PyroFetes.DTO.ExperienceLevel.Response;
|
using PyroFetes.DTO.ExperienceLevel.Response;
|
||||||
using PyroFetes.DTO.ExperienceLevel.Request;
|
using PyroFetes.DTO.ExperienceLevel.Request;
|
||||||
|
|
||||||
@@ -10,26 +9,15 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/experiencelevels");
|
Post("/api/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);
|
||||||
@@ -38,7 +26,6 @@ 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 ("/experiencelevels/{@Id}", x => new { x.Id });
|
Delete ("/api/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 ("/experiencelevels");
|
Get ("/api/experienceLevels");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/experiencelevels/{@Id}", x => new { x.Id });
|
Get ("/api/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 ("/experiencelevels/{@Id}", x => new { x.Id });
|
Put ("/api/ExperienceLevels/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -9,28 +8,17 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/historyofapprovals");
|
Post("/api/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);
|
||||||
@@ -39,8 +27,7 @@ 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 ("/historyofapprovals/{@Id}", x => new { x.Id });
|
Delete ("/api/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 ("/historyofapprovals");
|
Get ("/api/HistoryOfApprovals");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,6 @@ 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 ("/historyofapprovals/{@Id}", x => new { x.Id });
|
Get ("/api/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 ("/historyofapprovals/{@Id}", x => new { x.Id });
|
Put ("/api/HistoryOfApprovals/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
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()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/staffs");
|
Post("/api/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,10 +17,6 @@ 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,
|
||||||
};
|
};
|
||||||
@@ -29,10 +25,6 @@ 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 ("/staffs/{@Id}", x => new { x.Id });
|
Delete ("/api/staff/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,27 +8,20 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get("/staffs");
|
Get ("/api/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs
|
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
|
||||||
.Include(x => x.ExperienceLevel)
|
|
||||||
.Select(x => new GetStaffDto()
|
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
FirstName = x.FirstName,
|
|
||||||
LastName = x.LastName,
|
|
||||||
Profession = x.Profession,
|
|
||||||
Email = x.Email,
|
|
||||||
F4T2NumberApproval = x.F4T2NumberApproval,
|
F4T2NumberApproval = x.F4T2NumberApproval,
|
||||||
F4T2ExpirationDate = x.F4T2ExpirationDate,
|
F4T2ExpirationDate = x.F4T2ExpirationDate,
|
||||||
ExperienceLevel = x.ExperienceLevel.Label
|
|
||||||
}).ToListAsync(ct);
|
}).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 ("/staffs/{@Id}", x => new { x.Id });
|
Get ("/api/Staffs/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,10 +26,6 @@ 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,
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-6
@@ -5,11 +5,11 @@ using FastEndpoints;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
|
public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoint <UpdateStaffDto, GetStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Put ("/staffs/{@Id}", x => new { x.Id });
|
Put ("/api/Staffs/{@Id}", x => new { x.Id });
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,10 +32,6 @@ public class UpdateStaffEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
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,
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,52 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PyroFetes.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class FixingDatabase : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "References",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "SellingPrice",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Reference",
|
|
||||||
table: "Products",
|
|
||||||
type: "nvarchar(20)",
|
|
||||||
maxLength: 20,
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Reference",
|
|
||||||
table: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "References",
|
|
||||||
table: "Products",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<decimal>(
|
|
||||||
name: "SellingPrice",
|
|
||||||
table: "Products",
|
|
||||||
type: "decimal(18,2)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-1953
File diff suppressed because it is too large
Load Diff
@@ -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"));
|
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)");
|
||||||
|
|
||||||
@@ -143,10 +144,12 @@ 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)");
|
||||||
|
|
||||||
@@ -374,8 +377,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("StaffId")
|
b.HasIndex("StaffId");
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("ExperienceLevels");
|
b.ToTable("ExperienceLevels");
|
||||||
});
|
});
|
||||||
@@ -394,9 +396,6 @@ 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");
|
||||||
@@ -542,10 +541,11 @@ namespace PyroFetes.Migrations
|
|||||||
b.Property<int>("ProductCategoryId")
|
b.Property<int>("ProductCategoryId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Reference")
|
b.Property<int>("References")
|
||||||
.IsRequired()
|
.HasColumnType("int");
|
||||||
.HasMaxLength(20)
|
|
||||||
.HasColumnType("nvarchar(20)");
|
b.Property<decimal>("SellingPrice")
|
||||||
|
.HasColumnType("decimal(18,2)");
|
||||||
|
|
||||||
b.Property<decimal>("Weight")
|
b.Property<decimal>("Weight")
|
||||||
.HasColumnType("decimal(18,2)");
|
.HasColumnType("decimal(18,2)");
|
||||||
@@ -781,7 +781,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ProviderTypeId");
|
b.HasIndex("ProviderTypeId");
|
||||||
|
|
||||||
b.ToTable("ServiceProviders");
|
b.ToTable("Providers");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
|
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
|
||||||
@@ -1333,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")
|
||||||
.WithOne("ExperienceLevel")
|
.WithMany("ExperienceLevels")
|
||||||
.HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId")
|
.HasForeignKey("StaffId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
@@ -1911,8 +1911,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
|
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ExperienceLevel")
|
b.Navigation("ExperienceLevels");
|
||||||
.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; }
|
||||||
[MaxLength(100)] public string? Calling { get; set; }
|
[Required, MaxLength(100)] public string? Calling { get; set; }
|
||||||
[MaxLength(100)] public string? Email { get; set; }
|
[Required, MaxLength(100)] public string? Email { get; set; }
|
||||||
[MaxLength(300)] public string? Meeting { get; set; }
|
[Required, 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; }
|
||||||
|
|||||||
@@ -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; }
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,5 @@ 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; }
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,14 @@ namespace PyroFetes.Models
|
|||||||
public class Product
|
public class Product
|
||||||
{
|
{
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required, MaxLength(20)] public string? Reference { get; set; }
|
[Required] public int References { get; set; }
|
||||||
[Required, MaxLength(100)] public string? Name { get; set; }
|
[Required, MaxLength(100)] public string? Name { get; set; }
|
||||||
[Required] public decimal Duration {get; set;}
|
[Required] public decimal Duration {get; set;}
|
||||||
[Required] public decimal Caliber { get; set; }
|
[Required] public decimal Caliber { get; set; }
|
||||||
[Required] public int ApprovalNumber { get; set; }
|
[Required] public int ApprovalNumber { get; set; }
|
||||||
[Required] public decimal Weight { get; set; }
|
[Required] public decimal Weight { get; set; }
|
||||||
[Required] public decimal Nec { get; set; }
|
[Required] public decimal Nec { get; set; }
|
||||||
|
[Required] public decimal SellingPrice { get; set; }
|
||||||
[Required] public string? Image { get; set; }
|
[Required] public string? Image { get; set; }
|
||||||
[Required, MaxLength(200)] public string? Link { get; set; }
|
[Required, MaxLength(200)] public string? Link { get; set; }
|
||||||
[Required] public int MinimalQuantity { get; set; }
|
[Required] public int MinimalQuantity { 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 ExperienceLevel ExperienceLevel { get; set; }
|
public List<ExperienceLevel>? ExperienceLevels { 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; }
|
||||||
|
|||||||
+12
-36
@@ -1,43 +1,19 @@
|
|||||||
using PyroFetes;
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
using FastEndpoints;
|
|
||||||
using FastEndpoints.Swagger;
|
|
||||||
using FastEndpoints.Security;
|
|
||||||
|
|
||||||
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
|
var app = builder.Build();
|
||||||
builder.Services
|
|
||||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "zewsxrdctfvgybuhbgyvftrcdtfvgbyuhn")
|
|
||||||
.AddAuthorization()
|
|
||||||
.AddFastEndpoints().SwaggerDocument(options => { options.ShortSchemaNames = true;});
|
|
||||||
|
|
||||||
// On ajoute ici la configuration de la base de données
|
// Configure the HTTP request pipeline.
|
||||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
//On ajoute le CORS au code
|
app.UseSwagger();
|
||||||
builder.Services.AddCors(options =>
|
app.UseSwaggerUI();
|
||||||
{ 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,9 +7,7 @@
|
|||||||
</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> ServiceProviders { get; set; }
|
public DbSet<ServiceProvider> Providers { 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