Controller methods and views in an ASP.NET Core MVC app
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 following image) and ReleaseDate should be two words.
Open the Models/Movie.cs file and add the highlighted lines shown below:
[!code-csharpMain]
1: //#define AddDate
2: #if AddDate
3: #region snippet_1
4: using System;
5: using System.ComponentModel.DataAnnotations;
6:
7: namespace MvcMovie.Models
8: {
9: public class Movie
10: {
11: public int ID { get; set; }
12: public string Title { get; set; }
13:
14: [Display(Name = "Release Date")]
15: [DataType(DataType.Date)]
16: public DateTime ReleaseDate { get; set; }
17: public string Genre { get; set; }
18: public decimal Price { get; set; }
19: }
20: }
21: #endregion
22: #endif
Build and run the app.
[!INCLUDEadding-model]
Comments (
)
Link to this page:
//www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/tutorials/first-mvc-app-mac/controller-methods-views.htm
|