suppr all 'var' and Models.xxx. And added 's' at the end of all directories endpoints

This commit is contained in:
2025-11-17 20:49:12 +01:00
parent 20bbccf883
commit 6dba61f742
45 changed files with 141 additions and 114 deletions

View File

@@ -9,7 +9,7 @@ public class CreatePriceDto
public string? SupplierEmail { get; set; } public string? SupplierEmail { get; set; }
public string? SupplierPhone { get; set; } public string? SupplierPhone { get; set; }
public string? SupplierAddress { get; set; } public string? SupplierAddress { get; set; }
public int SupplierZipCode { get; set; } public string? SupplierZipCode { get; set; }
public string? SupplierCity { get; set; } public string? SupplierCity { get; set; }
public int SupplierDeliveryDelay { get; set; } public int SupplierDeliveryDelay { get; set; }

View File

@@ -7,7 +7,7 @@ public class GetSupplierDto
public string? Email { get; set; } public string? Email { get; set; }
public string? Phone { get; set; } public string? Phone { get; set; }
public string? Address { get; set; } public string? Address { get; set; }
public int ZipCode { get; set; } public string? ZipCode { get; set; }
public string? City { get; set; } public string? City { get; set; }
public int DeliveryDelay { get; set; } public int DeliveryDelay { get; set; }
} }

View File

