Beispiel #1
0
        public async Task <List <ScheduledMatchDto> > GetMatches(RequestDto request)
        {
            //TODO: Refactor

            //Convert the list of selected list to the string of filter
            var codes = GetCompetitionsCodes(request.LeaguesChecked);

            var matchProvider = MatchProvider.Create().With(_httpClient).Build();

            var matches = await matchProvider.GetAllMatches("competitions", codes, "dateFrom", request.StartingDate.ToString("yyyy-MM-dd"), "dateTo", request.EndingDate.ToString("yyyy-MM-dd"));

            var result = new List <ScheduledMatchDto>();

            foreach (var match in matches)
            {
                Enum.TryParse(match.Status.ToUpper(), out Status state);
                ScoreResult scoreResult = new ScoreResult(match.Score.FullTime.HomeTeam, match.Score.FullTime.AwayTeam);

                result.Add(new ScheduledMatchDto(
                               match.HomeTeam.Name,
                               match.AwayTeam.Name,
                               match.UtcDate,
                               state,
                               scoreResult,
                               (int)match.Matchday,
                               new LeagueDto(match.Competition.Name, match.Competition.Area.Name)
                               ));
            }
            //Filter matches with selected status
            result = result.Where(m => request.StatusChecked.Contains(m.Status)).ToList();
            return(result);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var httpClient = new HttpClient();

            var apiKey = Environment.GetEnvironmentVariable("ApiKey");

            if (!string.IsNullOrEmpty(apiKey))
            {
                httpClient.DefaultRequestHeaders.Add("X-Auth-Token", apiKey);
            }

            var competitionController = CompetitionProvider.Create()
                                        .With(httpClient)
                                        .Build();

            var matchController = MatchProvider.Create()
                                  .With(httpClient)
                                  .Build();

            //GetCompetitions(competitionController);
            //GetCompetitionsWithFilter(competitionController);
            //GetCompetitionById(competitionController, 2019);
            //GetAllMatchOfCompetition(matchController, 2019);
            //GetAllMatch(matchController);
            GetMatchById(matchController, 200033);

            Console.ReadKey();
        }
Beispiel #3
0
        public ImageMatchProvider GetImageMatchProvider(IFillProvider <IImageData> fillProvider, IImageDataSorter imageDataSorter)
        {
            IFillProviderFactory <IImageData, IImageData> fillProviderFactory = new FilteredFillProviderFactory <IImageData, IImageData>(fillProvider, _filterStrategyFactory);
            IMatchProvider <IImageData, ImageMatch>       matchProvider       = new MatchProvider <IImageData, IImageData, ImageMatch>(
                _matchStrategy, fillProviderFactory);
            IMatchEngine <IImageData, ImageMatch> matchEngine = new MatchEngine <IImageData, ImageMatch>(matchProvider, _matchFilter);

            return(new ImageMatchProvider(matchEngine));
        }
Beispiel #4
0
        private void matchProvider_OnLoadSuccess(MatchProvider sender, EventArgs e)
        {
            foreach (MatchItem match in matchProvider)
            {
                lstMatches.Items.Add(match.getName());
            }

            updateTrayIcon();
        }
Beispiel #5
0
        private static async void GetAllMatch(MatchProvider matchController)
        {
            var matches = await matchController.GetAllMatches();

            lock (lockWrite)
            {
                Console.WriteLine("### All available matches ###");
                Console.WriteLine(JsonConvert.SerializeObject(matches));
                Console.WriteLine();
            }
        }
Beispiel #6
0
        private static async void GetAllMatchOfCompetition(MatchProvider matchController, int id)
        {
            var matches = await matchController.GetAllMatchOfCompetition(id);

            lock (lockWrite)
            {
                Console.WriteLine("### All matches of competition ###");
                Console.WriteLine(JsonConvert.SerializeObject(matches));
                Console.WriteLine();
            }
        }
Beispiel #7
0
        private static async void GetMatchById(MatchProvider matchController, int idMatch)
        {
            var match = await matchController.GetMatchById(idMatch);

            lock (lockWrite)
            {
                Console.WriteLine("### Get match by ID ###");
                Console.WriteLine(JsonConvert.SerializeObject(match));
                Console.WriteLine();
            }
        }
Beispiel #8
0
        public static string ToIntersectsString(MatchProvider provider, MatchItem match)
        {
            string intersects = string.Empty;
            foreach (MatchItem m in provider)
            {
                if (match.isIntersectWith(m))
                {
                    intersects += ("\n" + m.getDescription());
                }
            }

            return intersects;
        }
