From e02d9b1ac06afc1d0619fcc3c2e37b2f46d62a95 Mon Sep 17 00:00:00 2001 From: leandro Date: Thu, 19 Mar 2026 18:23:26 -0300 Subject: [PATCH] feat(sales): incorporar servicio UI para consumo de Delivery Note closes #25 --- phronCare.UIBlazor/Program.cs | 2 + .../DeliveryNotes/DeliveryNoteService.cs | 51 +++++++++++++++++++ .../DeliveryNotes/IDeliveryNoteService.cs | 11 ++++ 3 files changed, 64 insertions(+) create mode 100644 phronCare.UIBlazor/Services/Sales/DeliveryNotes/DeliveryNoteService.cs create mode 100644 phronCare.UIBlazor/Services/Sales/DeliveryNotes/IDeliveryNoteService.cs diff --git a/phronCare.UIBlazor/Program.cs b/phronCare.UIBlazor/Program.cs index e543f5f..7335aac 100644 --- a/phronCare.UIBlazor/Program.cs +++ b/phronCare.UIBlazor/Program.cs @@ -7,6 +7,7 @@ using phronCare.UIBlazor; using phronCare.UIBlazor.Services.Authorization; using phronCare.UIBlazor.Services.Integrations; using phronCare.UIBlazor.Services.Lookups; +using phronCare.UIBlazor.Services.Sales.DeliveryNotes; using phronCare.UIBlazor.Services.Sales; using phronCare.UIBlazor.Services.Sales.Quotes; using phronCare.UIBlazor.Services.Stock; @@ -56,6 +57,7 @@ static void InjectDependencies(WebAssemblyHostBuilder builder) builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/phronCare.UIBlazor/Services/Sales/DeliveryNotes/DeliveryNoteService.cs b/phronCare.UIBlazor/Services/Sales/DeliveryNotes/DeliveryNoteService.cs new file mode 100644 index 0000000..05d999b --- /dev/null +++ b/phronCare.UIBlazor/Services/Sales/DeliveryNotes/DeliveryNoteService.cs @@ -0,0 +1,51 @@ +using Domain.Dtos.Sales; +using System.Net.Http.Json; + +namespace phronCare.UIBlazor.Services.Sales.DeliveryNotes +{ + public class DeliveryNoteService : IDeliveryNoteService + { + private readonly HttpClient _http; + + public DeliveryNoteService(HttpClient http) + { + _http = http; + } + + public async Task GetByIdAsync(int id) + { + try + { + return await _http.GetFromJsonAsync($"/api/deliverynote/{id}"); + } + catch + { + return null; + } + } + + public async Task GetByDeliveryNoteNumberAsync(string deliveryNoteNumber) + { + try + { + return await _http.GetFromJsonAsync($"/api/deliverynote/number/{Uri.EscapeDataString(deliveryNoteNumber)}"); + } + catch + { + return null; + } + } + + public async Task> GetByQuoteIdAsync(int quoteId) + { + try + { + return await _http.GetFromJsonAsync>($"/api/deliverynote/by-quote/{quoteId}") ?? Enumerable.Empty(); + } + catch + { + return Enumerable.Empty(); + } + } + } +} \ No newline at end of file diff --git a/phronCare.UIBlazor/Services/Sales/DeliveryNotes/IDeliveryNoteService.cs b/phronCare.UIBlazor/Services/Sales/DeliveryNotes/IDeliveryNoteService.cs new file mode 100644 index 0000000..fc0e75e --- /dev/null +++ b/phronCare.UIBlazor/Services/Sales/DeliveryNotes/IDeliveryNoteService.cs @@ -0,0 +1,11 @@ +using Domain.Dtos.Sales; + +namespace phronCare.UIBlazor.Services.Sales.DeliveryNotes +{ + public interface IDeliveryNoteService + { + Task GetByIdAsync(int id); + Task GetByDeliveryNoteNumberAsync(string deliveryNoteNumber); + Task> GetByQuoteIdAsync(int quoteId); + } +}