Example #1
0
        public HourBasedStatisticsForLocation GetHourStatisticsForLocation(DateTime startTime, DateTime endTime, Guid locationId, bool noAggregation)
        {
            var location = _locationRepository.GetById(locationId);

            if (location == null)
            {
                return new HourBasedStatisticsForLocation {
                           LocationId = locationId, LocationName = "", Statistics = new List <HourBasedStatistics>()
                }
            }
            ;

            var allStats      = new List <HourBasedStatistics>();
            var callHistories = _callHistoryRepository.GetCallHistoriesForLocation(startTime, endTime, locationId);
            var current       = HourBasedStatistics.Create(startTime);

            allStats.Add(current);
            foreach (var callEvent in HourBasedCallEvent.GetOrderedEvents(callHistories, locationId).Where(e => e.EventTime < endTime))
            {
                while (!current.AddEvent(callEvent))
                {
                    current = current.GetNext();
                    allStats.Add(current);
                }
            }

            return(new HourBasedStatisticsForLocation
            {
                LocationId = locationId,
                LocationName = location.Name,
                Statistics = noAggregation ? allStats : HourBasedStatistics.Aggregate(allStats)
            });
        }
 public IList <CallHistory> GetCallHistoriesForLocation(DateTime startDate, DateTime endDate, Guid locationId)
 {
     return(_internalRepository.GetCallHistoriesForLocation(startDate, endDate, locationId));
 }