Beispiel #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            checkAllowUpdate();
            checkAllowDelete();
            checkAllowAdd();

            timerUpdate.Interval = Config.TimeUpdate;
            timerUpdate.Tick    += timer_Tick;
            timerUpdate.Enabled  = true;

            matchProvider = new MatchProvider(Config.DataURL);
            matchProvider.OnLoadSuccess += matchProvider_OnLoadSuccess;
            matchProvider.Load();
        }
        public void InsertTooLongMatch()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);
            string         tooLong  = new String('a', maxLength + 1);

            //When
            provider.SaveMatchLevel1(tooLong, tooLong);

            var matches = provider.GetMatches(tooLong);

            //Then exception
        }
        public void InsertAndGetFromFreshDB()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            //When
            provider.SaveMatchLevel1("near", "actual");
            var matches = provider.GetMatches("near").ToList();

            //Then
            Assert.AreEqual(1, matches.Count());
            Assert.IsTrue(matches.All(x => x.AltLevel1 == "near"));
        }
        public void InsertAndGetLevel3FromFreshDB()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            //When
            provider.SaveMatchLevel3("near", "level1", "level2", "level3");
            var matches = provider.GetMatches("near", "level1", "level2");

            //Then
            Assert.AreEqual(1, matches.Count());
            var match = matches.Single();

            Assert.AreEqual("level3", match.Level3);
        }
        public void GetMatches_InputWithDifferentCase_RecordRetrieved()
        {
            // Arrange
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            provider.SaveMatchLevel1("Near", "actual");

            // Act
            List <Level1Match> matchesLowerCase =
                provider.GetMatches("near").ToList();

            // Assert
            Assert.AreEqual(1, matchesLowerCase.Count());
            Assert.AreEqual("Near", matchesLowerCase.Single().AltLevel1);
            Assert.AreEqual("actual", matchesLowerCase.Single().Level1);
        }
        public void SaveMatchLevel1_InsertDuplicateMatch_RecordOverwritten()
        {
            // Arrange
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            // Act
            provider.SaveMatchLevel1("input", "match_x");
            provider.SaveMatchLevel1("input", "match_y");
            IEnumerable <Level1Match> matches = provider.GetMatches("input").ToList();

            // Asset
            Assert.AreEqual(1, matches.Count());
            var match = matches.Single();

            Assert.AreEqual("input", match.AltLevel1);
            Assert.AreEqual("match_y", match.Level1);
        }
        public void InsertMaxLengthMatch()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);
            string         veryLong = new String('a', maxLength);

            //When
            provider.SaveMatchLevel1(veryLong, veryLong);
            var matches = provider.GetMatches(veryLong);

            //Then
            Assert.AreEqual(1, matches.Count());
            var match = matches.Single();

            Assert.AreEqual(veryLong, match.AltLevel1);
            Assert.AreEqual(veryLong, match.Level1);
        }
        public void InsertSpecialCharactersMatch()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider          = new MatchProvider(connection);
            string         specialCharacters =
                "%ùéèôçà六书/六書形声字/形聲字абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
            int length = specialCharacters.Length;

            //When
            provider.SaveMatchLevel1(specialCharacters, specialCharacters);
            var matches = provider.GetMatches(specialCharacters);

            //Then
            Assert.AreEqual(1, matches.Count());
            var match = matches.Single();

            Assert.AreEqual(specialCharacters.Length, match.AltLevel1.Length);
            Assert.AreEqual(specialCharacters, match.AltLevel1);
            Assert.AreEqual(specialCharacters, match.Level1);
        }
        public void SaveMatchLevel1_InsertWithDifferentCase_RecordOverwritten()
        {
            // Arrange
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            // Act
            provider.SaveMatchLevel1("near", "actual");
            provider.SaveMatchLevel1("Near", "actual");
            List <Level1Match> matchesUpperCase =
                provider.GetMatches("NEAR").ToList();
            List <Level1Match> matchesLowerCase =
                provider.GetMatches("near").ToList();

            // Assert
            Assert.AreEqual(1, matchesUpperCase.Count());
            Assert.AreEqual(1, matchesLowerCase.Count());
            Assert.AreEqual(
                matchesUpperCase.First().MatchId,
                matchesLowerCase.First().MatchId);
        }
        public void InsertToFreshDBAndGetFromDeletedDB()
        {
            //Given
            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            IMatchProvider provider = new MatchProvider(connection);

            //When
            provider.SaveMatchLevel1("near", "actual");
            provider.SaveMatchLevel1("near", "actual3");
            connection.Close();
            File.Delete(dbLocation);

            connection = DBHelper.GetDbConnection(dbLocation);
            connection.InitializeDB();
            provider = new MatchProvider(connection);
            var matches = provider.GetMatches("near");

            connection.Close();

            //Then
            Assert.AreEqual(0, matches.Count());
        }
Beispiel #19
0
        private async Task <SoftwareData> GetSoftwareAsync(SoftwareCameraInfo camera, SoftwareInfo softwareInfo, CancellationToken cancellationToken)
        {
            SetTitle(nameof(Resources.Download_FetchingData_Text));

            var buildName = BuildProvider.GetBuildName(softwareInfo);
            var matches   = await MatchProvider.GetMatchesAsync(camera, buildName, cancellationToken);

            if (matches == null)
            {
                var error = MatchProvider.GetError();
                SetTitle(error, LogLevel.Error);
                return(null);
            }

            var match     = matches.Last();
            var info      = SoftwareProvider.GetSoftware(match);
            var downloads = DownloadProvider.GetDownloads(matches, info).ToArray();

            return(new SoftwareData
            {
                Info = info,
                Downloads = downloads,
            });
        }
Beispiel #20
0
        private void matchProvider_OnLoadSuccess(MatchProvider sender, EventArgs e)
        {
            foreach (MatchItem match in matchProvider)
            {
                lstMatches.Items.Add(match.getName());
            }

            updateTrayIcon();
        }
Beispiel #21
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            checkAllowUpdate();
            checkAllowDelete();
            checkAllowAdd();

            timerUpdate.Interval = Config.TimeUpdate;
            timerUpdate.Tick += timer_Tick;
            timerUpdate.Enabled = true;

            matchProvider = new MatchProvider(Config.DataURL);
            matchProvider.OnLoadSuccess += matchProvider_OnLoadSuccess;
            matchProvider.Load();
        }
        public MatchMetaDataModel GetMatchByMatchID(int matchID)
        {
            MatchProvider provider = new MatchProvider();

            return(new MatchMetaDataModel());
        }
        public MatchesGroupModel GetMatchesBySeriesID(int seriesID)
        {
            MatchProvider provider = new MatchProvider();

            return(provider.GetMatchesBySeries(seriesID));
        }
        public MatchesGroupModel GetMatches()
        {
            MatchProvider provider = new MatchProvider();

            return(provider.GetMatches());
        }