All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 8m30s
closes #25
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
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>();
|
|
}
|
|
}
|
|
}
|
|
} |