コード例 #1
0
        public GetHorsesDataRequest GetHorsesDataRequest(string fileName)
        {
            //Matching pattern to determine which processor to use (i.e. if input is XML or JSON)
            var matchingProcessor = _feedRepository.GetFeedsProcessorType(fileName);

            if (matchingProcessor == null)
            {
                throw new Exception($"Feed with name {fileName} not supported");
            }

            var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);

            var fileContents = ReadText(filePath);

            var feed = matchingProcessor.Process(fileContents);

            var request = new GetHorsesDataRequest
            {
                Feed = feed
            };

            if (_feedRepository.Read().Any(x => x.FeedId == request.Feed.FeedId))
            {
            }

            _feedRepository.GetFeedsData(request.Feed);

            return(request);
        }
コード例 #2
0
        public GetHorsesDataResponse GetHorsesDataWithPrices(GetHorsesDataRequest request)
        {
            var feeds = _feedRepository.Read();

            var feed = feeds.Single(x => x.FeedId == request.Feed.FeedId);

            var race = feed.Races.Single(x => x.RaceNumber == request.RaceNumber);

            var horses = race.Horses.OrderBy(x => x.Price);

            return(new GetHorsesDataResponse
            {
                Horses = horses
            });
        }