@using Packt.Shared @model HomeIndexViewModel @{ ViewData["Title"] = "Home Page"; string currentItem = ""; WeatherForecast[]? weather = ViewData["weather"] as WeatherForecast[]; }

Welcome

@DateTime.Now.ToLongTimeString()

Five-Day Weather Forecast

@if ((weather is null) || (!weather.Any())) {

No weather forecasts found.

} else { @foreach (WeatherForecast w in weather) { }
@w.Date.ToString("ddd d MMM") will be @w.Summary
}

Binding

@if (Model is not null) { }

Northwind

We have had @Model?.VisitorCount visitors this month.

Query customers from a service

Query products by price

@if (Model is not null) {

Products

}