50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
// /**
|
|
// * 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<BilledCDR>
|
|
{
|
|
public Tariff Tariff { get; }
|
|
public BilledCDR[] BilledCDRs => billedCDRs.ToArray();
|
|
|
|
List<BilledCDR> billedCDRs = new List<BilledCDR>();
|
|
|
|
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<BilledCDR> GetEnumerator()
|
|
{
|
|
return billedCDRs.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
}
|