Web API – best practice – app assembly

Web API – best practice – app assembly and coding. You can use this as a checklist.

.

Class or code module Checklist
Configuring the app
Enable ‘root’ controller route in App_Start > WebApiConfig.cs
RootController.cs coding, to return the available link relations
Persistent data store connection string in Web.config
Configure the ‘Help’ page feature, and make it ready for Windows Azure
(more may be added here)
Plug-in modules (formatter, handler)
Image formatter
OAuth message handler (which uses this AuthN+AuthZ app)
HTTP OPTIONS handler
WebApiApplication class (in Global.asax.cs) that initializes these plug-in modules
Exception filter to handle runtime exceptions
(more may be added here)
App domain data model
App domain model classes, related (no data annotations)
Above, with data annotations
DbContext class (which is the Entity Framework API)
Store initializer class, to create objects with associations
Above, uploads byte array (e.g. photo) when creating object
Typical WebApiApplication class support for the store initializer, in situations that do NOT use Code First Migrations
When using Code First Migrations, store initialization happens in the Configuration class (in its Seed method)
Declaring an enumeration for use in an app domain model class
(more may be added here)
App and business logic
(coming soon)
View models
Link relation classes, in the ViewModels folder
Classes to support GET and POST methods, with link relations and add-new template
Guidance on naming view model classes
Classes to support PUT method (no link relations)
AutoMapper definitions (in WebApiApplication class) to support all HTTP methods; including standard to-one and to-many projections
(more may be added here)
Repositories
Repo base class
Repo for entity that includes nested to-many collection (e.g. Program > Subjects)
Repo for entity that includes flattened to-one object (e.g. Subject > Program)
Repo for entity that supports an ‘image’ representation
Validate user input for enum types
(more may be added here)
Controllers, no link relations
Supports all methods – GET, POST, PUT, DELETE (no link relations), including nested to-many collection (e.g. Program > Subjects)
Above, including flattened to-one object (Subject > Program)
Handles ‘image’ representation, upload (PUT) and delivery (GET) (no link relations)
(more may be added here)
Controllers, WITH link relations
Supports get-all and get-one requests; includes Links, Collection, Template properties
Supports add-new, update-existing, and delete requests
“Lookups” controller to deliver the string values of enumerations
(more may be added here)

.

.

.

.

.

.

.

.

  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: