DPS907 WSA500 Assignment 6 – Fall 2016

More practice with hypermedia representations.

Read/skim all of this document before you begin work.


Due date

Wednesday, October 19, 2016, at 11:00pm ET

Grade value: 5% of your final course grade

If you wish to submit the assignment before the due date and time, you can do that.



Experiment with the new topics that were introduced this week. Enable a hypermedia-driven web service to deliver responses that get closer to implementing REST architectural principles.


As a special situation, there is an alternative Assignment 6 that you can attempt, instead of the one described below. Read the specifications for more information.


Introduction to the problem to be solved

Working with the Chinook sample database, we need a web service that delivers hypermedia-aware responses. We will attempt to implement the REST architectural principles to make your professor and Roy Fielding happy.

For this assignment, we will work with a few entities, and will deliver data (i.e. individual property values) and nested objects/collections from associated entities, in a programmer-friendly manner.


Specifications overview and work plan

The following specifications apply to all of your assignments:

  • Follows best practices
  • Implements the recommended system design guidance
  • Customized appearance on the landing web page
  • Uses Entity Framework and Code First technology
  • Includes a Fiddler log file that shows complete coverage of tests

For this assignment, here is what we’re looking for:

  • All responses will be hypermedia representations
  • Deliver “Artist” data, with and without an “Albums” collection
  • Deliver “Album” data, with and without “Artist” data and a “Tracks” collection
  • Support “add photo” to an Album, and content negotiation to deliver it to a user/requestor
  • Deliver “Track” data, with “Album”, “Artist”, and “MediaType” data


During the class/session, your professor will help you get started and make progress on this assignment.

Every week, in the computer-lab class/session, your teacher will record a grade when you complete a specific small portion of the assignment. We call this “in-class grading“.

The in-class grading will be announced in-class by your professor.


Getting started

Create a new web service, named Assignment6. It must use the new “Web service project v2” project template.

Remember to customize the home controller’s index view with your personal information, and the _Layout.cshtml view template with the application name.

Build/compile, and run (without debugging), to ensure that the app’s home > index view loads in a browser.


Doing the work

Before writing code for the use cases, we must make some changes to some of the entities, which will change the database.

We will use a feature of the Entity Framework, “Code First Migrations”.


If you need to refresh your memory about Code First Migrations, please read the section titled…
New topic – making changes to the design of the persistent store

…in the professor’s web apps course notes from March 9 2016.


Let’s begin by ensuring that the project will build/compile without errors.

Then, open the package manager console, and configure the initial state of the migrations task. Run these commands, in the sequence shown, and make sure each command completes without errors:


add-migration Initial -ignorechanges



Now, run a quick test: Create a resource model class for (for example) EmployeeBase. Add a simple method in the Manager to fetch all employees. Then, write a method in a controller that calls the manager method and returns the results. Next, run the app (browser, then Fiddler) to ensure that it delivers data. Again, make sure that it does this successfully, without errors.

Next, edit some of the design model classes to add photo and sound clip media properties, as follows:


  • Add photo properties (which can hold a photo of the artist)


  • Add photo properties (which can hold an album art / cover image)


  • Add sound clip properties (which can hold a sample / sound clip)


Build/compile (to make sure that there are no errors). Then, return to the package manager console, to add a new migration task that will recognize the addition of the new photo and sound clip media properties. Run these commands in sequence.

add-migration AddMediaProperties



Finally, build/compile, and test/run the “get employees” task above, to ensure that it works correctly.

Now, you can circle back and do the programming work.

As a reminder, your professor believes that the best way to work through any assignment is to do it incrementally. Get one thing working correctly, before moving on to the next. Test each part.

Therefore, you will probably be cycling through the following programming tasks, for each use case. (You first saw this list in the Assignment 2 specifications.)

  1. Write the resource model class(es) that support the use case
  2. Add one or more AutoMapper mappings for the class(es) that you just added
  3. Write the Manager class method that performs the data service operation
  4. Create a controller, if necessary
  5. Write the controller method that implements the use case
  6. Test, using Fiddler, debug and fix if necessary

Incrementally doing these tasks will ensure that you’re making progress. You will also notice that they’re repetitive. That’s good, because the process will become familiar and natural to you.

