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

@@ -1,6 +1,7 @@
using FastEndpoints;
using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices;
using PyroFetes.Specifications.Products;
@@ -23,10 +24,10 @@ public class CreatePriceEndpoint(
public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct)
{
// 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)
{
supplier = new Models.Supplier()
supplier = new Supplier()
{
Name = req.SupplierName,
Email = req.SupplierEmail,
@@ -40,10 +41,10 @@ public class CreatePriceEndpoint(
}
// 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)
{
product = new Models.Product()
product = new Product()
{
Reference = req.ProductReferences,
Name = req.ProductName,
@@ -60,7 +61,7 @@ public class CreatePriceEndpoint(
}
// 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)
{
@@ -69,7 +70,7 @@ public class CreatePriceEndpoint(
}
// Création du prix
var priceAdded = new Models.Price()
var priceAdded = new Price()
{
SellingPrice = req.SellingPrice,
SupplierId = supplier.Id,

View File

@@ -1,7 +1,8 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.QuotationProduct;
namespace PyroFetes.Endpoints.Prices;
public class DeletePriceRequest
{
@@ -19,7 +20,7 @@ public class DeletePriceEndpoint(PyroFetesDbContext database) : Endpoint<DeleteP
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);
if (price == null)

View File

@@ -2,8 +2,9 @@ using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Price;
namespace PyroFetes.Endpoints.Prices;
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)
{
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)
{
await Send.NotFoundAsync(ct);