public static IEnumerable <LocationCallEvent> GetEvents(IList <CallHistory> callHistories, CallHistoryFilter filter) { foreach (var call in callHistories) { if ((call.FromLocationId == call.ToLocationId && filter.IsMatch(call)) || filter.IsFromMatch(call)) { yield return (Create(CallEventType.Start, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName))); yield return (Create(CallEventType.End, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName))); } if (call.FromLocationId != call.ToLocationId && filter.IsToMatch(call)) { yield return (Create(CallEventType.Start, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName))); yield return (Create(CallEventType.End, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName))); } } }
public static IEnumerable <LocationCallEvent> GetOrderedEvents(IList <CallHistory> callHistories, CallHistoryFilter filter) { return(GetEvents(callHistories, filter).OrderBy(e => e.EventTime).ThenBy(e => (int)e.EventType)); }