BTI420 Lab 5

Data annotations. AutoMapper. Edit and delete pattern.

.

BTI420 Lab 5 – Due on Tue Feb 18

Due date: Tuesday, February 18, 2014, at 6:00am ET

Grade value: 5% of your final course grade

.

Objective(s)

Build upon the work that you did in your Lab 4.

Add data annotations to design model classes, and view model classes.

Convert your property-mapping code to use AutoMapper.

Implement the edit and add patterns.

.

Introduction to the problem that you will solve

Your existing Lab 4 app needs a few more features.

  • Design model classes need data annotations
  • The Product design model class needs a new DateTime property
  • View model classes need data annotations too, to improve property display, and validation tasks
  • The edit and delete patterns need to be implemented for the Product entity
  • Supplier list and detail views will include Product object collections

Read/skim this assignment fully before you start work on it.

.

Get started with Lab 5

Follow the steps in this linked document to create a copy of your existing Lab 4 project.

The name of the new (copied) project will be “Lab5”.

Add and configure the functionality described in the following sections.

.

Design model classes need data annotations

Delete your existing database before you perform these tasks. If you need a reminder about the procedure for doing so:

  1. In Solution Explorer, select/highlight the project file
  2. On the Solution Explorer toolbar, select/activate “Show All Files”
  3. Open/reveal the contents of the App_Data folder, and you will see your database file (e.g. “StoreName.mdf”)
  4. Delete it

.

Design model annotations

Study the design model.

Add appropriate annotations for these specific design model classes.

What’s appropriate? Ask yourself about the validity and integrity of the data that will be created, and then use your judgement.

Add code comments to justify the decisions you made about your data annotations.

.

The Product design model class needs a new DateTime property

Add a DateTime property, named DateCreated, to the Product design model class.

If you wish, add code to initialize its value in the default constructor. What’s a reasonable initial value?

.

View model classes need data annotations too, to improve property display, and validation tasks

Study the data annotations topic, first introduced in the February 5 class session.

Add data annotations, where appropriate, to enable the following:

  • input data validation
  • friendly and useful display name
  • friendly and useful input data validation error message

Add code comments to justify the decisions you made about your data annotations.

.

The add, edit, and delete patterns need to be implemented for the Product entity

Recently, you learned how to modify the ‘add new’ handler in the controller to return bad data to the view, in situations where the incoming data did not pass validation.

Edit your existing code to implement this recently-learned ‘add new’ coding pattern.

.

Edit pattern

Add code (controller and manager) that enables the ‘edit existing’ task for a product object. Do not allow the user to edit the product object’s identifier, or the supplier.

.

Delete pattern

Add code (controller and manager) that enables the ‘delete existing’ task for a product object.

.

Supplier list and detail views will include Product object collections

Your Supplier list and detail views must now include some information about a supplier’s collection of products.

Modify your code to make this happen. What modifications are needed? Before you begin, think about the situation. Then, write down the modifications before you begin coding. Validate your thoughts by studying existing notes and code examples.

.

Configure (fix) navigation in your web app

Add links to the new page hierarchy in an appropriate place.

Maybe on the web app’s (Home) Index.cshtml view (in the body). Maybe also in the menu in _Layout.cshtml.

.

Submit your work on My.Seneca/Blackboard

Follow these brief instructions to submit your work on My.Seneca/Blackboard. See Lab 1 for all the detailed steps.

1. Make a copy of your “Lab5″ project

2. Remove the “packages”, “bin”, and “obj” folders

3. Zip your project (make sure you’re at the correct level in the file system)

4. Submit your work via My.Seneca/Blackboard

.

.

.

.

.

.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: