Primary Objectives:

  1. Be able to write a MVC web application that uses portions of a large, complex pre-existing database
  2. Be able to derive C# models from an existing database using Entity Framework and “Code First with an Existing Database” workflow
  3. Be able to write LINQ queries using fluent syntax
  4. Learn to use C# language features: partial classes
  5. Use more Razor language features to build feature-laden views

Overall Requirements:

  • You must use “Code First with an Existing Database” workflow
  • Don't add and commit your database file (ignore it please; it's 205 MB)
  • If you need to add something to a model class, do it in a new file (still in the model folder) and use a partial class
  • Make this a single website, with a landing page and links as appropriate. Remove unnecessary boilerplate and add in something to make it look like a prototype of a real system
  • You should prefer strongly-typed views over untyped viewbag-only views
  • Use only fluent LINQ syntax (dot notation) and not query syntax (the sql-like version)

"As a Web Application Developer Padawan (WADP™), I want to build an example application that uses a lot of data and showcases the use of an existing large database, so I can practice my LINQ and MVC moves."

Questions/Tasks:

  1. Begin this homework by downloading and extracting the AdventureWorks 2014 example database from CodePlex. It's moved. The database you want to use is the OLTP version from here. (They moved sample databases from "CodePlex" to GitHub.) Use the full database backup zip file version.

    For a full description of the AdventureWorks "company" and database, see here.

  2. Follow the steps shown in class, or here (for reference: Entity Framework - Code First from Existing Database) to create an empty MVC project, add the database and reverse engineer (generate) model classes. We will only be using the Production subsystem, so I recommend you only generate model classes for that subsystem (something like 24 tables/classes plus the context class).
  3. Feature 1: Browse Products

    As a potential customer who is visiting the website I would like to be able to browse to find products to buy. I already know what category of product I want, I just want to pick an item in that category.

    A user should easily be able to find products in the store/catalog and view details of that product. The user does not want to search by keyword. They want to browse by product category. Products can be organized by top level category (Production.ProductCategory) and then by a sub-category (Production.ProductSubcategory). Don't show results until the user has selected both category and sub-category. Then allow them to see a short listing of products (or a paged version), from which they can select or click on one to bring up a full product description, maybe with a review. Kudos to anyone who can display the product photo.

    For an example, go to nearly any large web store, say REI. Click on Snow (the top level category), then click on Downhill Skiing (a subcategory). You see a number of products. Click on Arc'teryx Sabre Jacket - Men's to see a full description, yikes :-( $625!) They have at least 2 levels of sub-categories where we have only 1, but you get the idea. (You can see the subcategories in the breadcrumbs.)

    Your stakeholders have not given a preference as to what this should look like or how you do this, so it's your choice. Do you use hyperlinks? Drop down (select) lists? What info do you show the user? Well, certainly don't show them primary key or foreign key values, or internal things like FinishedGoodsFlag. Should you show discontinued items? Probably not. It's up to you. Also, try to make it look decent please; the default auto-generated CRUD look won't cut it!

  4. Feature 2: Add Review

    Let's see if we can insert to the database. This user story describes what is needed.

    As a customer who has purchased a product I would like to be able to write and submit a review of a particular product so others can read about my experience with the it.

    For ease of implementation, assume the user knows the Production.Product.ProductID. Allow them to enter their name, email address, rating and a possibly lengthy comment/review. When they correctly submit the information, insert it into the database and thank the user for their review (using POST/Redirect/GET).

    You can integrate this feature with the browse functionality or not; it's up to you. If you integrate it then the user won't have to know the product ID as you'll already have it.

  5. And by now you know the drill; put it all in your Portfolio. Do you know what would make the grader really happy? A video of you demonstrating your website.