O'Reilly logo

Professional ASP.NET Design Patterns by Scott Millett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Implementing the Shopping Basket

WHAT'S IN THIS CHAPTER?

  • Adding products to a basket via AJAX

  • Using the client's cookie to store a summary of the basket contents

  • Utilizing AJAX for the basket detail page when modifying the basket or shipping options

In Chapter 11, you enabled a customer to browse for products; this chapter addresses the needs of a customer to store the items they would like to order in a basket.

IMPLEMENTING THE BASKET

The basket implementation should use AJAX in all of its functionality, in keeping with the rich web 2.0 theme of the product browsing pages. Therefore, you will use AJAX to add, amend, and remove items from a basket, as well as select the dispatch options. A summary of the basket will appear on all product browsing pages, which will be stored in the client's cookie to enable faster page generation

Basket Domain Model

Figure 12-1 shows the domain model of the entities involved with the basket functionality.

FIGURE 12-1

Figure 12-1. FIGURE 12-1

Create a new folder within the Model project named Shipping, and add to it a new class named Courier that inherits from the EntityBase class that you created in the Infrastructure project.

using System.Collections.Generic; using Agathas.Storefront.Infrastructure.Domain; namespace Agathas.Storefront.Model.Shipping { public class Courier : EntityBase<int> { private readonly string _name; private readonly IEnumerable<ShippingService> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required