Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
So far in this course, we've collaborated on building out the "entries" endpoint, but now it's your turn to take what you've learned and build out the "activities" and "intensities" endpoints.
Follow Along
To follow along committing your changes to this course, you'll need to fork the aspnet-fitness-frog-spa repo. Then you can clone, commit, and push your changes to your fork like this:
git clone <your-fork>
cd aspnet-fitness-frog-spa
git checkout tags/v3.5 -b exercise-adding-the-activities-and-intensities-api-endpoints
Exercise: Adding the Activities and Intensities API Endpoints
Here are the requirements for the exercise:
Activities API Endpoint
- Add an API controller named
ActivitiesController
- Add a controller action method to handle GET requests
- The method should return a collection of resources representing the available activities
- Each returned activity resource should have an
id
andname
property - Use the
ActivitiesRepository.GetList
method to get a list of the available activities
Intensities API Endpoint
- Add an API controller named
IntensitiesController
- Add a controller action method to handle GET requests
- The method should return a collection of resources representing the available intensities
- Each returned intensity resource should have an
id
andname
property - Use the .NET Framework
Enum.GetValues
static method to enumerate the values of theEntry.IntensityLevel
enumeration
Intensities Endpoint Hint
Here are a couple of hints in case you get stuck on how to get a list of intensities from the Entry.IntensityLevel
enumeration.
Hint #1: Enum.GetValues Method
You can use the .NET Framework Enum.GetValues
static method to enumerate the values of an enum. You can find the documentation for that method at https://msdn.microsoft.com/en-us/library/system.enum.getvalues(v=vs.110).aspx.
Hint #2: Code Snippet
If the first hint didn't help, here's a code snippet that you can use to get a list of the available intensities:
var results = Enum.GetValues(typeof(Entry.IntensityLevel))
.Cast<Entry.IntensityLevel>()
.Select(il => new { id = (int)il, name = il.ToString() })
.ToList();
Visual Studio Markdown Editor
To get a preview of markdown in Visual Studio (as you see in the video), you can install the following Visual Studio extension:
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up