DPS907 WSA500 Assignment 5

Add link relations and documentation to a web service.

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

 

Due date

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

Grade value: 4% of your final course grade

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

 

Objective(s)

Enable a hypermedia-driven web service to deliver responses that get closer to implementing REST architectural principles.

 

Introduction to the problem to be solved

Returning to the Chinook sample database, we need a web service that delivers hypermedia-aware responses.

For this assignment, we will work with a few entities, and will deliver selected properties from associated entities (but will not be delivering full/complete objects or collections).

 

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:

  • Deliver “Customer” data, with link relations etc.
  • Modify “Customer” data, including add-new, edit-existing, and a command to set/configure the employee support representative
  • Deliver “Invoice” data, with link relations etc.
  • Fully-implemented documentation components (code comments, XML code comments for the help page, entry URI, and “add new” template info

 

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 Assignment5. It must use the “Web service project v1” 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, add the infrastructure components that are needed, including:

  • HTTP OPTIONS handler (and initialization of it)
  • Link enabling classes
  • Enable and configure the Web API help page
  • Root controller (and its activation in the WebApiConfig class)

 

After configuring the app’s structure, 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, Customer entity
  • Get one use case, Customer entity
  • Add new use case, Customer entity
  • Edit existing use case, Customer entity (address fields only)
  • Change state, a command, to set/configure a customer’s support representative (i.e. an employee)
  • Get all use case, Invoice entity

All use cases will deliver responses that include hypermedia (link relations etc.). Therefore, you must write additional link-aware resource model classes for the Customer and Invoice 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.

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 Customer

This should deliver Customer data, and the name of the associated support representative (employee), as simple composed properties, that use the AutoMapper flattening feature.

The response must include link relations. You will have to add link-aware resource model classes.

And, as a “get all”, it should now deliver a template that tells the user/requestor about the data needed to create a new Customer object.

 

Info about the get one use case for Customer

Similar to above, this should deliver Customer data, and support rep name data. With link relations.

 

Info about the add new use case for Customer

Similar to above, this should deliver Customer data, and support rep name data. With link relations.

 

Info about the edit existing use case for Customer

Write a resource model class that will enable the editing of the address-related fields in the Customer entity (address, city, etc.).

Similar to above, the result of the edit task should deliver Customer data, and support rep name data. With link relations.

 

Info about the change state use case (set support rep) for Customer

As a command, this will not return data in the entity body of the response. However, you should call out the existence of the use case in the root controller response.

 

Info about the get all use case for Invoice

This should deliver Invoice data, and the name of the associated customer, as simple composed properties, that use the AutoMapper flattening feature.

With link relations. And, a template that tells the user/requestor about the data needed to create a new Invoice object.

 

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.

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Advertisements
%d bloggers like this: