Files
FA_WEB/OrdersManagement/Services/ProductService.cs
Piotr Kus 0eaf941021 * Added maintaining Products
* Extended DataModels
* Extended API
2025-03-29 21:37:36 +01:00

25 lines
829 B
C#

using FaKrosnoEfDataModel.Dtos;
namespace OrdersManagement.Services;
public class ProductService(IHttpClientFactory httpClientFactory, CustomAuthenticationStateProvider authenticationStateProvider)
: ServiceBase<ProductDto>(httpClientFactory, authenticationStateProvider)
{
public async Task<IEnumerable<ProductDto>?> GetProductsByIndexAsync(string indexName)
{
try
{
return await GetListAsync($"api/Product/by-index?indexName={indexName}");
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Błąd HTTP w GetProductsByIndexAsync: {ex.Message}");
return null;
}
}
public async Task<HttpResponseMessage> UpdateProductAsync(ProductDto product)
{
return await PutAsJsonAsync("api/Product", product);
}
}