diff --git a/PyroFetes/DTO/Price/Request/CreatePriceDto.cs b/PyroFetes/DTO/Price/Request/CreatePriceDto.cs index b149ef6..dc4f9b2 100644 --- a/PyroFetes/DTO/Price/Request/CreatePriceDto.cs +++ b/PyroFetes/DTO/Price/Request/CreatePriceDto.cs @@ -9,7 +9,7 @@ public class CreatePriceDto public string? SupplierEmail { get; set; } public string? SupplierPhone { get; set; } public string? SupplierAddress { get; set; } - public int SupplierZipCode { get; set; } + public string? SupplierZipCode { get; set; } public string? SupplierCity { get; set; } public int SupplierDeliveryDelay { get; set; } diff --git a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs index 7390854..1fc9a60 100644 --- a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -7,7 +7,7 @@ public class GetSupplierDto public string? Email { get; set; } public string? Phone { get; set; } public string? Address { get; set; } - public int ZipCode { get; set; } + public string? ZipCode { get; set; } public string? City { get; set; } public int DeliveryDelay { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs index 8661c64..16502ac 100644 --- a/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs +++ b/PyroFetes/Endpoints/Deliverers/CreateDelivererEndpoint.cs @@ -14,7 +14,6 @@ public class CreateDelivererEndpoint( { Post("api/deliverers"); AllowAnonymous(); - } public override async Task HandleAsync(CreateDelivererDto req, CancellationToken ct) diff --git a/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs index 20addcd..bc7a44a 100644 --- a/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs +++ b/PyroFetes/Endpoints/DeliveryNotes/CreateDeliveryNoteEndpoint.cs @@ -45,7 +45,7 @@ public class CreateDeliveryNoteEndpoint( foreach (var productQuantity in req.ProductQuantities!) { - Models.Product? product = + Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct); if (product != null) { diff --git a/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs b/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs index fcdbde3..3a71e9c 100644 --- a/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs +++ b/PyroFetes/Endpoints/Prices/CreatePriceEndpoint.cs @@ -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, diff --git a/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs b/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs index bb289c9..deb47e0 100644 --- a/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs +++ b/PyroFetes/Endpoints/Prices/DeletePriceEndpoint.cs @@ -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 p.ProductId == req.ProductId && p.SupplierId == req.SupplierId, ct); if (price == null) diff --git a/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs b/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs index 05dbdb8..b0a9084 100644 --- a/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs +++ b/PyroFetes/Endpoints/Prices/PatchPriceEndpoint.cs @@ -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 { @@ -15,7 +16,7 @@ public class PatchPriceEndpoint(PyroFetesDbContext database) : Endpoint 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); diff --git a/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs b/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs index 70ec082..e0d13d8 100644 --- a/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs +++ b/PyroFetes/Endpoints/Products/GetAllProductsEndpoint.cs @@ -1,9 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; 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> { @@ -14,7 +14,7 @@ public class GetAllProductsEndpoint(PyroFetesDbContext database) : EndpointWitho public override async Task HandleAsync(CancellationToken ct) { - var product = await database.Products + List product = await database.Products .Select(product => new GetProductDto() { Id = product.Id, diff --git a/PyroFetes/Endpoints/Products/GetProductEndpoint.cs b/PyroFetes/Endpoints/Products/GetProductEndpoint.cs index 72e3fa5..2125a9c 100644 --- a/PyroFetes/Endpoints/Products/GetProductEndpoint.cs +++ b/PyroFetes/Endpoints/Products/GetProductEndpoint.cs @@ -1,9 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Response; -using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Product; +namespace PyroFetes.Endpoints.Products; public class GetProductRequest { @@ -19,7 +19,7 @@ public class GetProductEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (product == null) diff --git a/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs b/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs index 31ad504..69995ad 100644 --- a/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs +++ b/PyroFetes/Endpoints/Products/PatchProductMinimalStockEndpoint.cs @@ -2,9 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Request; 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) : Endpoint @@ -17,7 +17,7 @@ public class PatchProductMinimalStockEndpoint(PyroFetesDbContext database) 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) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs b/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs index 856280f..ca26fde 100644 --- a/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Products/UpdateProductEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Product.Request; using PyroFetes.DTO.Product.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Product; +namespace PyroFetes.Endpoints.Products; public class UpdateProductEndpoint(PyroFetesDbContext database) : Endpoint { @@ -14,7 +15,7 @@ public class UpdateProductEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + Product? product = await database.Products.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (product == null) { diff --git a/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs rename to PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs index a6a990a..a2d68a8 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/DeletePurchaseOrderEndpoint.cs @@ -1,7 +1,8 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseOrder; +namespace PyroFetes.Endpoints.PurchaseOrders; public class DeletePurchaseOrderRequest { @@ -18,7 +19,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct) { - var purchaseOrder = await database.PurchaseOrders + PurchaseOrder? purchaseOrder = await database.PurchaseOrders .Include(po => po.PurchaseProducts) .SingleOrDefaultAsync(po => po.Id == req.Id, ct); diff --git a/PyroFetes/Endpoints/PurchaseOrder/GetAllPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs similarity index 93% rename from PyroFetes/Endpoints/PurchaseOrder/GetAllPurchaseOrderEndpoint.cs rename to PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs index c79de3d..b2e4c7e 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/GetAllPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseProduct.Response; -namespace PyroFetes.Endpoints.PurchaseOrder; +namespace PyroFetes.Endpoints.PurchaseOrders; public class GetAllPurchaseOrderEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest> { @@ -14,7 +14,7 @@ public class GetAllPurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint public override async Task HandleAsync(CancellationToken ct) { - var purchaseOrder = await database.PurchaseOrders + List purchaseOrder = await database.PurchaseOrders .Include(p => p.PurchaseProducts) .Select(purchaseOrder => new GetPurchaseOrderDto() { diff --git a/PyroFetes/Endpoints/PurchaseOrder/GetPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs similarity index 92% rename from PyroFetes/Endpoints/PurchaseOrder/GetPurchaseOrderEndpoint.cs rename to PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs index 0f0562a..8920221 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/GetPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetPurchaseOrderEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseOrder; +namespace PyroFetes.Endpoints.PurchaseOrders; public class GetPurchaseOrderRequest { @@ -19,7 +20,7 @@ public class GetPurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (purchaseOrder == null) diff --git a/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs similarity index 90% rename from PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs rename to PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs index a6bbff0..04beca3 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/PatchPurchaseOrderPurchaseConditionsEndpoint.cs @@ -2,10 +2,10 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseOrder.Request; using PyroFetes.DTO.PurchaseOrder.Response; -using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseOrder; +namespace PyroFetes.Endpoints.PurchaseOrders; public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext database) : Endpoint { @@ -17,7 +17,7 @@ public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext dat 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) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/PurchaseProduct/CreatePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs similarity index 79% rename from PyroFetes/Endpoints/PurchaseProduct/CreatePurchaseProductEndpoint.cs rename to PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs index f060c3a..3aad50d 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/CreatePurchaseProductEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProducts/CreatePurchaseProductEndpoint.cs @@ -1,9 +1,10 @@ -using Microsoft.EntityFrameworkCore; using FastEndpoints; +using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseProduct; +namespace PyroFetes.Endpoints.PurchaseProducts; public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,18 +16,18 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi 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) { await Send.NotFoundAsync(ct); 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) { - purchaseOrder = new Models.PurchaseOrder() + purchaseOrder = new PurchaseOrder() { PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées" }; @@ -34,7 +35,7 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi await database.SaveChangesAsync(ct); } - var purchaseProduct = new Models.PurchaseProduct() + PurchaseProduct purchaseProduct = new PurchaseProduct() { ProductId = product.Id, PurchaseOrderId = purchaseOrder.Id, @@ -43,7 +44,7 @@ public class CreatePurchaseProductEndpoint(PyroFetesDbContext database) : Endpoi database.PurchaseProducts.Add(purchaseProduct); await database.SaveChangesAsync(ct); - var responseDto = new GetPurchaseProductDto() + GetPurchaseProductDto responseDto = new GetPurchaseProductDto() { ProductId = product.Id, ProductReferences = product.Reference, diff --git a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs similarity index 87% rename from PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs rename to PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs index 93d60fb..3a06268 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProducts/DeletePurchaseProductEndpoint.cs @@ -1,7 +1,8 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseProduct; +namespace PyroFetes.Endpoints.PurchaseProducts; public class DeletePurchaseProductRequest { @@ -19,7 +20,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint 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); if (purchaseProduct == null) diff --git a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs similarity index 81% rename from PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs rename to PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs index 952dd8d..1e72074 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProducts/PatchPurchaseProductQuantityEndpoint.cs @@ -2,8 +2,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.PurchaseProduct.Request; using PyroFetes.DTO.PurchaseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.PurchaseProduct; +namespace PyroFetes.Endpoints.PurchaseProducts; public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,7 +16,7 @@ public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : 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) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/QuotationProduct/CreateQuotationProductEndpoint.cs b/PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs similarity index 80% rename from PyroFetes/Endpoints/QuotationProduct/CreateQuotationProductEndpoint.cs rename to PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs index ada8499..6e24781 100644 --- a/PyroFetes/Endpoints/QuotationProduct/CreateQuotationProductEndpoint.cs +++ b/PyroFetes/Endpoints/QuotationProducts/CreateQuotationProductEndpoint.cs @@ -2,8 +2,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.QuotationProduct.Request; using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.QuotationProduct; +namespace PyroFetes.Endpoints.QuotationProducts; public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,18 +16,18 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo 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) { await Send.NotFoundAsync(ct); 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) { - quotation = new Models.Quotation() + quotation = new Quotation() { Message = req.QuotationMessage ?? "", ConditionsSale = req.QuotationConditionsSale, @@ -35,7 +36,7 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo await database.SaveChangesAsync(ct); } - var quotationProduct = new Models.QuotationProduct() + QuotationProduct quotationProduct = new QuotationProduct() { ProductId = product.Id, QuotationId = quotation.Id, @@ -44,7 +45,7 @@ public class CreateQuotationProductEndpoint(PyroFetesDbContext database) : Endpo database.QuotationProducts.Add(quotationProduct); await database.SaveChangesAsync(ct); - var responseDto = new GetQuotationProductDto() + GetQuotationProductDto responseDto = new GetQuotationProductDto() { ProductId = product.Id, ProductReferences = product.Reference, diff --git a/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs b/PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs similarity index 86% rename from PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs rename to PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs index aa480e8..2ee2d1e 100644 --- a/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs +++ b/PyroFetes/Endpoints/QuotationProducts/DeleteQuotationProductEndpoint.cs @@ -1,7 +1,8 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.QuotationProduct; +namespace PyroFetes.Endpoints.QuotationProducts; public class DeleteQuotationProductRequest { @@ -19,7 +20,7 @@ public class DeleteQuotationProductEndpoint(PyroFetesDbContext database) : Endpo 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); if (quotationProduct == null) diff --git a/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs b/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs similarity index 81% rename from PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs rename to PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs index 33c050e..68034c9 100644 --- a/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/QuotationProducts/PatchQuotationProductQuantityEndpoint.cs @@ -2,8 +2,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.QuotationProduct.Request; using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.QuotationProduct; +namespace PyroFetes.Endpoints.QuotationProducts; public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,7 +16,7 @@ public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database) 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) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs similarity index 89% rename from PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs rename to PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs index e83ae15..dbb0bfe 100644 --- a/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/DeleteQuotationEndpoint.cs @@ -1,7 +1,8 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Quotation; +namespace PyroFetes.Endpoints.Quotations; public class DeleteQuotationRequest { @@ -18,7 +19,7 @@ public class DeleteQuotationEndpoint(PyroFetesDbContext database) : Endpoint q.QuotationProducts) .SingleOrDefaultAsync(q => q.Id == req.Id, ct); diff --git a/PyroFetes/Endpoints/Quotation/GetAllQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs similarity index 92% rename from PyroFetes/Endpoints/Quotation/GetAllQuotationEndpoint.cs rename to PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs index 2dad3aa..f4efa10 100644 --- a/PyroFetes/Endpoints/Quotation/GetAllQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Quotation; +namespace PyroFetes.Endpoints.Quotations; public class GetAllQuotationEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest> { @@ -14,7 +15,7 @@ public class GetAllQuotationEndpoint(PyroFetesDbContext database) : EndpointWith public override async Task HandleAsync(CancellationToken ct) { - var quotations = await database.Quotations + List quotations = await database.Quotations .Include(q => q.QuotationProducts!) .ThenInclude(qp => qp.Product) .Select(q => new GetQuotationDto diff --git a/PyroFetes/Endpoints/Quotation/GetQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs similarity index 93% rename from PyroFetes/Endpoints/Quotation/GetQuotationEndpoint.cs rename to PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs index 162245c..0a455b4 100644 --- a/PyroFetes/Endpoints/Quotation/GetQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetQuotationEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Quotation; +namespace PyroFetes.Endpoints.Quotations; public class GetQuotationRequest { @@ -19,7 +20,7 @@ public class GetQuotationEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (quotation == null) diff --git a/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs b/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs rename to PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs index 8cc9609..1462f7e 100644 --- a/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/PatchQuotationConditionsSaleEndpoint.cs @@ -1,13 +1,11 @@ using FastEndpoints; 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.Response; using PyroFetes.DTO.QuotationProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Quotation; +namespace PyroFetes.Endpoints.Quotations; public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) : Endpoint { @@ -19,7 +17,7 @@ public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) : 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) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/SettingEndpoints/CreateSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/SettingEndpoints/CreateSettingEndpoint.cs rename to PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs index 93250d6..97c35fb 100644 --- a/PyroFetes/Endpoints/SettingEndpoints/CreateSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/CreateSettingEndpoint.cs @@ -1,8 +1,9 @@ using FastEndpoints; using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.SettingEndpoints; +namespace PyroFetes.Endpoints.Settings; public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint { @@ -13,7 +14,7 @@ public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + Setting? setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (setting == null) { diff --git a/PyroFetes/Endpoints/SettingEndpoints/GetSettingEndpoint.cs b/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/SettingEndpoints/GetSettingEndpoint.cs rename to PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs index 34b059d..f3011ab 100644 --- a/PyroFetes/Endpoints/SettingEndpoints/GetSettingEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/GetSettingEndpoint.cs @@ -1,8 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.SettingEndpoints; +namespace PyroFetes.Endpoints.Settings; public class GetSettingRequest { @@ -18,7 +19,7 @@ public class GetSettingEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (setting == null) diff --git a/PyroFetes/Endpoints/SettingEndpoints/PatchSettingElectronicSignatureEndpoint.cs b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs similarity index 86% rename from PyroFetes/Endpoints/SettingEndpoints/PatchSettingElectronicSignatureEndpoint.cs rename to PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs index 39e8459..7119c1d 100644 --- a/PyroFetes/Endpoints/SettingEndpoints/PatchSettingElectronicSignatureEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/PatchSettingElectronicSignatureEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.SettingEndpoints; +namespace PyroFetes.Endpoints.Settings; public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database) : Endpoint { @@ -14,7 +15,7 @@ public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database 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) { diff --git a/PyroFetes/Endpoints/SettingEndpoints/PatchSettingLogoEndpoint.cs b/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs similarity index 84% rename from PyroFetes/Endpoints/SettingEndpoints/PatchSettingLogoEndpoint.cs rename to PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs index 553800a..8916f20 100644 --- a/PyroFetes/Endpoints/SettingEndpoints/PatchSettingLogoEndpoint.cs +++ b/PyroFetes/Endpoints/Settings/PatchSettingLogoEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.SettingDTO.Request; using PyroFetes.DTO.SettingDTO.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.SettingEndpoints; +namespace PyroFetes.Endpoints.Settings; public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint { @@ -14,7 +15,7 @@ public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + Setting? setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (setting == null) { diff --git a/PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs similarity index 86% rename from PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs index 6232481..0bf6b9e 100644 --- a/PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/CreateSupplierEndpoint.cs @@ -1,8 +1,9 @@ -using PyroFetes.DTO.Supplier.Request; +using FastEndpoints; +using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Response; -using FastEndpoints; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Supplier; +namespace PyroFetes.Endpoints.Suppliers; public class CreateSupplierEndpoint(PyroFetesDbContext database) : Endpoint { @@ -13,7 +14,7 @@ public class CreateSupplierEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + Supplier? supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (supplier == null) { diff --git a/PyroFetes/Endpoints/Supplier/GetAllSuppliersEndpoint.cs b/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs similarity index 86% rename from PyroFetes/Endpoints/Supplier/GetAllSuppliersEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs index b550c85..ea65f22 100644 --- a/PyroFetes/Endpoints/Supplier/GetAllSuppliersEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/GetAllSuppliersEndpoint.cs @@ -1,9 +1,8 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.PurchaseProduct.Response; using PyroFetes.DTO.Supplier.Response; -namespace PyroFetes.Endpoints.Supplier; +namespace PyroFetes.Endpoints.Suppliers; public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest> { @@ -14,7 +13,7 @@ public class GetAllSuppliersEndpoint(PyroFetesDbContext database) : EndpointWith public override async Task HandleAsync(CancellationToken ct) { - var supplier = await database.Suppliers + List supplier = await database.Suppliers .Select(supplier => new GetSupplierDto() { Id = supplier.Id, diff --git a/PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs similarity index 90% rename from PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs index 40b6e8e..a2dec7c 100644 --- a/PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/GetSupplierEndpoint.cs @@ -1,8 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Supplier; +namespace PyroFetes.Endpoints.Suppliers; public class GetSupplierRequest { @@ -18,7 +19,7 @@ public class GetSupplierEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (supplier == null) diff --git a/PyroFetes/Endpoints/Supplier/PatchSupplierDeleveryDelayEndpoint.cs b/PyroFetes/Endpoints/Suppliers/PatchSupplierDeleveryDelayEndpoint.cs similarity index 84% rename from PyroFetes/Endpoints/Supplier/PatchSupplierDeleveryDelayEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/PatchSupplierDeleveryDelayEndpoint.cs index ea31903..3574f2e 100644 --- a/PyroFetes/Endpoints/Supplier/PatchSupplierDeleveryDelayEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/PatchSupplierDeleveryDelayEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Supplier; +namespace PyroFetes.Endpoints.Suppliers; public class PatchSupplierDeleveryDelayEndpoint(PyroFetesDbContext database) : Endpoint { @@ -14,7 +15,7 @@ public class PatchSupplierDeleveryDelayEndpoint(PyroFetesDbContext database) : E 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) { diff --git a/PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs b/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs rename to PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs index ab68ebb..6a81bbc 100644 --- a/PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs +++ b/PyroFetes/Endpoints/Suppliers/UpdateSupplierEndpoint.cs @@ -2,8 +2,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.Supplier.Request; using PyroFetes.DTO.Supplier.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.Supplier; +namespace PyroFetes.Endpoints.Suppliers; public class UpdateSupplierEndpoint(PyroFetesDbContext database) : Endpoint { @@ -14,7 +15,7 @@ public class UpdateSupplierEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + Supplier? supplier = await database.Suppliers.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (supplier == null) { diff --git a/PyroFetes/Endpoints/User/ConnectUserEndpoint.cs b/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs similarity index 86% rename from PyroFetes/Endpoints/User/ConnectUserEndpoint.cs rename to PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs index b84c932..7ddff69 100644 --- a/PyroFetes/Endpoints/User/ConnectUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/ConnectUserEndpoint.cs @@ -3,8 +3,9 @@ using FastEndpoints.Security; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint { @@ -16,7 +17,7 @@ public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint x.Name == req.Name, ct); + User? user = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct); if (user == null) { @@ -26,7 +27,7 @@ public class ConnectUserEndpoint(PyroFetesDbContext database) : Endpoint { o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong"; diff --git a/PyroFetes/Endpoints/User/CreateUserEndpoint.cs b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs similarity index 92% rename from PyroFetes/Endpoints/User/CreateUserEndpoint.cs rename to PyroFetes/Endpoints/Users/CreateUserEndpoint.cs index 466cb8b..a923b4e 100644 --- a/PyroFetes/Endpoints/User/CreateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs @@ -2,8 +2,9 @@ using PasswordGenerator; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint { @@ -17,7 +18,7 @@ public class CreateUserEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); + User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (user == null) { diff --git a/PyroFetes/Endpoints/User/GetAllUsersEndpoint.cs b/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs similarity index 88% rename from PyroFetes/Endpoints/User/GetAllUsersEndpoint.cs rename to PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs index 5b027b5..65506a8 100644 --- a/PyroFetes/Endpoints/User/GetAllUsersEndpoint.cs +++ b/PyroFetes/Endpoints/Users/GetAllUsersEndpoint.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Response; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest> { @@ -13,7 +13,7 @@ public class GetAllUsersEndpoint(PyroFetesDbContext database) : EndpointWithoutR public override async Task HandleAsync(CancellationToken ct) { - var users = await database.Users + List users = await database.Users .Select(users => new GetUserDto() { Id = users.Id, diff --git a/PyroFetes/Endpoints/User/GetUserEndpoint.cs b/PyroFetes/Endpoints/Users/GetUserEndpoint.cs similarity index 90% rename from PyroFetes/Endpoints/User/GetUserEndpoint.cs rename to PyroFetes/Endpoints/Users/GetUserEndpoint.cs index f373674..0de2798 100644 --- a/PyroFetes/Endpoints/User/GetUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/GetUserEndpoint.cs @@ -1,8 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class GetUserRequest { @@ -18,7 +19,7 @@ public class GetUserEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); if (user == null) diff --git a/PyroFetes/Endpoints/User/PatchUserPasswordEndpoint.cs b/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs similarity index 87% rename from PyroFetes/Endpoints/User/PatchUserPasswordEndpoint.cs rename to PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs index 4049b89..17e5af8 100644 --- a/PyroFetes/Endpoints/User/PatchUserPasswordEndpoint.cs +++ b/PyroFetes/Endpoints/Users/PatchUserPasswordEndpoint.cs @@ -2,8 +2,9 @@ using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,7 +16,7 @@ public class PatchUserPasswordEndpoint(PyroFetesDbContext database) : Endpoint

x.Id == req.Id, ct); + User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); if (user == null) { await Send.NotFoundAsync(ct); diff --git a/PyroFetes/Endpoints/User/UpdateUserEndpoint.cs b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs similarity index 85% rename from PyroFetes/Endpoints/User/UpdateUserEndpoint.cs rename to PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs index 13a8935..0ecc3c1 100644 --- a/PyroFetes/Endpoints/User/UpdateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs @@ -3,8 +3,9 @@ using Microsoft.EntityFrameworkCore; using PasswordGenerator; using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.User; +namespace PyroFetes.Endpoints.Users; public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint { @@ -15,8 +16,8 @@ public class UpdateUserEndpoint(PyroFetesDbContext database) : Endpoint x.Id == req.Id, ct); - var ckeckName = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct); + User? user = await database.Users.SingleOrDefaultAsync(x => x.Id == req.Id, ct); + User? ckeckName = await database.Users.SingleOrDefaultAsync(x => x.Name == req.Name, ct); if (user == null) { diff --git a/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs similarity index 84% rename from PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs rename to PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs index 0005391..a6398c8 100644 --- a/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProducts/GetTotalQuantityEndpoint.cs @@ -1,8 +1,9 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; using PyroFetes.DTO.WareHouseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.WareHouseProduct; +namespace PyroFetes.Endpoints.WareHouseProducts; public class GetTotalQuantityRequest { @@ -19,7 +20,7 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint wp.ProductId == req.ProductId, ct); if (!exists) @@ -28,7 +29,7 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint wp.ProductId == req.ProductId) .SumAsync(wp => wp.Quantity, ct); diff --git a/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs similarity index 78% rename from PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs rename to PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs index d5cc5f8..5426645 100644 --- a/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProducts/PatchWareHouseProductQuantityEndpoint.cs @@ -1,11 +1,10 @@ using FastEndpoints; using Microsoft.EntityFrameworkCore; -using PyroFetes.DTO.QuotationProduct.Request; -using PyroFetes.DTO.QuotationProduct.Response; using PyroFetes.DTO.WareHouseProduct.Request; using PyroFetes.DTO.WareHouseProduct.Response; +using PyroFetes.Models; -namespace PyroFetes.Endpoints.WareHouseProduct; +namespace PyroFetes.Endpoints.WareHouseProducts; public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) : Endpoint { @@ -17,7 +16,7 @@ public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) 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) { await Send.NotFoundAsync(ct);