@@ -14,7 +14,6 @@ public class CreateDelivererEndpoint(
{ {
Post("api/deliverers"); Post("api/deliverers");
AllowAnonymous(); AllowAnonymous();
} }
public override async Task HandleAsync(CreateDelivererDto req, CancellationToken ct) public override async Task HandleAsync(CreateDelivererDto req, CancellationToken ct)

View File

@@ -45,7 +45,7 @@ public class CreateDeliveryNoteEndpoint(
foreach (var productQuantity in req.ProductQuantities!) foreach (var productQuantity in req.ProductQuantities!)
{ {
Models.Product? product = Product? product =
await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct); await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct);
if (product != null) if (product != null)
{ {

View File

@@ -1,6 +1,7 @@
using FastEndpoints; using FastEndpoints;
using PyroFetes.DTO.Price.Request; using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response; using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
using PyroFetes.Repositories; using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices; using PyroFetes.Specifications.Prices;
using PyroFetes.Specifications.Products; using PyroFetes.Specifications.Products;
@@ -23,10 +24,10 @@ public class CreatePriceEndpoint(
public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct) public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct)
{ {
// Gestion du fournisseur // Gestion du fournisseur
var supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct); Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct);
if (supplier == null) if (supplier == null)
{ {
supplier = new Models.Supplier() supplier = new Supplier()
{ {
Name = req.SupplierName, Name = req.SupplierName,
Email = req.SupplierEmail, Email = req.SupplierEmail,
@@ -40,10 +41,10 @@ public class CreatePriceEndpoint(
} }
// Gestion du produit // Gestion du produit
var product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct); Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct);
if (product == null) if (product == null)
{ {
product = new Models.Product() product = new Product()
{ {
Reference = req.ProductReferences, Reference = req.ProductReferences,
Name = req.ProductName, Name = req.ProductName,
@@ -60,7 +61,7 @@ public class CreatePriceEndpoint(
} }
// Vérifie si le prix existe déjà pour ce fournisseur et produit // Vérifie si le prix existe déjà pour ce fournisseur et produit
var existingPrice = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct); Price? existingPrice = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct);
if (existingPrice != null) if (existingPrice != null)
{ {
@@ -69,7 +70,7 @@ public class CreatePriceEndpoint(
} }
// Création du prix // Création du prix
var priceAdded = new Models.Price() var priceAdded = new Price()
{ {
SellingPrice = req.SellingPrice, SellingPrice = req.SellingPrice,
SupplierId = supplier.Id, SupplierId = supplier.Id,

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.QuotationProduct; namespace PyroFetes.Endpoints.Prices;
public class DeletePriceRequest public class DeletePriceRequest
{ {
@@ -19,7 +20,7 @@ public class DeletePriceEndpoint(PyroFetesDbContext database) : Endpoint<DeleteP
public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct) public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct)
{ {
var price = await database.Prices Price? price = await database.Prices
.SingleOrDefaultAsync(p => p.ProductId == req.ProductId && p.SupplierId == req.SupplierId, ct); .SingleOrDefaultAsync(p => p.ProductId == req.ProductId && p.SupplierId == req.SupplierId, ct);
if (price == null) if (price == null)

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Price.Request; using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response; using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Price; namespace PyroFetes.Endpoints.Prices;
public class PatchPriceEndpoint(PyroFetesDbContext database) : Endpoint<PatchPriceSellingPriceDto, GetPriceDto> public class PatchPriceEndpoint(PyroFetesDbContext database) : Endpoint<PatchPriceSellingPriceDto, GetPriceDto>
{ {
@@ -15,7 +16,7 @@ public class PatchPriceEndpoint(PyroFetesDbContext database) : Endpoint<PatchPri
public override async Task HandleAsync(PatchPriceSellingPriceDto req, CancellationToken ct) public override async Task HandleAsync(PatchPriceSellingPriceDto req, CancellationToken ct)
{ {
var price = await database.Prices.SingleOrDefaultAsync(p => p.ProductId == req.ProductId && p.SupplierId == req.SupplierId, ct); Price? price = await database.Prices.SingleOrDefaultAsync(p => p.ProductId == req.ProductId && p.SupplierId == req.SupplierId, ct);
if (price == null) if (price == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -1,9 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response; using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product; namespace PyroFetes.Endpoints.Products;
public class GetAllProductsEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetProductDto>> public class GetAllProductsEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetProductDto>>
{ {
@@ -14,7 +14,7 @@ public class GetAllProductsEndpoint(PyroFetesDbContext database) : EndpointWitho
public override async Task HandleAsync(CancellationToken ct) public override async Task HandleAsync(CancellationToken ct)
{ {
var product = await database.Products List<GetProductDto> product = await database.Products
.Select(product => new GetProductDto() .Select(product => new GetProductDto()
{ {
Id = product.Id, Id = product.Id,

View File

@@ -1,9 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response; using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product; namespace PyroFetes.Endpoints.Products;
public class GetProductRequest public class GetProductRequest
{ {
@@ -19,7 +19,7 @@ public class GetProductEndpoint(PyroFetesDbContext database) : Endpoint<GetProdu
public override async Task HandleAsync(GetProductRequest req, CancellationToken ct) public override async Task HandleAsync(GetProductRequest req, CancellationToken ct)
{ {
var product = await database.Products Product? product = await database.Products
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (product == null) if (product == null)

View File

@@ -2,9 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Request; using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response; using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product; namespace PyroFetes.Endpoints.Products;
public class PatchProductMinimalStockEndpoint(PyroFetesDbContext database) public class PatchProductMinimalStockEndpoint(PyroFetesDbContext database)
: Endpoint<PatchProductMinimalStockDto, GetProductDto> : Endpoint<PatchProductMinimalStockDto, GetProductDto>
@@ -17,7 +17,7 @@ public class PatchProductMinimalStockEndpoint(PyroFetesDbContext database)
public override async Task HandleAsync(PatchProductMinimalStockDto req, CancellationToken ct) public override async Task HandleAsync(PatchProductMinimalStockDto req, CancellationToken ct)
{ {
var product = await database.Products.SingleOrDefaultAsync(po => po.Id == req.Id, ct); Product? product = await database.Products.SingleOrDefaultAsync(po => po.Id == req.Id, ct);
if (product == null) if (product == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Request; using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response; using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product; namespace PyroFetes.Endpoints.Products;
public class UpdateProductEndpoint(PyroFetesDbContext database) : Endpoint<UpdateProductDto, GetProductDto> public class UpdateProductEndpoint(PyroFetesDbContext database) : Endpoint<UpdateProductDto, GetProductDto>
{ {
@@ -14,7 +15,7 @@ public class UpdateProductEndpoint(PyroFetesDbContext database) : Endpoint<Updat
public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct) public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct)
{ {
var product = await database.Products.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Product? product = await database.Products.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (product == null) if (product == null)
{ {

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseOrder; namespace PyroFetes.Endpoints.PurchaseOrders;
public class DeletePurchaseOrderRequest public class DeletePurchaseOrderRequest
{ {
@@ -18,7 +19,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint
public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct) public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct)
{ {
var purchaseOrder = await database.PurchaseOrders PurchaseOrder? purchaseOrder = await database.PurchaseOrders
.Include(po => po.PurchaseProducts) .Include(po => po.PurchaseProducts)
.SingleOrDefaultAsync(po => po.Id == req.Id, ct); .SingleOrDefaultAsync(po => po.Id == req.Id, ct);

View File

@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.PurchaseProduct.Response;
namespace PyroFetes.Endpoints.PurchaseOrder; namespace PyroFetes.Endpoints.PurchaseOrders;
public class GetAllPurchaseOrderEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetPurchaseOrderDto>> public class GetAllPurchaseOrderEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetPurchaseOrderDto>>
{ {
@@ -14,7 +14,7 @@ public class GetAllPurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint
public override async Task HandleAsync(CancellationToken ct) public override async Task HandleAsync(CancellationToken ct)
{ {
var purchaseOrder = await database.PurchaseOrders List<GetPurchaseOrderDto> purchaseOrder = await database.PurchaseOrders
.Include(p => p.PurchaseProducts) .Include(p => p.PurchaseProducts)
.Select(purchaseOrder => new GetPurchaseOrderDto() .Select(purchaseOrder => new GetPurchaseOrderDto()
{ {

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseOrder; namespace PyroFetes.Endpoints.PurchaseOrders;
public class GetPurchaseOrderRequest public class GetPurchaseOrderRequest
{ {
@@ -19,7 +20,7 @@ public class GetPurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint<Ge
public override async Task HandleAsync(GetPurchaseOrderRequest req, CancellationToken ct) public override async Task HandleAsync(GetPurchaseOrderRequest req, CancellationToken ct)
{ {
var purchaseOrder = await database.PurchaseOrders PurchaseOrder? purchaseOrder = await database.PurchaseOrders
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (purchaseOrder == null) if (purchaseOrder == null)

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Request; using PyroFetes.DTO.PurchaseOrder.Request;
using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseOrder; namespace PyroFetes.Endpoints.PurchaseOrders;
public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext database) : Endpoint<PatchPurchaseOrderPurchaseConditionsDto, GetPurchaseOrderDto> public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext database) : Endpoint<PatchPurchaseOrderPurchaseConditionsDto, GetPurchaseOrderDto>
{ {
@@ -17,7 +17,7 @@ public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext dat
public override async Task HandleAsync(PatchPurchaseOrderPurchaseConditionsDto req, CancellationToken ct) public override async Task HandleAsync(PatchPurchaseOrderPurchaseConditionsDto req, CancellationToken ct)
{ {
var purchaseOrder = await database.PurchaseOrders.SingleOrDefaultAsync(po => po.Id == req.Id, ct); PurchaseOrder? purchaseOrder = await database.PurchaseOrders.SingleOrDefaultAsync(po => po.Id == req.Id, ct);
if (purchaseOrder == null) if (purchaseOrder == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -1,9 +1,10 @@
using Microsoft.EntityFrameworkCore;
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseProduct; namespace PyroFetes.Endpoints.PurchaseProducts;
public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoint<CreatePurchaseProductDto, GetPurchaseProductDto> public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoint<CreatePurchaseProductDto, GetPurchaseProductDto>
{ {
@@ -15,18 +16,18 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi
public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct) public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct)
{ {
var product = await database.Products.FirstOrDefaultAsync(p => p.Id == req.ProductId, ct); Product? product = await database.Products.FirstOrDefaultAsync(p => p.Id == req.ProductId, ct);
if (product == null) if (product == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);
return; return;
} }
var purchaseOrder = await database.PurchaseOrders.FirstOrDefaultAsync(po => po.Id == req.PurchaseOrderId, ct); PurchaseOrder? purchaseOrder = await database.PurchaseOrders.FirstOrDefaultAsync(po => po.Id == req.PurchaseOrderId, ct);
if (purchaseOrder == null) if (purchaseOrder == null)
{ {
purchaseOrder = new Models.PurchaseOrder() purchaseOrder = new PurchaseOrder()
{ {
PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées" PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées"
}; };
@@ -34,7 +35,7 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi
await database.SaveChangesAsync(ct); await database.SaveChangesAsync(ct);
} }
var purchaseProduct = new Models.PurchaseProduct() PurchaseProduct purchaseProduct = new PurchaseProduct()
{ {
ProductId = product.Id, ProductId = product.Id,
PurchaseOrderId = purchaseOrder.Id, PurchaseOrderId = purchaseOrder.Id,
@@ -43,7 +44,7 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi
database.PurchaseProducts.Add(purchaseProduct); database.PurchaseProducts.Add(purchaseProduct);
await database.SaveChangesAsync(ct); await database.SaveChangesAsync(ct);
var responseDto = new GetPurchaseProductDto() GetPurchaseProductDto responseDto = new GetPurchaseProductDto()
{ {
ProductId = product.Id, ProductId = product.Id,
ProductReferences = product.Reference, ProductReferences = product.Reference,

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseProduct; namespace PyroFetes.Endpoints.PurchaseProducts;
public class DeletePurchaseProductRequest public class DeletePurchaseProductRequest
{ {
@@ -19,7 +20,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint
public override async Task HandleAsync(DeletePurchaseProductRequest req, CancellationToken ct) public override async Task HandleAsync(DeletePurchaseProductRequest req, CancellationToken ct)
{ {
var purchaseProduct = await database.PurchaseProducts PurchaseProduct? purchaseProduct = await database.PurchaseProducts
.SingleOrDefaultAsync(po => po.ProductId == req.ProductId && po.PurchaseOrderId == req.PurchaseOrderId, ct); .SingleOrDefaultAsync(po => po.ProductId == req.ProductId && po.PurchaseOrderId == req.PurchaseOrderId, ct);
if (purchaseProduct == null) if (purchaseProduct == null)

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.PurchaseProduct; namespace PyroFetes.Endpoints.PurchaseProducts;
public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchPurchaseProductQuantityDto, GetPurchaseProductDto> public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchPurchaseProductQuantityDto, GetPurchaseProductDto>
{ {
@@ -15,7 +16,7 @@ public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) :
public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct) public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct)
{ {
var purchaseProduct = await database.PurchaseProducts.SingleOrDefaultAsync(po => po.ProductId == req.ProductId && po.PurchaseOrderId == req.PurchaseOrderId, ct); PurchaseProduct? purchaseProduct = await database.PurchaseProducts.SingleOrDefaultAsync(po => po.ProductId == req.ProductId && po.PurchaseOrderId == req.PurchaseOrderId, ct);
if (purchaseProduct == null) if (purchaseProduct == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.QuotationProduct.Request; using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.QuotationProduct; namespace PyroFetes.Endpoints.QuotationProducts;
public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpoint<CreateQuotationProductDto, GetQuotationProductDto> public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpoint<CreateQuotationProductDto, GetQuotationProductDto>
{ {
@@ -15,18 +16,18 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo
public override async Task HandleAsync(CreateQuotationProductDto req, CancellationToken ct) public override async Task HandleAsync(CreateQuotationProductDto req, CancellationToken ct)
{ {
var product = await database.Products.FirstOrDefaultAsync(p => p.Id == req.ProductId, ct); Product? product = await database.Products.FirstOrDefaultAsync(p => p.Id == req.ProductId, ct);
if (product == null) if (product == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);
return; return;
} }
var quotation = await database.Quotations.FirstOrDefaultAsync(q => q.Id == req.QuotationId, ct); Quotation? quotation = await database.Quotations.FirstOrDefaultAsync(q => q.Id == req.QuotationId, ct);
if (quotation == null) if (quotation == null)
{ {
quotation = new Models.Quotation() quotation = new Quotation()
{ {
Message = req.QuotationMessage ?? "", Message = req.QuotationMessage ?? "",
ConditionsSale = req.QuotationConditionsSale, ConditionsSale = req.QuotationConditionsSale,
@@ -35,7 +36,7 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo
await database.SaveChangesAsync(ct); await database.SaveChangesAsync(ct);
} }
var quotationProduct = new Models.QuotationProduct() QuotationProduct quotationProduct = new QuotationProduct()
{ {
ProductId = product.Id, ProductId = product.Id,
QuotationId = quotation.Id, QuotationId = quotation.Id,
@@ -44,7 +45,7 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo
database.QuotationProducts.Add(quotationProduct); database.QuotationProducts.Add(quotationProduct);
await database.SaveChangesAsync(ct); await database.SaveChangesAsync(ct);
var responseDto = new GetQuotationProductDto() GetQuotationProductDto responseDto = new GetQuotationProductDto()
{ {
ProductId = product.Id, ProductId = product.Id,
ProductReferences = product.Reference, ProductReferences = product.Reference,

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.QuotationProduct; namespace PyroFetes.Endpoints.QuotationProducts;
public class DeleteQuotationProductRequest public class DeleteQuotationProductRequest
{ {
@@ -19,7 +20,7 @@ public class DeleteQuotationProductEndpoint(PyroFetesDbContext database) : Endpo
public override async Task HandleAsync(DeleteQuotationProductRequest req, CancellationToken ct) public override async Task HandleAsync(DeleteQuotationProductRequest req, CancellationToken ct)
{ {
var quotationProduct = await database.QuotationProducts QuotationProduct? quotationProduct = await database.QuotationProducts
.SingleOrDefaultAsync(qo => qo.ProductId == req.ProductId && qo.QuotationId == req.QuotationId, ct); .SingleOrDefaultAsync(qo => qo.ProductId == req.ProductId && qo.QuotationId == req.QuotationId, ct);
if (quotationProduct == null) if (quotationProduct == null)

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.QuotationProduct.Request; using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.QuotationProduct; namespace PyroFetes.Endpoints.QuotationProducts;
public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchQuotationProductQuantityDto, GetQuotationProductDto> public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchQuotationProductQuantityDto, GetQuotationProductDto>
{ {
@@ -15,7 +16,7 @@ public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database)
public override async Task HandleAsync(PatchQuotationProductQuantityDto req, CancellationToken ct) public override async Task HandleAsync(PatchQuotationProductQuantityDto req, CancellationToken ct)
{ {
var quotationProduct = await database.QuotationProducts.SingleOrDefaultAsync(qo => qo.ProductId == req.ProductId && qo.QuotationId == req.QuotationId, ct); QuotationProduct? quotationProduct = await database.QuotationProducts.SingleOrDefaultAsync(qo => qo.ProductId == req.ProductId && qo.QuotationId == req.QuotationId, ct);
if (quotationProduct == null) if (quotationProduct == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Quotation; namespace PyroFetes.Endpoints.Quotations;
public class DeleteQuotationRequest public class DeleteQuotationRequest
{ {
@@ -18,7 +19,7 @@ public class DeleteQuotationEndpoint(PyroFetesDbContext database) : Endpoint<Del
public override async Task HandleAsync(DeleteQuotationRequest req, CancellationToken ct) public override async Task HandleAsync(DeleteQuotationRequest req, CancellationToken ct)
{ {
var quotation = await database.Quotations Quotation? quotation = await database.Quotations
.Include(q => q.QuotationProducts) .Include(q => q.QuotationProducts)
.SingleOrDefaultAsync(q => q.Id == req.Id, ct); .SingleOrDefaultAsync(q => q.Id == req.Id, ct);

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Quotation; namespace PyroFetes.Endpoints.Quotations;
public class GetAllQuotationEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetQuotationDto>> public class GetAllQuotationEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetQuotationDto>>
{ {
@@ -14,7 +15,7 @@ public class GetAllQuotationEndpoint(PyroFetesDbContext database) : EndpointWith
public override async Task HandleAsync(CancellationToken ct) public override async Task HandleAsync(CancellationToken ct)
{ {
var quotations = await database.Quotations List<GetQuotationDto> quotations = await database.Quotations
.Include(q => q.QuotationProducts!) .Include(q => q.QuotationProducts!)
.ThenInclude(qp => qp.Product) .ThenInclude(qp => qp.Product)
.Select(q => new GetQuotationDto .Select(q => new GetQuotationDto

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Quotation; namespace PyroFetes.Endpoints.Quotations;
public class GetQuotationRequest public class GetQuotationRequest
{ {
@@ -19,7 +20,7 @@ public class GetQuotationEndpoint(PyroFetesDbContext database) : Endpoint<GetQuo
public override async Task HandleAsync(GetQuotationRequest req, CancellationToken ct) public override async Task HandleAsync(GetQuotationRequest req, CancellationToken ct)
{ {
var quotation = await database.Quotations Quotation? quotation = await database.Quotations
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (quotation == null) if (quotation == null)

View File

@@ -1,13 +1,11 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Request;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.DTO.Quotation.Request; using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Quotation; namespace PyroFetes.Endpoints.Quotations;
public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) : Endpoint<PatchQuotationConditionsSaleDto, GetQuotationDto> public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) : Endpoint<PatchQuotationConditionsSaleDto, GetQuotationDto>
{ {
@@ -19,7 +17,7 @@ public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) :
public override async Task HandleAsync(PatchQuotationConditionsSaleDto req, CancellationToken ct) public override async Task HandleAsync(PatchQuotationConditionsSaleDto req, CancellationToken ct)
{ {
var quotation = await database.Quotations.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Quotation? quotation = await database.Quotations.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (quotation == null) if (quotation == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -1,8 +1,9 @@
using FastEndpoints; using FastEndpoints;
using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.SettingEndpoints; namespace PyroFetes.Endpoints.Settings;
public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint<CreateSettingDto, GetSettingDto> public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint<CreateSettingDto, GetSettingDto>
{ {
@@ -13,7 +14,7 @@ public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint<Creat
public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct) public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct)
{ {
var setting = new Models.Setting() Setting setting = new Setting()
{ {
ElectronicSignature = req.ElectronicSignature, ElectronicSignature = req.ElectronicSignature,
Logo = req.Logo Logo = req.Logo

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.SettingEndpoints; namespace PyroFetes.Endpoints.Settings;
public class DeleteSettingRequest public class DeleteSettingRequest
{ {
@@ -17,7 +18,7 @@ public class DeleteSettingEndpoint(PyroFetesDbContext database) : Endpoint<Delet
public override async Task HandleAsync(DeleteSettingRequest req, CancellationToken ct) public override async Task HandleAsync(DeleteSettingRequest req, CancellationToken ct)
{ {
var setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Setting? setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null) if (setting == null)
{ {

View File

@@ -1,8 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.SettingEndpoints; namespace PyroFetes.Endpoints.Settings;
public class GetSettingRequest public class GetSettingRequest
{ {
@@ -18,7 +19,7 @@ public class GetSettingEndpoint(PyroFetesDbContext database) : Endpoint<GetSetti
public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct) public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct)
{ {
var setting = await database.Settings Setting? setting = await database.Settings
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null) if (setting == null)

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.SettingEndpoints; namespace PyroFetes.Endpoints.Settings;
public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingElectronicSignatureDto, GetSettingDto> public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingElectronicSignatureDto, GetSettingDto>
{ {
@@ -14,7 +15,7 @@ public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database
public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct) public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct)
{ {
var setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Setting? setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null) if (setting == null)
{ {

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response; using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.SettingEndpoints; namespace PyroFetes.Endpoints.Settings;
public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingLogoDto, GetSettingDto> public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingLogoDto, GetSettingDto>
{ {
@@ -14,7 +15,7 @@ public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint<Pa
public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct) public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct)
{ {
var setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Setting? setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null) if (setting == null)
{ {

View File

@@ -1,8 +1,9 @@
using PyroFetes.DTO.Supplier.Request; using FastEndpoints;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.Supplier.Response;
using FastEndpoints; using PyroFetes.Models;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class CreateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<CreateSupplierDto, GetSupplierDto> public class CreateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<CreateSupplierDto, GetSupplierDto>
{ {
@@ -13,7 +14,7 @@ public class CreateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<Crea
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct) public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
{ {
var supplier = new Models.Supplier() Supplier? supplier = new Supplier()
{ {
Name = req.Name, Name = req.Name,
Email = req.Email, Email = req.Email,

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class DeleteSupplierRequest public class DeleteSupplierRequest
{ {
@@ -17,7 +18,7 @@ public class DeleteSupplierEndpoint(PyroFetesDbContext database) : Endpoint<Dele
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct) public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
{ {
var supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Supplier? supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (supplier == null) if (supplier == null)
{ {

View File

@@ -1,9 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.Supplier.Response;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSupplierDto>> public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSupplierDto>>
{ {
@@ -14,7 +13,7 @@ public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWith
public override async Task HandleAsync(CancellationToken ct) public override async Task HandleAsync(CancellationToken ct)
{ {
var supplier = await database.Suppliers List<GetSupplierDto> supplier = await database.Suppliers
.Select(supplier => new GetSupplierDto() .Select(supplier => new GetSupplierDto()
{ {
Id = supplier.Id, Id = supplier.Id,

View File

@@ -1,8 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class GetSupplierRequest public class GetSupplierRequest
{ {
@@ -18,7 +19,7 @@ public class GetSupplierEndpoint(PyroFetesDbContext database) : Endpoint<GetSupp
public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct) public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct)
{ {
var supplier = await database.Suppliers Supplier? supplier = await database.Suppliers
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (supplier == null) if (supplier == null)

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class PatchSupplierDeleveryDelayEndpoint(PyroFetesDbContext database) : Endpoint<PatchSupplierDeliveryDelayDto, GetSupplierDto> public class PatchSupplierDeleveryDelayEndpoint(PyroFetesDbContext database) : Endpoint<PatchSupplierDeliveryDelayDto, GetSupplierDto>
{ {
@@ -14,7 +15,7 @@ public class PatchSupplierDeleveryDelayEndpoint(PyroFetesDbContext database) : E
public override async Task HandleAsync(PatchSupplierDeliveryDelayDto req, CancellationToken ct) public override async Task HandleAsync(PatchSupplierDeliveryDelayDto req, CancellationToken ct)
{ {
var supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Supplier? supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (supplier == null) if (supplier == null)
{ {

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response; using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Supplier; namespace PyroFetes.Endpoints.Suppliers;
public class UpdateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<UpdateSupplierDto, GetSupplierDto> public class UpdateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<UpdateSupplierDto, GetSupplierDto>
{ {
@@ -14,7 +15,7 @@ public class UpdateSupplierEndpoint(PyroFetesDbContext database) : Endpoint<Upda
public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct) public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct)
{ {
var supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct); Supplier? supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (supplier == null) if (supplier == null)
{ {

View File

@@ -3,8 +3,9 @@ using FastEndpoints.Security;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<ConnectUserDto, GetTokenDto> public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<ConnectUserDto, GetTokenDto>
{ {
@@ -16,7 +17,7 @@ public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<Connect
public override async Task HandleAsync(ConnectUserDto req, CancellationToken ct) public override async Task HandleAsync(ConnectUserDto req, CancellationToken ct)
{ {
var user = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct); User? user = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct);
if (user == null) if (user == null)
{ {
@@ -26,7 +27,7 @@ public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint<Connect
if (BCrypt.Net.BCrypt.Verify(req.Password + user.Salt, user.Password)) if (BCrypt.Net.BCrypt.Verify(req.Password + user.Salt, user.Password))
{ {
var jwtToken = JwtBearer.CreateToken( string jwtToken = JwtBearer.CreateToken(
o => o =>
{ {
o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong"; o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong";

View File

@@ -2,8 +2,9 @@
using PasswordGenerator; using PasswordGenerator;
using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint<CreateUserDto, GetUserDto> public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint<CreateUserDto, GetUserDto>
{ {
@@ -17,7 +18,7 @@ public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint<CreateUs
{ {
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next(); string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
var user = new Models.User() User user = new User()
{ {
Name = req.Name, Name = req.Name,
Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt), Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt),

View File

@@ -1,7 +1,8 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class DeleteUserRequest public class DeleteUserRequest
{ {
@@ -17,7 +18,7 @@ public class DeleteUserEndpoint(PyroFetesDbContext database) : Endpoint<DeleteUs
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct) public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
{ {
var user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (user == null) if (user == null)
{ {

View File

@@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetUserDto>> public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetUserDto>>
{ {
@@ -13,7 +13,7 @@ public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutR
public override async Task HandleAsync(CancellationToken ct) public override async Task HandleAsync(CancellationToken ct)
{ {
var users = await database.Users List<GetUserDto> users = await database.Users
.Select(users => new GetUserDto() .Select(users => new GetUserDto()
{ {
Id = users.Id, Id = users.Id,

View File

@@ -1,8 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class GetUserRequest public class GetUserRequest
{ {
@@ -18,7 +19,7 @@ public class GetUserEndpoint(PyroFetesDbContext database) : Endpoint<GetUserRequ
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct) public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
{ {
var user = await database.Users User? user = await database.Users
.SingleOrDefaultAsync(x => x.Id == req.Id, ct); .SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (user == null) if (user == null)

View File

@@ -2,8 +2,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<PatchUserPasswordDto, GetUserDto> public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<PatchUserPasswordDto, GetUserDto>
{ {
@@ -15,7 +16,7 @@ public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint<P
public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct) public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct)
{ {
var user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (user == null) if (user == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);

View File

@@ -3,8 +3,9 @@ using Microsoft.EntityFrameworkCore;
using PasswordGenerator; using PasswordGenerator;
using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response; using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.User; namespace PyroFetes.Endpoints.Users;
public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUserDto, GetUserDto> public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUserDto, GetUserDto>
{ {
@@ -15,8 +16,8 @@ public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint<UpdateUs
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct) public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
{ {
var user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
var ckeckName = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct); User? ckeckName = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct);
if (user == null) if (user == null)
{ {

View File

@@ -1,8 +1,9 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.WareHouseProduct.Response; using PyroFetes.DTO.WareHouseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.WareHouseProduct; namespace PyroFetes.Endpoints.WareHouseProducts;
public class GetTotalQuantityRequest public class GetTotalQuantityRequest
{ {
@@ -19,7 +20,7 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<Ge
public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct) public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct)
{ {
var exists = await database.WarehouseProducts bool exists = await database.WarehouseProducts
.AnyAsync(wp => wp.ProductId == req.ProductId, ct); .AnyAsync(wp => wp.ProductId == req.ProductId, ct);
if (!exists) if (!exists)
@@ -28,7 +29,7 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<Ge
return; return;
} }
var totalQuantity = await database.WarehouseProducts int totalQuantity = await database.WarehouseProducts
.Where(wp => wp.ProductId == req.ProductId) .Where(wp => wp.ProductId == req.ProductId)
.SumAsync(wp => wp.Quantity, ct); .SumAsync(wp => wp.Quantity, ct);

View File

@@ -1,11 +1,10 @@
using FastEndpoints; using FastEndpoints;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.DTO.WareHouseProduct.Request; using PyroFetes.DTO.WareHouseProduct.Request;
using PyroFetes.DTO.WareHouseProduct.Response; using PyroFetes.DTO.WareHouseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.WareHouseProduct; namespace PyroFetes.Endpoints.WareHouseProducts;
public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchWareHouseProductQuantityDto, GetWareHouseProductDto> public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint<PatchWareHouseProductQuantityDto, GetWareHouseProductDto>
{ {
@@ -17,7 +16,7 @@ public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database)
public override async Task HandleAsync(PatchWareHouseProductQuantityDto req, CancellationToken ct) public override async Task HandleAsync(PatchWareHouseProductQuantityDto req, CancellationToken ct)
{ {
var wareHouseProduct = await database.WarehouseProducts.SingleOrDefaultAsync(wp => wp.ProductId == req.ProductId && wp.WarehouseId == req.WareHouseId, ct); WarehouseProduct? wareHouseProduct = await database.WarehouseProducts.SingleOrDefaultAsync(wp => wp.ProductId == req.ProductId && wp.WarehouseId == req.WareHouseId, ct);
if (wareHouseProduct == null) if (wareHouseProduct == null)
{ {
await Send.NotFoundAsync(ct); await Send.NotFoundAsync(ct);