// /** // * File: BilledCDRCollection.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use without proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace ln.provider.data.phone { public class BilledCDRCollection : IEnumerable { public Tariff Tariff { get; } public BilledCDR[] BilledCDRs => billedCDRs.ToArray(); List billedCDRs = new List(); public BilledCDRCollection(Tariff tariff) { Tariff = tariff; } public BilledCDR this[int n] => billedCDRs[n]; public int Count => billedCDRs.Count; public int TotalCents => (billedCDRs.Select((bc) => bc.PricePerThousand).Sum() + 9) / 10; public void Add(CDR cdr) { BilledCDR billedCDR = new BilledCDR(cdr, Tariff.GetRate(cdr.Called)); billedCDRs.Add(billedCDR); } public IEnumerator GetEnumerator() { return billedCDRs.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } }