@page "/weather"

@using TestRibbon.Services
@rendermode InteractiveServer
@inject WeatherForecastService ForecastService

<PageTitle>Weather</PageTitle>
<h1>Weather</h1>

@if (forecasts == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <DxGrid Data="@forecasts">
        <Columns>
            <DxGridDataColumn Caption="Date" FieldName="Date" />
            <DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
            <DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" />
            <DxGridDataColumn Caption="Summary" FieldName="Summary" />
        </Columns>
    </DxGrid>
}

@code {
    private WeatherForecast[]? forecasts;

    protected override async Task OnInitializedAsync()
    {
        forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
    }
}