Repository navigation
6. Tutorial Lab
After downloading the provided starter project and running a build to make sure there are not any errors running the project, open the Package Manager Console. You can do this by navigating to Tools > NuGet Package Manager > Package Manager Console. Insert the following command into the console to install Open-Meteo Weather API:
dotnet add package openmeteo_sdk
The first step is to create a model that will hold the weather information returned by the Open-Meteo API.
A model is a C# class used to represent and organize data in your application. In this project, the WeatherData model will represent the information we receive from Open-Meteo, such as the latitude, longitude, temperature, humidity, and wind speed.
Step 1 — Create the Models Folder
In Solution Explorer, locate the WeatherTraining project.
- Right-click 'WeatherTraining'.
- Select Add then click 'New Folder'.
- Name the folder 'Models'
Your project should look similar to: [SCREENSHOT]
using System.Text.Json.Serialization;
namespace WeatherTraining.Models;
public class WeatherData
{
[JsonPropertyName("latitude")]
public double Latitude { get; set; }
[JsonPropertyName("longitude")]
public double Longitude { get; set; }
[JsonPropertyName("current")]
public CurrentWeather Current { get; set; } = new();
}
public class CurrentWeather
{
[JsonPropertyName("temperature_2m")]
public double Temperature { get; set; }
[JsonPropertyName("relative_humidity_2m")]
public double Humidity { get; set; }
[JsonPropertyName("wind_speed_10m")]
public double WindSpeed { get; set; }
}Here is how the code should look in Visual Studio Code:

[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]
[Explanation]
[Code]
[SCREENSHOT]