feat(sales): incorporar servicio UI para consumo de Delivery Note #26

Merged
leandro merged 1 commits from feature/leandro/25-deliverynote-ui-service into master 2026-03-19 21:24:10 +00:00
3 changed files with 64 additions and 0 deletions
Showing only changes of commit e02d9b1ac0 - Show all commits

View File

@ -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<IStockScanService, StockScanService>();
builder.Services.AddScoped<IExpeditionService, ExpeditionService>();
builder.Services.AddScoped<IQuoteService,QuoteService>();
builder.Services.AddScoped<IDeliveryNoteService, DeliveryNoteService>();
builder.Services.AddScoped<ExchangeRateService>();
builder.Services.AddScoped<TicketsService>();

View File

@ -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<DeliveryNoteDto?> GetByIdAsync(int id)
{
try
{
return await _http.GetFromJsonAsync<DeliveryNoteDto>($"/api/deliverynote/{id}");
}
catch
{
return null;
}
}
public async Task<DeliveryNoteDto?> GetByDeliveryNoteNumberAsync(string deliveryNoteNumber)
{
try
{
return await _http.GetFromJsonAsync<DeliveryNoteDto>($"/api/deliverynote/number/{Uri.EscapeDataString(deliveryNoteNumber)}");
}
catch
{
return null;
}
}
public async Task<IEnumerable<DeliveryNoteDto>> GetByQuoteIdAsync(int quoteId)
{
try
{
return await _http.GetFromJsonAsync<IEnumerable<DeliveryNoteDto>>($"/api/deliverynote/by-quote/{quoteId}") ?? Enumerable.Empty<DeliveryNoteDto>();
}
catch
{
return Enumerable.Empty<DeliveryNoteDto>();
}
}
}
}

View File

@ -0,0 +1,11 @@
using Domain.Dtos.Sales;
namespace phronCare.UIBlazor.Services.Sales.DeliveryNotes
{
public interface IDeliveryNoteService
{
Task<DeliveryNoteDto?> GetByIdAsync(int id);
Task<DeliveryNoteDto?> GetByDeliveryNoteNumberAsync(string deliveryNoteNumber);
Task<IEnumerable<DeliveryNoteDto>> GetByQuoteIdAsync(int quoteId);
}
}