MvcMusicStore.Models.ShoppingCart.GetTotal C# (CSharp) Method

GetTotal() public method

public GetTotal ( ) : decimal
return decimal
        public decimal GetTotal()
        {
            /*
            // Multiply album price by count of that album to get 
            // the current price for each of those albums in the cart
            // sum all album price totals to get the cart total
            decimal? total = (from cartItems in storeDB.Carts
                              where cartItems.CartId == ShoppingCartId
                              select (int?)cartItems.Count * cartItems.Album.Price).Sum();
            return total ?? decimal.Zero;
             */

            decimal? total = (from c in GetCartItems() select (c.Count * c.Album.Price)).Sum();
            return total ?? decimal.Zero;
        }