Esempio n. 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);
        }