From the course: Learning ASP.NET

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Courses API

Solution: Courses API

From the course: Learning ASP.NET

Start my 1-month free trial

Solution: Courses API

(upbeat music) - It's time to review the solution to our challenge. We need a new model class that represents a course. So let's go ahead and add it. It'll have an int ID property, and then a string for name, as well as description, and finally, a Boolean IsActive for whether or not it's an active course. Next, we have to add an API controller for courses and we'll go with this option, the Web API 2 empty controller and name it CourseController. For simplicity, we'll be hard coding a list of courses, so let's declare that at the top of the class. And we'll need to pull in the model's namespace. And this'll be set to a list of courses. I'll add two courses. The first one, having an ID of one, a name of computer science, and the description can be the fundamentals of computer science, and I'll also make it active. For the second course, I'll give it an ID of two. The name can be introduction to programming.…

Contents