Adding models to an ASP.NET application

We configured our application to use MVC services and added the Web API controller. Now, let's add the models needed for our My Todo application. Follow these steps to add a model named Todo:

  1. Right-click on the My Todo project, navigate to Add | New Folder, and name the folder Models:
Add a new folder for Models under the My Todo project
  1. Now, right-click on the Models folder that we just created and go to Add | Class....:
Add a class for the Todo object under the Models folder
  1. Name the class Todo and add the following code snippet to it:
   namespace My_Todo.Models
{
public class Todo
{
public int Id { get; set;
}
public string Title { get; set;
}
public bool Completed { get; set;
}
}
}

Todo is a C# POCO class that represents a Todo item. It has properties such as an Id that holds the primary key value of the Todo item, the Title property that holds the title of the Todo item, and the Completed property that holds the Boolean flag to indicate whether the item is completed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset