DPS907 WSA500 Assignment 3

Continue to work with associated data in a web service.

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

 

Due date

Wednesday, September 28, 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)

Create a web service that works with associated entities. Implement a specific set of use cases.

 

Introduction to the problem to be solved

We need a web service that will deliver data about the music business. Your app will enable users to request data about invoices, and detail for a specific invoice. The detail will be extensive, and will include data from many associated entities. It will also enable you to add and configure employees.

 

Specifications overview and work plan

Here’s a brief list of specifications that you must implement:

  • Follows best practices
  • Implements the recommended system design guidance
  • Customized appearance on the landing web page
  • Uses Entity Framework and Code First technology
  • Supports HTTP GET, for get all use cases, for Invoice and Employee entities
  • Supports HTTP GET, for the get one use case, for Invoice, with info from related objects
  • Supports HTTP GET, for the get one use case, for Employee, with info from related objects
  • Supports HTTP POST, for the add new use case, for Employee
  • Implements the command pattern, to enable the configuration of an employee’s manager
  • Includes a Fiddler log file that shows complete coverage of tests

 

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.

DPS907 students must add another command to enable the configuration of an employee’s direct-reports.

 

Getting started

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

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

 

Doing the work

After configuring and studying 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, from above:

  • Get all use cases, for Invoice and Employee entities
  • Get one use case, for Invoice, with info from related objects
  • Get one use case, for Employee, with info from related objects
  • Add new use case, for Employee
  • Change state, a command, to enable the configuration of an employee’s manager
  • (DPS907 students…) Change state, a command, to enable the configuration of an employee’s direct-reports

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 cases

A common practice for get all use cases is to return a collection of objects, without associated objects. That’s a good starting point. And, that’s what you can do when returning the Invoice collection, and the Employee collection.

However, when appropriate, some associated data can be returned. That data can be individual/selected properties (mapped using the composite pattern/feature of AutoMapper), or less frequently, a nested object or collection. Also, you could create new calculated/computed properties, if that makes sense.

For example, a collection of invoice data is pretty boring. It could be more meaningful to the requestor if, for example, the customer name was included, instead of just the customer identifier. And maybe the invoice total/amount could be useful.

Hint / tip: There are MANY invoices. About 412. That’s a big blob of data.

In your “get all invoices” manager method, you can limit the number of invoices that you bring back, FYI.

If you want to do this, add the Take() extension method to the end of the query statement. For example, Take(100) will return only 100 items. Cool.

 

Info about the get one use case, for Invoice

A common practice for get one use cases is to return an object that has associated data. The situation (use case, needs of the requestor, programmer preference, etc.) will determine how much data.

For this use case, for invoice, plan on returning the following associated data:

  • Customer name
  • Employee (sales rep) name
  • The collection of invoice line items
  • Each item in the collection will include…
    • Track name
    • Composer
    • Media type name
    • Album title
    • Artist name

Remember the design principle that we discussed in class recently, when working with multiple associations:

When the associated objects are sequentially connected together, the string in the Include() method can be a dot-separated string of the class names, starting with the class name of the nearest connected object.

When the associated objects are not sequentially connected together, add an Include() statement for each associated class name.

If you are looking for a visualization, here’s a screen shot of a web app that includes the data. Click to open it full-size in a new tab/window.

invoice-detail

 

Info about the get one use case, for Employee

As noted above, a common practice for get one use cases is to return an object that has associated data.

For this use case, for employee, plan on returning the following associated data:

  • The collection of direct-reports (the awkwardly-named Employee1 navigation property; the other employees that this employee supervises or manages)
  • The employee’s supervisor/manager (the awkwardly-named Employee2 navigation property)

 

Info about the add new use case, for Employee

When adding a new employee object, the employee’s supervisor info (an identifier) can be provided in the data package, or not.

 

Info about the change state use case that configures an employee’s manager

Straightforward, uncomplicated command. Notice that the request’s data package must include both the identifier of the employee, and the identifier of the employee’s supervisor/manager.

Remember, in the manager method, you must validate the identifiers.

 

DPS907 students:
Info about the change state use case that configures an employee’s direct-reports

The request’s data package will send the identifier of the employee (who is a supervisor/manager), and a collection of identifiers for the other employees that report to the manager/supervisor.

You must send a collection of employee identifiers.
Question: What does an integer collection look like in JSON?

Remember, in the manager method, you must validate the identifiers.

 

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).

 

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

Here’s how to submit your work, before the due date and time:

1. Locate the folder that holds your project files. (It has about four items, a Visual Studio “solution” file, a folder that has your project’s source code, a “packages” folder, and a Fiddler archive “har” file.)

2. Make a copy of the folder. You will be uploading the copy.

3. Remove the “packages” folder from the copied folder; also, remove the “bin” and “obj” folders, which are in the project’s source code folder hierarchy.

4. Compress/zip the copied folder. The zip file SHOULD be about 1MB to 2MB in size. If it isn’t, you haven’t followed the instructions properly.

5. Login to My.Seneca. Open the Web Services Architecture course area. Click the “Assignments” link on the left-side navigator. Follow the link for this assignment. Submit/upload your zip file. The page will accept three submissions, so if you upload, then decide to fix something and upload again, you can do so.

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Advertisements
%d bloggers like this: