TrainNotifier.Service.TrainMovementRepository.CallingAtLocation C# (CSharp) Method

CallingAtLocation() public method

public CallingAtLocation ( string stanox, System.DateTime startDate = null, System.DateTime endDate = null, string atocCode = null, PowerType powerType = null ) : IEnumerable
stanox string
startDate System.DateTime
endDate System.DateTime
atocCode string
powerType PowerType
return IEnumerable
        public IEnumerable<TrainMovementResult> CallingAtLocation(string stanox, DateTime? startDate = null, DateTime? endDate = null, string atocCode = null, PowerType? powerType = null)
        {
            startDate = startDate ?? DateTime.UtcNow.AddDays(-1);
            endDate = endDate ?? DateTime.UtcNow.Date.Add(new TimeSpan(23, 59, 59));

            if ((endDate.Value - startDate.Value) > TimeSpan.FromDays(1))
            {
                endDate = startDate.Value.AddDays(1);
            }

            // get tiploc id to improve query
            var tiplocs = _tiplocRepository.GetTiplocsByStanox(stanox)
                .Select(t => t.TiplocId);

            if (!tiplocs.Any())
                return Enumerable.Empty<TrainMovementResult>();

            return CallingAt(tiplocs, startDate.Value, endDate.Value, atocCode, powerType);
        }