Creating the TwitterViewModel class

The TwitterViewModel class is just a really simple class that takes a collection of TweetItem as a property called HomeTimelineTweets.

Let's start by adding a model to our project:

  1. Right-click your Models folder and add a class called TwitterViewModel to the folder. Then, add the following code to that class:
public class TwitterViewModel 
{ 
    public List<TweetItem> HomeTimelineTweets { get; set; } 
}
  1. Also, add the using statement using CoreTwitter.Classes; to the class.

This is all that is needed. As you expand the TweetItem class later on (if you decide to add functionality to this app), this model will be responsible for passing that information through to our view for use in the Razor.

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.