예제 #1
0
 public void SetUp()
 {
     _loggerMock            = new Mock <ILogger <RailPredictionsController> >();
     _predictionServiceMock = new Mock <IPredictionService>();
     _controller            = new RailPredictionsController(_loggerMock.Object, _predictionServiceMock.Object);
     _request  = new RailPredictionDCRequest();
     _response = new RailPredictionDCResponse();
 }
        public async Task <ActionResult <IEnumerable <RailPredictionDCResponse> > > GetRailPredictionsDC([FromQuery] RailPredictionDCRequest request)
        {
            try
            {
                _logger.LogInformation("Rail Predictions Get Rail Predictions DC Endpoint");
                var response = await _predictionService.GetRailPredictionsDC(request);

                return(response.ToArray());
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception in Rail Prediction Endpoint: {ex.Message}");
                _logger.LogInformation($"Exception stack trace: {ex.StackTrace}");
                return(InternalServerError(ex.Message));
            }
        }
예제 #3
0
 public void SetUp()
 {
     _logger   = new Mock <ILogger <RailPredictionService> >();
     _request  = new RailPredictionDCRequest();
     _response = new RailPredictionDCApiResponse();
 }
예제 #4
0
        public async Task <IEnumerable <RailPredictionDCResponse> > GetRailPredictionsDC(RailPredictionDCRequest request)
        {
            var req = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri("https://api.wmata.com/StationPrediction.svc/json/GetPrediction/" + (request.StationCode ?? "All"))
            };

            return(await MakeRailPredictionsDCApiCall(req));
        }