Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

GetFromJsonAsync by custom Id

$
0
0

I'm using Blazor WebAssembly and I want to do a GetFromJsonAsync from a URI based on the ID entered by the client.Practically, the client will enter an ID in the label, and depending on it, he will receive a list. That URI is formed according to the entered ID.

@page "/dentistappointments"@using WhiteDentalClinic.Application.Models.AppointmentModel;@using WhiteDentalClinic.Application.Models;@inject HttpClient Http`<h3>DentistAppointments</h3><EditForm class="d-flex flex-column align-items-center"><InputText @bind-Value="@dentistId"/><button type="submit" class="btn btn-primary">See appointments:</button></EditForm>@if (appByDentist == null){<p><em>No dentist appointments found.</em></p>}else{<table class="table"><thead><tr><th>Id</th><th>Date time</th></tr></thead><tbody>            @foreach (var app in appByDentist)            {<tr><td>@app.Id</td><td>@app.dateTime</td></tr>            }</tbody></table>}@code {    private List<AppointmentResponse> appByDentist = new List<AppointmentResponse>();    private var dentistId = "87459b92-79d6-44b3-850e-727d90519ba3";    protected override async Task OnInitializedAsync()    {        var temp = await Http.GetFromJsonAsync<ApiResult<IEnumerable<AppointmentResponse>>>($"/api/Appointment/allapp/dentist{dentistRequestId}", dentistId);        appByDentist = temp.Result.ToList();    }

Viewing all articles
Browse latest Browse all 4839

Trending Articles