Project Paper

Project Part A
Objective
Over two days you will be working on Project Part A individually or together in group.
Assignment A1 has 3 parts to be completed and the Assignment A2 has 4 parts. You may
decide to do part of the work in the group and complete it individually. In any case the
project part is individual and should be send in individually. Pls send in your solutions,
compressed into zip format, so I can easily un-compress them and open in Visual Studio
2019 and run the code. Pls see deadline in “Kursplaneringen”.
The objective is by using the Model (and Service) separation of MVVM create a service that
communicates with a web api service using Json. You should use as much as possible of what
you learned during the C# AOOP theory, in particular Tasks, async/await, events, Lambda
Expression, Linq, Collections, Serialization. But also, of course basics like classes, tuples,
enumerations.
For Assignment A1, I have provided hints and a simple template in code for you to not get
stuck on trivial matters. For Assignment A2 is of somewhat similar nature but, only some
basic data types are provided, and only one hint.
Grade criterias for this part of the project:
Godkänt (G) : Completion of all assignments part of “Project Part A: Assignment A1”, using
the C# methodology you learned in C# AOOP theory part of the course.
Väl godkänt (VG): Completion of all assignments as part of “Project Part A: Assignment A2”,
using the C# methodology you learned in C# AOOP theory part of the course.
The services are Weather webapi service (https://openweathermap.org/) and News webapi
service (https://newsapi.org/). You should have already registered yourself to the two webapi services following my document “Setting up a .NET cross-platform development
environment in Windows 10”.
Note: For the weather web-api on the free plan you have 60 free web-api calls per minute,
and for the news web-api you have 100 calls per day. For the news web-api, I provide in the
template directory sample data and code that you can use to test and debug before calling
for live data.
Project Part A
© Seido AB Martin Lenart, 2021-11-10 Page 2
Project Part A: Assignment A1
Use the Console Solution Project Part A template.
Assignment A1.1
In class OpenWeatherService you should create an async method, GetForecastAsync(..) that
implements following functionality:
– Requests weather data from https://api.openweathermap.org using your apiKey.
– Read the Json response string async.
– Convert the Json string into the class WeatherApiData.
– Create a response object of type Forecast from WeatherApiData using Linq.
– return the Forecast object to the caller.
The caller, Program.Main should implement following functionality:
– Call the GetForecastAsync(..) using the asynchronous design methodology.
– Wait for the task to be completed.
– Group the Forecast according to Dates using Linq.
– Write the weather data to the console.
Hint:
The timestamp from the weather service is in Unit time stamp format. In one of my
examples you see how to convert. Linq operator Select is a perfect tool together with
Lambda Expression to convert one collection to another. Linq operator GroupBy is perfect
for grouping. Remember how to Wait for all tasks to complete. ReadFromJsonAsync<>()
extension is an excellent way to get the Json response string.
Project Part A
© Seido AB Martin Lenart, 2021-11-10 Page 3
An output from Main on the Console could be something like