Exemple #1
0
        //public void AddLine(Album album, int quantity)
        //{
        //    // Get the matching cart and album instances
        //    var line = repository.Carts.SingleOrDefault(
        //        c => c.CartId == this.ShoppingCartId
        //        && c.AlbumId == album.AlbumId);

        //    if (line == null)
        //    {
        //        // Create a new cart line if no cart item exists
        //        Cart newLine = new Cart
        //        {
        //            CartId = this.ShoppingCartId,
        //            AlbumId = album.AlbumId,
        //            Count = quantity,
        //            DateCreated = DateTime.Now
        //        };
        //        repository.AddLine(newLine);
        //    }
        //    else
        //    {
        //        // If the item does exist in the cart, then add one to the quantity
        //        repository.AddLine(line.LineId, quantity);
        //    }
        //}

        public void AddLine(int albumId, int quantity)
        {
            repository.AddLine(this.ShoppingCartId, albumId, quantity);
        }