public void AddToCart(Album album)
{
// Get the matching cart and album instances
Cart cartItem = Cart.FindByCartIdAlbum(ShoppingCartId, album);
if (cartItem == null)
{
// Create a new cart item if no cart item exists
cartItem = new Cart
{
Album = album,
CartId = ShoppingCartId,
Count = 1,
DateCreated = DateTime.Now
};
}
else
{
// If the item does exist in the cart, then add one to the quantity
cartItem.Count++;
}
// Save changes
cartItem.Save();
}