-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
211 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Sample.Core.Models | ||
{ | ||
public class Bank | ||
{ | ||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
|
||
[JsonPropertyName("uid")] | ||
public Guid Identifier { get; set; } | ||
|
||
[JsonPropertyName("account_number")] | ||
public string AccountNumber { get; set; } | ||
|
||
[JsonPropertyName("iban")] | ||
public string IBAN { get; set; } | ||
|
||
[JsonPropertyName("bank_name")] | ||
public string BankName { get; set; } | ||
|
||
[JsonPropertyName("routing_number")] | ||
public string RoutingNumber { get; set; } | ||
|
||
[JsonPropertyName("swift_bic")] | ||
public string SwiftBIC { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@using Sample.Core.Services | ||
@using Sample.Core.Models | ||
|
||
@inject RandomDataClient RandomDataClient; | ||
|
||
<h3>Banks</h3> | ||
|
||
<DataGrid Data="Data" class="table table-hover" @ref="DataGrid" RowAttributes="RowAttributes"> | ||
<DataColumns> | ||
<DataColumn TItem="Bank" Property="p => p.Id" Width="70px" data-test="testing" CellAttributes="CellAttributes" /> | ||
<DataColumn TItem="Bank" Property="p => p.AccountNumber" Width="150px" Title="Account" SortIndex="0" /> | ||
<DataColumn TItem="Bank" Property="p => p.IBAN" Width="200px" /> | ||
<DataColumn TItem="Bank" Property="p => p.BankName" /> | ||
<DataColumn TItem="Bank" Property="p => p.RoutingNumber" Width="200px" /> | ||
<DataColumn TItem="Bank" Property="p => p.SwiftBIC" Width="200px" /> | ||
</DataColumns> | ||
<DataPagination Context="grid"> | ||
<DataPager PageSize="10" /> | ||
<DataSizer /> | ||
<div>@grid.Pager.StartItem - @grid.Pager.EndItem of @grid.Pager.Total</div> | ||
</DataPagination> | ||
</DataGrid> | ||
|
||
|
||
@code { | ||
public ICollection<Bank> Data { get; set; } = new List<Bank>(); | ||
|
||
private DataGrid<Bank> DataGrid { get; set; } | ||
|
||
protected async override Task OnInitializedAsync() | ||
{ | ||
var results = await RandomDataClient.GetBanks(); | ||
|
||
Data = results; | ||
|
||
// triger refresh | ||
StateHasChanged(); | ||
await DataGrid.RefreshAsync(true); | ||
} | ||
|
||
private Dictionary<string, object> CellAttributes(Bank bank) | ||
{ | ||
return new Dictionary<string, object> | ||
{ | ||
{ "data-key-" + bank.Id, "Test " + bank.BankName } | ||
}; | ||
} | ||
|
||
private Dictionary<string, object> RowAttributes(Bank bank) | ||
{ | ||
return new Dictionary<string, object> | ||
{ | ||
{ "data-row-" + bank.Id, "Test " + bank.BankName } | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ | |
|
||
<Virtual /> | ||
|
||
<div class="mb-5"></div> | ||
|
||
<Banks /> | ||
|
||
@code { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Sample.Core.Models; | ||
|
||
using System.Net.Http.Headers; | ||
using System.Net.Http.Json; | ||
using System.Net.Mime; | ||
|
||
namespace Sample.Core.Services | ||
{ | ||
public class RandomDataClient | ||
{ | ||
public HttpClient HttpClient { get; } | ||
|
||
public RandomDataClient(HttpClient httpClient) | ||
{ | ||
httpClient.BaseAddress = new Uri("https://random-data-api.com/"); | ||
|
||
var mimeTypeHeader = new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json); | ||
httpClient.DefaultRequestHeaders.Accept.Add(mimeTypeHeader); | ||
|
||
HttpClient = httpClient; | ||
} | ||
|
||
public async Task<List<Bank>> GetBanks(int size = 100) | ||
{ | ||
var url = $"/api/v2/banks"; | ||
|
||
if (size > 0) | ||
url += $"?size={size}"; | ||
|
||
return await HttpClient.GetFromJsonAsync<List<Bank>>(url); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.