Compare commits
5 Commits
develop
...
be0436efc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be0436efc1 | ||
| 70d47eb82b | |||
| 6f3c9a5fac | |||
| 44a48f8ccd | |||
| a93d399942 |
@@ -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,9 +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; }
|
|
||||||
}
|
|
||||||
@@ -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; }
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Provider.Request;
|
|
||||||
|
|
||||||
public class CreateProviderDto
|
|
||||||
{
|
|
||||||
public decimal Price { 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,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Provider.Response;
|
|
||||||
|
|
||||||
public class GetProviderDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public decimal Price { 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; }
|
|
||||||
}
|
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ using PyroFetes.DTO.Communication.Response;
|
|||||||
|
|
||||||
namespace PyroFetes.Endpoints.Communication;
|
namespace PyroFetes.Endpoints.Communication;
|
||||||
|
|
||||||
public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationDto, GetAllCommunicationsEndpoint>
|
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,27 +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.Select(x => new GetCommunicationDto()
|
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
Calling = x.Calling,
|
|
||||||
Email = x.Email,
|
|
||||||
Meeting = x.Meeting,
|
|
||||||
}).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 = contact.CustomerId,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GetAllContactxuest(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateContactRequest(PyroFetesDbContext pyroFetesDbContext) : Endpo
|
|||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,25 +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.Select(x => new GetCustomerDto()
|
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
Note = x.Note,
|
|
||||||
}).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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/experiencelevels");
|
Post("/api/ExperienceLevels");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Post("/historyofapprovals");
|
Post("/api/HistoryOfApprovals");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,34 +0,0 @@
|
|||||||
using FastEndpoints;
|
|
||||||
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("/providers");
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateProviderDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var provider = new Models.ServiceProvider()
|
|
||||||
{
|
|
||||||
Price = req.Price
|
|
||||||
};
|
|
||||||
pyroFetesDbContext.Add(provider);
|
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
GetProviderDto response = new GetProviderDto()
|
|
||||||
{
|
|
||||||
Id = provider.Id,
|
|
||||||
Price = provider.Price
|
|
||||||
};
|
|
||||||
|
|
||||||
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 ("/providers/{@Id}", x => new { x.Id });
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
|
||||||
|
|
||||||
if (databaseProvider == null)
|
|
||||||
{
|
|
||||||
await Send.NotFoundAsync(ct);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pyroFetesDbContext.Providers.Remove(databaseProvider);
|
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
await Send.NoContentAsync(ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +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 ("/providers");
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
|
||||||
{
|
|
||||||
List<GetProviderDto> customer= await pyroFetesDbContext.Providers.Select(x => new GetProviderDto()
|
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
Price = x.Price,
|
|
||||||
}).ToListAsync(ct);
|
|
||||||
|
|
||||||
await Send.OkAsync(customer, 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 ("/providers/{@Id}", x => new { x.Id });
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(GetProviderRequest req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.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 ("/providers/{@Id}", x => new { x.Id });
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateProviderDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
Models.ServiceProvider? databaseProvider = await pyroFetesDbContext.Providers.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 ("/providertype");
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 +8,7 @@ public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpo
|
|||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
Get ("/staffs");
|
Get ("/api/availabilities");
|
||||||
AllowAnonymous();
|
AllowAnonymous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public class UpdateStaffRequest(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1950
PyroFetes/Migrations/20251010083620_FixingDatabase.Designer.cs
generated
Normal file
1950
PyroFetes/Migrations/20251010083620_FixingDatabase.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
PyroFetes/Migrations/20251010083620_FixingDatabase.cs
Normal file
52
PyroFetes/Migrations/20251010083620_FixingDatabase.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -541,11 +541,10 @@ namespace PyroFetes.Migrations
|
|||||||
b.Property<int>("ProductCategoryId")
|
b.Property<int>("ProductCategoryId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("References")
|
b.Property<string>("Reference")
|
||||||
.HasColumnType("int");
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
b.Property<decimal>("SellingPrice")
|
.HasColumnType("nvarchar(20)");
|
||||||
.HasColumnType("decimal(18,2)");
|
|
||||||
|
|
||||||
b.Property<decimal>("Weight")
|
b.Property<decimal>("Weight")
|
||||||
.HasColumnType("decimal(18,2)");
|
.HasColumnType("decimal(18,2)");
|
||||||
|
|||||||
@@ -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; }
|
|
||||||
}
|
|
||||||
@@ -5,14 +5,13 @@ namespace PyroFetes.Models
|
|||||||
public class Product
|
public class Product
|
||||||
{
|
{
|
||||||
[Key] public int Id { get; set; }
|
[Key] public int Id { get; set; }
|
||||||
[Required] public int References { get; set; }
|
[Required, MaxLength(20)] public string? Reference { 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; }
|
||||||
|
|||||||
@@ -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:5298")
|
|
||||||
.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" />
|
||||||
|
|||||||
Reference in New Issue
Block a user