Here are the use cases, as suggested from the simple sentence above:

  • Get all use case, Artist entity, with Albums data
  • Get one use case, Artist entity, with nested Albums collection, with link relations
  • Get all use case, Album entity, with Artist name, and Tracks data
  • Get one use case, Album entity, with nested Tracks collection, with link relations;
    this should also support content negotiation, to return an album photo (i.e. the album art/cover)
  • Change state, a command, to set/configure a photo for an Album
  • Get all use case, Track entity, with Album title, and Artist name

All use cases will deliver responses that include hypermedia (link relations etc.). Therefore, you must write additional link-aware resource model classes for the Artist and Album entities. And, where necessary, AutoMapper “create map” statements.

Remember to add appropriate code comments to your controllers and manager.

Also, remember to add XML code comments on controller methods, to enable the Web API Help Page feature.

New task: Add XML code comments on resource model properties. Doing this will enable the “Description” column of a Web API Help Page to show some useful information.

Make sure that you study the code examples, from this course and from the web apps course, to learn and implement the best practice way of designing and coding each programming task listed above. Also, use the comments and feedback that appears on your previous assignment checklists.


Info about the get all use case for Artist

This should deliver Artist data.

An Artist object has an Albums collection (an ICollection<T>; look in the design model class). An ICollection<T> has a “Count” property. Interesting.

Therefore, add a composed property name to the appropriate/relevant resource model class, and make sure you include the Albums property when the manager method fetches all the artists.


Info about the get one use case for Artist

This should deliver data for one Artist. It must also deliver the Artist’s Albums as a nested collection. Add a link relation (self) to each item in the Albums collection.


Info about the get all use case for Album

This should deliver Album data. It must also deliver the following:

  1. The artist name, as a composed property (using AutoMapper flattening etc.)
  2. Similar to “get all artists” above, it should also deliver a tracks count value.


Info about the get one use case for Album

Similar to “get one album” above, this should deliver data for one Album. It must also deliver the following:

  1. The artist name, as a composed property
  2. The Album’s Tracks, as a nested collection, with link relations.

In addition, ensure that content negotiation works. Enable the user to enter an accept header for an image in the request, and deliver the album photo (album art/cover).


Info about the change state use case (set photo) for Album

As a command, enable a user/requestor to set/configure/upload an album cover.

Where can you easily get photos/images of the albums? Here’s a suggestion, if you don’t know:

  1. Use a search engine, such as images.google.com
  2. Search for the album, using a search term like album name album art
  3. To limit the size to a popular 300px-square size, choose Search tools > Size > Exactly… and specify 300 for width and height


Info about the get all use case for Track

This should deliver Track data. With the album title, the artist name, and the media type name.


Configure the root (entry point) controller

As a final task, after configuring all the functionality above, go to the root (entry point) controller, and configure the link relations that you want to deliver to requestors.


Testing your work

Use Fiddler.

Ensure that it has been configured to save the message bodies in requests and responses. (A default installation does not do this.) If you are using a College computer, this should have been configured, but check anyway. If you installed Fiddler on your own computer, follow the instructions on this document.

Test all scenarios (use cases). Make sure that you test error or error-like scenarios.


Saving – “exporting” – your tests

On the left side list of requests, you can delete items that you do not want included in the export.

When you’re ready to save, choose File > Export Sessions > All Sessions…

The export format will be “HTTPArchive v1.2”. Click the Next button to choose a save location (your project’s root, in the same folder level as the “packages” folder and specify a filename. Name the file by using the project name (e.g. “<whatever>.har”).

(You can test whether the export was successful. How? First, close then re-open Fiddler. Choose File > Import Sessions. Select “HTTPArchive” as the import format. Navigate to the folder that holds the “har” file, and select it. Finally, browse through the request-response sessions.)


Reminder about academic honesty

You must comply with the College’s academic honesty policy.

Although you may interact and collaborate with others, you must submit your own work.


Submitting your work

At this point in time, you should be familiar with the process:

  1. Copy your project
  2. Remove its packages, bin, and obj folders
  3. Zip and upload to the designated location on My.Seneca/Blackboard before the due date-and-time

If you need more details, look at the info in assignments 1 through 3.




























%d bloggers like this: