Add project files.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using ConstructorAppUI.Dtos.ProjectDtos;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ConstructorAppUI.ViewComponents.HomeComponents
|
||||
{
|
||||
public class _HomeProjectPartialComponent : ViewComponent
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly string? _apiBaseUrl;
|
||||
|
||||
public _HomeProjectPartialComponent(IHttpClientFactory httpClientFactory, IConfiguration configuration)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_apiBaseUrl = configuration["ApiSettings:BaseUrl"];
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync()
|
||||
{
|
||||
var client = _httpClientFactory.CreateClient();
|
||||
var responseMessage = await client.GetAsync($"{_apiBaseUrl}/api/Project");
|
||||
var jsonData = await responseMessage.Content.ReadAsStringAsync();
|
||||
var values = JsonConvert.DeserializeObject<List<ResultProjectDto>>(jsonData);
|
||||
return View(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user