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); + } +}