4.2: NoteListItem Model
Last updated
Last updated
In this module we'll make our first model in our models assembly.
We'll be using models throughout our application for scaffolding code, creating objects properly at the right time and in the right way, and matching objects that are passed in from the view to properly reflect what they should be shaped like in the database.
NoteListItem
ModelThe first model we will create will handle the task of collecting property data for a list of notes. When a user enters information, we will want them to enter specific data. When we show information, we will want to show specific data in specific views.
In the Solution Explorer, right click on ElevenNote.Models
Select Add -> Class and name it NoteListItem.cs
Make the class public immediately.
Add the following properties. (Note: for the ToString
method, you can type override
and then a space):
These are the properties that will show up in the view. You can add data annotations to these properties. For example, to change the display name of CreatedUtc
:
CTRL .
to bring in the using statement for the [Display]
annotation.
Move on to the next module and we'll build out the view using the model details.