ASP.NET 3.5 Problem ' Design - Solution

Last Summer, around August 2008, I started work on my latest book and spent the next 5 months working on updates to the Beer House application. WROX asked me to write the book and only had 2 requirements: 1) Use Entity Framework 2) Add more AJAX to the application, focusing on ASP.NET AJAX. So that is what I did! I was told this past week that I should have my copies by the Code Camp of the Carolinas (Charlotte on Oct 10), so go ahead and get your pre-order in with Amazon now!!

New Features

Besides an entirely new data access methodology and more AJAX I added a few more modules and improved a few of the existing modules and added. One thing I tried to do was not stray too far from some things in the Beer House I felt would cause confusion or major changes for existing Beer House enthusiasts to absorb.

Chapters

Chapter 1: Introducing the Project: TheBeerHouse.
Chapter 2: Developing the Site Design.
Chapter 3: Planning an Architecture.
Chapter 4: Membership and User Profiling.
Chapter 5: News and Article Management.
Chapter 6: Opinion Polls.
Chapter 7: Newsletters.
Chapter 8: Forums.
Chapter 9: E-Commerce Store.
Chapter 10: Calendar of Events.
Chapter 11: Photo Gallery.
Chapter 12: Localizing the Site.
Chapter 13: Deploying the Site.

Photo Gallery

Some of the new features to the Beer House include a Photo Gallery and Calendar of Events module. The Photo Gallery allows authenticated users to create new and manage existing photo albums. They can upload full-sized photos that will have display and thumbnail versions created at upload time. I also features a pretty neat lightbox based on the Prototype AJAX framework (yes I am aware of the ones based on jQuery, but did not find them in time for the book).

Calendar of Events

The Calendar of Events allows administrators to create new events, such as karaoke, game watching, live music, etc in the case of the Beer House. Events are displayed on an interactive calendar and visitors can open up a vCal to add the event to their personal calendar, such as Outlook.

Login ' Now With OpenId!

As far as AJAX features, I added a Login Dialog feature to the application so a user can authenticate anywhere in the site without loosing their place. The Dialog is based on some simple AJAX and CSS manipulations. I also added a simple way to authenticate via OpenId to the Beer House.

Social Networking

Two new features were added to the Articles module to make it more social and secure. When articles are published they can now be automatically announced on Twitter. This will help the Beer House to be visible to its customers. I also update the article rating mechanism, as well as polling, to utilize the ASP.NET AJAX Rating Control, with Beer mugs no less!

Akismet

Another new feature is filter comments through Akismet. If you are not familiar with Akismet it is a comment filtering service managed by WordPress. Utilizing this service should help eliminate potential Comment Spam that is littering the Internet these days. I know I delete several hundred each week on this Blog.

Gravatar

Another new feature for article comments is integration of Gravatar support. A Gravater is simply a service that manages your personal avatar that is displayed in places like comments or user forums over the Internet. I like Gravatars because it helps me personalize (think branding) my comments across the Internet without having to manually add my pretty smile each and every time!

SEO

Finally a another new feature I included in the new version of the Beer House is better Search Engine Optimization (SEO) support. The new Beer House features a sound URL rewriting engine, as well as some onpage SEO features. The URL rewriting engine works to eliminate duplicate content and canonicalization issues. For example if a visitor uses the 'www.' alias to access the site it will automatically perform a 301 redirect to the same URL minus the 'www.' prefix.

Entity Framework

The primary reason why I wanted to write this book was to learn Entity Framework. Before starting this project the only exposure to the Entity Framework I had was listening to Julie Lerman (by the way she has a great book on EF) and a DNR TV with Danny Simmons. I also had zero ORM experience so this was all new to me. I hope the content supplied in the book is helpful to folks new to all these concepts to get you going. It has been several months since I froze the code in the book and I have some follow up Blogs to extend the Linq to Entity Framework concepts in the book based on what I have learned since then, so please follow my Blog to see where I take things.

Changes from V 2.0

I decided to pull data and business logic pieces out of the web site and place those in a separate Class Library project. I did this because I wanted to eventually use the data and utility classes in other applications and apply automated testing tools to the logic.

I also decided to create separate data models for each module in the application instead of one giant monolithic model. The nature of this application, being an open source project that many will only use the modules they need to use it made sense.

I kept the LINQ syntax more readable in this phase. I think it makes the queries more readable and easier to understand for someone trying to get their head wrapped around the concepts of LINQ to a Data Model. Once you get comfortable with querying an Entity Model you can start creating more advanced queries and I will be doing just that in the coming months.

Public

Function

GetArticles()

As

List(Of Article)

Dim

key

As

String

= CacheKey &

"_FullList"

If

EnableCaching

AndAlso

Not

IsNothing(Cache(key))

Then

Return

CType

(Cache(key), List(Of Article))

End

If

Articlesctx.Articles.MergeOption = _Data.Objects.MergeOption.NoTracking

Dim

lArticles

As

List(Of Article) = ( _From lArticle

In

Articlesctx.Articles _ Order By lArticle.ReleaseDate Descending).ToList()

If

EnableCaching

Then

CacheData(key, lArticles, CacheDuration)

End

If

Return

lArticles

End

Function

I also moved the Business layer from Active Record to a Repository pattern. I like repository because it separates the business logic that interacts with the DAL from the entity itself.

You will also note from the code sample above that I wrote the Beer House in VB.NET. A C# version is also available to download. There are downloadables available for the application as it is presented in the book as well as the main source, which I will be updated as I write new Blogs in the coming months. I also encourage you to download the MVC version of the Beer House too.

I hope you will find many benefits to the new version of the Beer House and extend your tools and knowledge base. I also look forward to getting feedback from you in the coming months. I have many Blogs waiting to publish to extend the concepts in the book. There was a lot of ideas I had that just did not make the cut for the release. So think about the future Blogs as the deleted scenes you only get on the DVD!

Share This Article With Your Friends!