weird error

master
Lilian BRETON 2 years ago
parent f0d89e4874
commit 8e96c6addd

@ -20,4 +20,3 @@
<InventoryItem Index="16" />
<InventoryItem Index="17" />
</div>

@ -11,11 +11,6 @@
</div>
<div id="ItemList">
<div>
<h3>List of Items</h3>
@*SearchBar*@
</div>
<div id="ItemList" class="align-end">
<div>
@ -36,14 +31,16 @@
<DataGridColumn TItem="Item" Field=""/>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" Caption="Display name" />
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="Image">
@if (!string.IsNullOrWhiteSpace(context.ImageBase64))
{
<img src="data:image/png;base64, @(context.ImageBase64)" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="min-width: 50px; max-width: 150px" />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="max-width: 150px"/>
}
<DisplayTemplate>
@if (!string.IsNullOrWhiteSpace(context.ImageBase64))
{
<img src="data:image/png;base64, @(context.ImageBase64)" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="min-width: 50px; max-width: 150px" />
}
else
{
<img src="images/default.png" class="img-thumbnail" title="@context.DisplayName" alt="@context.DisplayName" style="max-width: 150px"/>
}
</DisplayTemplate>
</DataGridColumn>
</DataGrid>
</div>

@ -6,11 +6,12 @@ using static System.Net.WebRequestMethods;
namespace myBlazorApp.Services
{
public class DataApiService : IDataService
{
public class DataApiService : IDataService
{
private readonly HttpClient _http;
public DataApiService(HttpClient http)
public DataApiService(
HttpClient http)
{
_http = http;
}
@ -21,22 +22,22 @@ namespace myBlazorApp.Services
var item = ItemFactory.Create(model);
// Save the data
await _http.PostAsJsonAsync("https://localhost:8635/api/Crafting/", item);
await _http.PostAsJsonAsync("https://localhost:7234/api/Crafting/", item);
}
public async Task<int> Count()
{
return await _http.GetFromJsonAsync<int>("https://localhost:8635/api/Crafting/count");
return await _http.GetFromJsonAsync<int>("https://localhost:7234/api/Crafting/count");
}
public async Task<List<Item>> List(int currentPage, int pageSize)
{
return await _http.GetFromJsonAsync<List<Item>>($"https://localhost:8635/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
return await _http.GetFromJsonAsync<List<Item>>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
}
public async Task<Item> GetById(int id)
{
return await _http.GetFromJsonAsync<Item>($"https://localhost:8635/api/Crafting/{id}");
return await _http.GetFromJsonAsync<Item>($"https://localhost:7234/api/Crafting/{id}");
}
public async Task Update(int id, ItemModel model)
@ -44,17 +45,17 @@ namespace myBlazorApp.Services
// Get the item
var item = ItemFactory.Create(model);
await _http.PutAsJsonAsync($"https://localhost:8635/api/Crafting/{id}", item);
await _http.PutAsJsonAsync($"https://localhost:7234/api/Crafting/{id}", item);
}
public async Task Delete(int id)
{
await _http.DeleteAsync($"https://localhost:8635/api/Crafting/{id}");
await _http.DeleteAsync($"https://localhost:7234/api/Crafting/{id}");
}
public async Task<List<CraftingRecipe>> GetRecipes()
{
return await _http.GetFromJsonAsync<List<CraftingRecipe>>("https://localhost:8635/api/Crafting/recipe");
return await _http.GetFromJsonAsync<List<CraftingRecipe>>("https://localhost:7234/api/Crafting/recipe");
}
}
}

Loading…
Cancel
Save