Cleaned code
This commit is contained in:
@@ -51,7 +51,7 @@ public class CreateDeliveryNoteEndpoint(
|
||||
DeliveryNote = newDeliveryNote,
|
||||
Quantity = productQuantity.Value,
|
||||
Product = product,
|
||||
ProductId = product.Id,
|
||||
ProductId = product.Id,
|
||||
DeliveryNoteId = newDeliveryNote.Id
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ public class GetAllDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRep
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync<GetDeliveryNoteDto>(new GetAllDeliveryNoteSpec() ,ct), ct);
|
||||
await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync<GetDeliveryNoteDto>(new GetAllDeliveryNoteSpec(), ct), ct);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ using PyroFetes.Specifications.DeliveryNotes;
|
||||
|
||||
namespace PyroFetes.Endpoints.DeliveryNotes;
|
||||
|
||||
public class GetDeliveryNotePdfEndpoint(DeliveryNotesRepository deliveryNotesRepository, IDeliveryNotePdfService deliveryNotePdfService, SettingsRepository settingsRepository) : Endpoint<GetDeliveryNotePdfDto, byte[]>
|
||||
public class GetDeliveryNotePdfEndpoint(DeliveryNotesRepository deliveryNotesRepository, IDeliveryNotePdfService deliveryNotePdfService, SettingsRepository settingsRepository)
|
||||
: Endpoint<GetDeliveryNotePdfDto, byte[]>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PatchProductMinimalStockEndpoint(ProductsRepository productsReposit
|
||||
}
|
||||
|
||||
mapper.Map(req, product);
|
||||
|
||||
|
||||
await productsRepository.UpdateAsync(product, ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class CreatePurchaseOrder(
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
PurchaseProduct? purchaseProduct =
|
||||
|
||||
PurchaseProduct? purchaseProduct =
|
||||
await purchaseProductsRepository.SingleOrDefaultAsync(new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(line.ProductId, purchaseOrder.Id), ct);
|
||||
|
||||
if (purchaseProduct is not null)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PyroFetes.Endpoints.PurchaseOrders;
|
||||
|
||||
public class GetPurchaseOrderPdfEndpoint(
|
||||
PurchaseOrdersRepository purchaseOrdersRepository,
|
||||
IPurchaseOrderPdfService purchaseOrderPdfService,
|
||||
IPurchaseOrderPdfService purchaseOrderPdfService,
|
||||
SettingsRepository settingsRepository)
|
||||
: Endpoint<GetPurchaseOrderPdfDto, byte[]>
|
||||
{
|
||||
@@ -24,7 +24,7 @@ public class GetPurchaseOrderPdfEndpoint(
|
||||
public override async Task HandleAsync(GetPurchaseOrderPdfDto req, CancellationToken ct)
|
||||
{
|
||||
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.SingleOrDefaultAsync(new GetPurchaseOrderByIdWithProductsSpec(req.Id), ct);
|
||||
|
||||
|
||||
if (purchaseOrder is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
@@ -32,7 +32,7 @@ public class GetPurchaseOrderPdfEndpoint(
|
||||
}
|
||||
|
||||
Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct);
|
||||
|
||||
|
||||
byte[] bytes = purchaseOrderPdfService.Generate(purchaseOrder, purchaseOrder.PurchaseProducts!, setting!);
|
||||
|
||||
await Send.BytesAsync(
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PatchPurchaseProductQuantityEndpoint(PurchaseProductsRepository pur
|
||||
}
|
||||
|
||||
mapper.Map(req, purchaseProduct);
|
||||
|
||||
|
||||
await purchaseProductsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ public class AddProductoToQuotationEndpoint(
|
||||
|
||||
public override async Task HandleAsync(AddQuotationProductDto req, CancellationToken ct)
|
||||
{
|
||||
QuotationProduct? productQuotation = await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct);
|
||||
QuotationProduct? productQuotation =
|
||||
await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct);
|
||||
|
||||
if (productQuotation is not null)
|
||||
{
|
||||
@@ -28,7 +29,7 @@ public class AddProductoToQuotationEndpoint(
|
||||
}
|
||||
|
||||
QuotationProduct quotationProduct = mapper.Map<QuotationProduct>(req);
|
||||
|
||||
|
||||
await quotationProductsRepository.AddAsync(quotationProduct, ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CreateQuotationEndpoint(
|
||||
Product? product = await productsRepository.SingleOrDefaultAsync(new GetProductByIdSpec(line.ProductId), ct);
|
||||
QuotationProduct? quotationProduct =
|
||||
await quotationProductsRepository.SingleOrDefaultAsync(new GetQuotationProductByProductIdAndQuotationIdSpec(line.ProductId, quotation.Id), ct);
|
||||
|
||||
|
||||
if (product is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PyroFetes.Endpoints.Quotations;
|
||||
|
||||
public class GetQuotationPdfEndpoint(
|
||||
QuotationsRepository quotationRepository,
|
||||
IQuotationPdfService quotationPdfService,
|
||||
IQuotationPdfService quotationPdfService,
|
||||
SettingsRepository settingsRepository)
|
||||
: Endpoint<GetQuotationPdfDto, byte[]>
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public class GetQuotationPdfEndpoint(
|
||||
}
|
||||
|
||||
Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct);
|
||||
|
||||
|
||||
byte[] bytes = quotationPdfService.Generate(quotation, quotation.QuotationProducts!, setting!);
|
||||
|
||||
await Send.BytesAsync(
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PatchQuotationConditionsSaleEndpoint(
|
||||
}
|
||||
|
||||
mapper.Map(req, quotation);
|
||||
|
||||
|
||||
await quotationsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PatchQuotationMessageEndpoint(
|
||||
}
|
||||
|
||||
mapper.Map(req, quotation);
|
||||
|
||||
|
||||
await quotationsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PatchQuotationProductQuantityEndpoint(
|
||||
}
|
||||
|
||||
mapper.Map(req, quotationProduct);
|
||||
|
||||
|
||||
await quotationProductsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UpdateQuotationEndpoint(
|
||||
}
|
||||
|
||||
mapper.Map(req, quotation);
|
||||
|
||||
|
||||
await quotationsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CreateSettingEndpoint(SettingsRepository settingsRepository) : Endp
|
||||
|
||||
if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct);
|
||||
byte[] signatureBytes = memoryStream.ToArray();
|
||||
|
||||
|
||||
Setting setting = new()
|
||||
{
|
||||
ElectronicSignature = Convert.ToBase64String(signatureBytes),
|
||||
|
||||
@@ -28,9 +28,9 @@ public class PatchSettingElectronicSignatureEndpoint(SettingsRepository settings
|
||||
using MemoryStream memoryStream = new();
|
||||
if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct);
|
||||
byte[] signatureBytes = memoryStream.ToArray();
|
||||
|
||||
|
||||
setting.ElectronicSignature = Convert.ToBase64String(signatureBytes);
|
||||
|
||||
|
||||
await settingsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public class PatchSettingLogoEndpoint(SettingsRepository settingsRepository) : E
|
||||
using MemoryStream memoryStream = new();
|
||||
if (req.Logo != null) await req.Logo.CopyToAsync(memoryStream, ct);
|
||||
byte[] logoBytes = memoryStream.ToArray();
|
||||
|
||||
|
||||
setting.Logo = Convert.ToBase64String(logoBytes);
|
||||
|
||||
|
||||
await settingsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PyroFetes.Endpoints.Suppliers;
|
||||
public class AddProductToSupplierEndpoint(
|
||||
SuppliersRepository suppliersRepository,
|
||||
ProductsRepository productsRepository,
|
||||
PricesRepository pricesRepository,
|
||||
PricesRepository pricesRepository,
|
||||
AutoMapper.IMapper mapper) : Endpoint<CreatePriceDto>
|
||||
{
|
||||
public override void Configure()
|
||||
@@ -36,7 +36,7 @@ public class AddProductToSupplierEndpoint(
|
||||
await Send.StringAsync("Le fournisseur a déjà un prix pour ce produit.", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await pricesRepository.AddAsync(mapper.Map<Price>(req), ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PatchPriceEndpoint(
|
||||
}
|
||||
|
||||
mapper.Map(req, price);
|
||||
|
||||
|
||||
await pricesRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using PyroFetes.Specifications.Users;
|
||||
|
||||
namespace PyroFetes.Endpoints.Users;
|
||||
|
||||
public class PatchUserPasswordEndpoint(UsersRepository usersRepository,AutoMapper.IMapper mapper) : Endpoint<PatchUserPasswordDto, GetUserDto>
|
||||
public class PatchUserPasswordEndpoint(UsersRepository usersRepository, AutoMapper.IMapper mapper) : Endpoint<PatchUserPasswordDto, GetUserDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PatchWareHouseProductQuantityEndpoint(WarehouseProductsRepository w
|
||||
|
||||
public override async Task HandleAsync(PatchWareHouseProductQuantityDto req, CancellationToken ct)
|
||||
{
|
||||
WarehouseProduct? wareHouseProduct = await warehouseProductsRepository.FirstOrDefaultAsync(new GetWarehouseProductByProductIdSpec(req.ProductId, req.WareHouseId) , ct);
|
||||
WarehouseProduct? wareHouseProduct = await warehouseProductsRepository.FirstOrDefaultAsync(new GetWarehouseProductByProductIdSpec(req.ProductId, req.WareHouseId), ct);
|
||||
|
||||
if (wareHouseProduct is null)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public class PatchWareHouseProductQuantityEndpoint(WarehouseProductsRepository w
|
||||
|
||||
wareHouseProduct.Quantity = req.Quantity;
|
||||
await warehouseProductsRepository.SaveChangesAsync(ct);
|
||||
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user