Modifying the TwitterController class

Now we come to the part where we allow the user to send a tweet.

Open up the TwitterController class and add two actions called ComposeTweet and PublishTweet. The TwitterController class is really simple. It just contains the following code:

public class TwitterController : Controller 
{         
    public IActionResult ComposeTweet() 
    {             
        return View(); 
    } 
         
    public IActionResult PublishTweet(string tweetText) 
    { 
        var firstTweet = Tweet.PublishTweet(tweetText); 
             
        return RedirectToAction("GetHomeTimeline", "Home");  
    } 
} 

The ComposeTweet action simply returns the user to a view where they can compose a tweet. You will remember that we created the ComposeTweet view earlier. The PublishTweet action is just as simple. It takes the ...

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.