DPS907 WSA500 Lab 2

Work with associations.

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

.

DPS907 WSA500 Lab 2 – Due Mon Sep 28

Due date: Monday, September 28, 2015, at 8:00am ET

Grade value: 5% of your final course grade (partially graded in-class on Mon Sep 21)

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

.

Objective(s)

Work with associations.

.

Introduction to the problem to be solved

We need a web service that will work with data in the music business.

The problem domain entities are Artists, Albums, and Songs. This assignment will focus on the Artist entity, and a future assignment will work with the others.

.

Specifications and work plan

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

  • Follows best practices
  • Implements the recommended system design guidance
  • Uses Entity Framework and Code First technology
  • Supports a number of data service operations on the Artist entity
  • Includes a Fiddler log file that shows complete coverage of tests

.

The in-class grading will look at the entities in your design model classes, and how they are surfaced in the app.

.

Getting started

Create a new project, named “Lab2”. It will use the “Web API” template. “Individual User Accounts” authentication. No hosting. No Web Forms or unit tests.

Reminders:

As you perform each step, test your work, to ensure that you’re making error-free progress:

  • Build/compile
  • Where appropriate, use Fiddler

This project will include the components needed to use a database, and Entity Framework Code First technology:

  • Its data context class is ApplicationDbContext, in the IdentityModels.cs source code file
  • You must add your own DbSet<TEntity> properties to this class

Update the project’s components:

  • If you are using Visual Studio 2013, open the Package Manager dialog. Highlight the left-side “Updates” item. On the center panel, “Update All”.
  • If you are using Visual Studio 2015, open the Package Manager Console. (If it’s not open, then use the TOOLS menu to locate and open it.) Run this command: update-package

The project will need AutoMapper.

.

Understanding and writing the design model classes

As noted above, you will write entity classes for Artist, Album, and Song. The following describes each entity. (Obviously, all will need an identifier.)

Artist properties

  • artist name
  • artist type (i.e. individual, duo, group)
  • birth or start date
  • genre
  • member of (artist object, self-referencing)
  • members (artist collection, self-referencing)
  • albums (collection)
  • songs (collection

Album properties

  • album name
  • release date
  • genre
  • MSRP
  • artist (reference, required)
  • songs (collection)

Song properties

  • song name
  • composer name(s) (as a simple string)
  • release date as single (can be null)
  • genre
  • artist (reference, required)
  • albums (collection)

.

The design model has some association constraints to reduce complexity:

  • Artist – one to many – Album (Album MUST be associated with an Artist)
  • Artist – one to many – Song (Song MUST be associated with an Artist)
  • Artist – self referencing one to many – Artist (this is how we can define a group, with members)
  • Artist – self referencing one to one – Artist (this is how we can identify an Artist’s group membership)
  • Album – many to many – Song (optional, both ends)

.

Reminder about the other infrastructure components

Each entity needs to be declared in the data context class. Also, please add the code that will remove the default “cascade delete” behaviour, as implemented in the AssociationsIntro code example.

A data service operations (manager) class is required.

For this assignment, resource models for the Artist entity must be defined. AutoMapper mappings must be created (in the WebApiApplication class, in its Application_Start event-handling method).

And obviously, a controller for the Artist entity must be written.

.

Web service functionality

As noted earlier, this assignment will focus on the Artist entity. Plan to support these use cases:

  • POST – Create new artist
  • PUT – Configure an artist to be a member of a group
  • PUT – Configure an artist with a new group member
  • GET – All artists
  • GET – All artists with group members
  • GET – One artist, showing group membership (if any)
  • DELETE – Delete an artist

.

Use attribute routing to handle requests that cannot be defined by the default format for a resource URI.

.

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 has already been configured. 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 don’t 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 as the “packages” and “lab2” folder) and specify a filename. Name the file by using the project name (e.g. “lab2.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 “lab2.har”, 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 the Fiddler tests.)

2. Make a copy of the folder. This is the data that you will be uploading.

3. Remove the “packages” folder from the copied folder; also, remove the “bin” and “obj” folders.

4. Compress/zip the copied folder. The zip file SHOULD be about 1MB or less 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 lab. 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.

.

.

.

.

.

.

.

.

.

.

.

%d bloggers like this: