private void CalculateSubtotalPrice() { OrderLines.ForEach(line => line.CalculatePrice()); var subtotal = OrderLines .Aggregate(0.0, (i, line) => i + line.Price); SubtotalPrice = Math.Round(subtotal, 2); }
/// <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); }