2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: Controller methods and views
2016-10-29 01:35:15 +08:00
author: rick-anderson
2017-03-04 05:35:47 +08:00
description: Working with controller methods, views and DataAnnotations
2016-11-18 04:13:02 +08:00
keywords: ASP.NET Core,
2016-10-29 01:35:15 +08:00
ms.author: riande
manager: wpickett
2017-03-04 05:35:47 +08:00
ms.date: 03/07/2017
2017-06-01 05:55:29 +08:00
ms.topic: get-started-article
2016-10-29 01:35:15 +08:00
ms.assetid: c7313211-b271-4adf-bab8-8e72603cc0ce
2016-11-17 08:24:57 +08:00
ms.technology: aspnet
2017-03-03 08:50:36 +08:00
ms.prod: asp.net-core
2016-10-29 01:35:15 +08:00
uid: tutorials/first-mvc-app/controller-methods-views
---
2017-03-04 05:35:47 +08:00
2016-10-29 01:35:15 +08:00
# Controller methods and views
2016-12-17 14:54:05 +08:00
By [Rick Anderson ](https://twitter.com/RickAndMSFT )
2016-10-29 01:35:15 +08:00
We have a good start to the movie app, but the presentation is not ideal. We don't want to see the time (12:00:00 AM in the image below) and **ReleaseDate** should be two words.
2016-12-23 02:03:29 +08:00
![Index view: Release Date is one word (no space) and every movie release date shows a time of 12 AM ](working-with-sql/_static/m55.png )
2016-10-29 01:35:15 +08:00
Open the *Models/Movie.cs* file and add the highlighted lines shown below:
2017-04-09 09:51:01 +08:00
[!code-csharp[Main ](start-mvc/sample/MvcMovie/Models/MovieDateWithExtraUsings.cs?name=snippet_1&highlight=13-14 )]
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
Right click on a red squiggly line ** > Quick Actions and Refactorings**.
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
![Contextual menu shows **> Quick Actions and Refactorings**. ](controller-methods-views/_static/qa.png )
2016-12-17 11:05:01 +08:00
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
Tap `using System.ComponentModel.DataAnnotations;`
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
![using System.ComponentModel.DataAnnotations at top of list ](controller-methods-views/_static/da.png )
2016-10-29 01:35:15 +08:00
2016-12-17 11:05:01 +08:00
Visual studio adds `using System.ComponentModel.DataAnnotations;` .
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
Let's remove the `using` statements that are not needed. They show up by default in a light grey font. Right click anywhere in the *Movie.cs* file ** > Remove and Sort Usings**.
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
![Remove and Sort Usings ](controller-methods-views/_static/rm.png )
2016-12-17 11:05:01 +08:00
2016-10-29 01:35:15 +08:00
The updated code:
2017-03-04 05:35:47 +08:00
[!code-csharp[Main ](./start-mvc/sample/MvcMovie/Models/MovieDate.cs?name=snippet_1 )]
2016-10-29 01:35:15 +08:00
2017-04-09 09:51:01 +08:00
<!-- include start -->
2016-10-29 01:35:15 +08:00
2017-04-09 09:51:01 +08:00
[!INCLUDE[adding-model ](../../includes/mvc-intro/controller-methods-views.md )]
2016-10-29 01:35:15 +08:00
2016-11-10 13:17:21 +08:00
>[!div class="step-by-step"]
[Previous ](working-with-sql.md )
[Next ](search.md )