コード例 #1
0
        private void CalculateSubtotalPrice()
        {
            OrderLines.ForEach(line => line.CalculatePrice());
            var subtotal = OrderLines
                           .Aggregate(0.0, (i, line) => i + line.Price);

            SubtotalPrice = Math.Round(subtotal, 2);
        }
コード例 #2
0
        /// <summary>
        /// Get the total of the order
        /// </summary>
        /// <returns>The total of the order</returns>
        public decimal GetOrderTotal()
        {
            decimal total = 0M;

            if (OrderLines != null //use OrderLines for lazy loading
                &&
                OrderLines.Any())
            {
                total = OrderLines.Aggregate(total, (t, l) => t += l.TotalLine);
            }

            return(total);
        }