コード例 #1
0
        public List <string> GetData(DrivingService drivingService)
        {
            var path = _configuration[$"{nameof(FileDrivingServiceDataProvider)}:FolderPath"];

            var fullName = Path.Combine(path, drivingService.ToString() + ".csv");

            List <string> allLines = File.ReadAllLines(fullName).ToList();

            return(allLines);
        }
コード例 #2
0
        public ITripMetrics GetMetrics(DrivingService drivingService, Borough startBorough, Borough stopBorough, TimeSpan tripPickupTime)
        {
            // decide which provider to use
            ITripMetricsProvider tmp;

            if (drivingService == DrivingService.GreenTaxi)
            {
                tmp = new GreenTaxiTripMetricsProvider(_configuration, _drivingServiceDataProvider);
            }
            else
            {
                throw new NotSupportedException($"Trip Provider '{drivingService}' is not yet supported.");
            }

            // get metrics from the provider
            var tripMetrics = tmp.GetMetrics(startBorough, stopBorough, tripPickupTime);

            // return the metrics to the caller
            return(tripMetrics);
        }
コード例 #3
0
        public ActionResult <ITripMetrics> Get(DrivingService drivingService, Borough startBorough, Borough stopBorough, string tripPickupTime)
        {
            if (TimeSpan.TryParse(tripPickupTime, out TimeSpan ts) == false)
            {
                return(BadRequest("tripPickupTime is not a valid time."));
            }

            if (ts.TotalHours >= 24)
            {
                return(BadRequest("tripPickupTime must be a time of day and so must be between 00:00 and 23:59."));
            }

            var metrics = _tripMetricsManager.GetMetrics(drivingService, startBorough, stopBorough, ts);

            if (metrics == null)
            {
                return(NoContent());
            }

            return(Ok(metrics));
        }
コード例 #4
0
 public List <string> GetData(DrivingService drivingService)
 {
     return(_data.Split('\n').ToList());
 }