The New Stored Procedures

After we created a schema to tie users to the products they wished to buy (or have bought for them), we needed a way to add, delete, and list the data. Three new stored procedures were added to achieve this functionality: spAddToWishList, spDeleteFromWishList, and spGetWishList.

The spAddToWishList Stored Procedure

As its name implies, the spAddToWishList stored procedure was created to allow for the addition of products to a particular user's wish list. Listing 9.1 shows the code for this stored procedure.

Listing 9.1. spAddToWishList
 CREATE PROCEDURE dbo.spAddToWishList ( @userid int, @productid uniqueidentifier ) AS if not exists ( select * from WishList where userid = @Userid and productid = @productID ) BEGIN insert ...

Get Building e-Commerce Sites with the .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.