Exemple #1
0
        public void GivenExistingMatch_WhenPreviousGameWonAndNoDynamitesAvailableInTheGame_ThenBotsMoveShouldBeOfOneThatBeatsItsPreviousHandWithNoDynamitAndNoWaterbomb()
        {
            // Assemble
            var           botStrategy = new BotStrategy();
            IMatchService service     = new MatchService(botStrategy);

            service.NewMatch(3, 0);

            //Act

            //first game
            service.AddGame();
            var botsFirstMove = service.BotsMove();

            service.GameResult(Outcome.Win, Move.Paper);

            //second game
            service.AddGame();
            var         botsSecondMove = service.BotsMove();
            MoveHelpers mh             = new MoveHelpers();
            var         beaters        = mh.GetBeaters(botsFirstMove).ToList();

            //Assert
            Assert.AreNotEqual(Move.Dynamite, botsSecondMove);
            Assert.AreNotEqual(Move.Waterbomb, botsSecondMove);
            Assert.Contains(botsSecondMove, beaters);
        }
Exemple #2
0
 public HomeController(
     IAddGames addGames,
     MatchService matchService)
 {
     this.addGames     = addGames;
     this.matchService = matchService;
 }
Exemple #3
0
        public void GivenExistingMatch_WhenDynamiteAvailableInTheGameAndAlreadyUsedByBot_ThenBotsMoveShouldBeOfOneThatBeatsPlayersPreviousHand()
        {
            // Assemble
            var botStrategy = new BotStrategy();

            var strategyMock = new Mock <IBotStrategy>();

            var sequence = strategyMock.SetupSequence(m => m.GetBotsNextMove(It.IsAny <Game>(), It.IsAny <bool>(), It.IsAny <bool>()));


            IMatchService service = new MatchService(strategyMock.Object);


            service.NewMatch(3, 1);

            Move playersMove = Move.Waterbomb;

            //Act

            //first game
            sequence.Returns(Move.Dynamite);
            service.AddGame();
            var botsFirstMove = service.BotsMove();
            var gameResult    = service.GameResult(Outcome.Lose, playersMove);

            //second game
            sequence.Returns(botStrategy.GetBotsNextMove(gameResult, false, true));
            service.AddGame();
            var         botsSecondMove = service.BotsMove();
            MoveHelpers mh             = new MoveHelpers();
            var         beaters        = mh.GetBeaters(playersMove).ToList();

            //Assert
            Assert.Contains(botsSecondMove, beaters);
        }
 public SellTicketsServer(TicketService ticketService, UserService userService, MatchService matchService)
 {
     this._ticketService = ticketService;
     this._userService   = userService;
     this._loggedClients = new Dictionary <string, ISellTicketsClient>();
     this._matchService  = matchService;
 }
Exemple #5
0
 public MarketSvc(MatchService ms, IConnectionMgr <IMarketCallBack> connmgr, ISubscribeMgr mgr)
 {
     this.srv     = ms;
     this.connMgr = connMgr;
     this.smgr    = mgr;
     this.log     = new TextLog("marketsvc.txt");
 }
        /// <summary>
        /// Handles OnNavigatedTo event.
        /// </summary>
        /// <param name="e">Arguments passed to this page including parameter.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.matchService = e.Parameter as MatchService;

            if (this.matchService == null)
            {
                throw new Exception("Parameter not of type MatchService");
            }

            numPlayers = this.matchService.StandardMatch.Players.Count();

            this.matchService.InitializeGame();
            this.matchService.SetHasStarted();

            this.SetStatsScoreItems();

            this.UpdateScoreItems();

            if (numPlayers > 2)
            {
                PlayersListView.ItemsSource = PlayerScoreItems;
            }

            // Initialize values.
            this.SetCurrentTurn();
            this.SetTurnStartLeg();

            var player = this.matchService.GetTurn();

            if (player.PlayerType == PlayerType.Bot)
            {
                EnterBotScore(player);
            }
        }
        public UserControl_HomeAwayTeams(UserControl_MainContent mainContent)
        {
            InitializeComponent();
            new Thread(() =>
            {
                UtilsNotification.StartLoadingAnimation();

                _mainContent       = mainContent;
                IsDrawableMenuOpen = false;

                IsMatchType = false;
                IsHomeTeam  = true;
                matchPeriod = MatchPeriodTypeValues.FullTime;
                ImageLogo.Dispatcher.BeginInvoke((Action)(() => ImageLogo.Visibility = Visibility.Visible));
                LabelInfo.Dispatcher.BeginInvoke((Action)(() => LabelInfo.Visibility = Visibility.Visible));
                LabelExtraInfo.Dispatcher.BeginInvoke((Action)(() => LabelExtraInfo.Visibility = Visibility.Visible));

                teamService  = new TeamService();
                matchService = new MatchService();

                DrawableMenuContainer.Dispatcher.BeginInvoke((Action)(() =>
                                                                      DrawableMenuContainer.Content = new UserControl_DrawableMenuTeams(_mainContent, this)));

                UtilsNotification.StopLoadingAnimation();
            }).Start();
        }
Exemple #8
0
        public async Task Substitution_WhenAllSubsUsed_ThrowsException()
        {
            var userId  = Guid.NewGuid();
            var matchId = Guid.NewGuid();

            var mockMatch = new Mock <ApplicationCore.Models.Match>();

            mockMatch.SetupGet(x => x.HomeTeam).Returns(new TeamDetails()
            {
                UserId   = userId,
                UsedSubs = MatchService.SubCount
            });

            var mockMatchmakingService = new Mock <IMatchmakingService>();

            var stubMatchEngine = new Mock <IMatchEngine>();

            stubMatchEngine.Setup(x => x.SimulateReentrant(It.IsAny <ApplicationCore.Models.Match>()))
            .Returns(mockMatch.Object);

            var mockBus             = new Mock <IBus>();
            var mockMatchRepository = new Mock <IMatchRepository>();

            mockMatchRepository.Setup(x => x.GetAsync(matchId)).ReturnsAsync(mockMatch.Object);

            _matchService = new MatchService(mockMatchmakingService.Object, stubMatchEngine.Object,
                                             mockMatchRepository.Object, mockBus.Object);

            await Assert.ThrowsAsync <Exception>(() => _matchService.Substitution(Guid.NewGuid(), Guid.NewGuid(), matchId, userId));
        }
Exemple #9
0
        public void GetTurn()
        {
            var leg = new Leg();

            leg.LegByPlayers.Add(new LegByPlayer("PlayerOne")
            {
                DartsThrown = { 5, 5, 5, 5 },
                HasStarted  = true,
                IsWon       = true.ToMaybe(),
                Scores      = new List <int> {
                    46, 83, 41, 60
                }
            });
            leg.LegByPlayers.Add(new LegByPlayer("PlayerTwo")
            {
                DartsThrown = { 5, 5, 5, 5 },
                HasStarted  = true,
                IsWon       = true.ToMaybe(),
                Scores      = new List <int> {
                    46, 83, 41, 60
                }
            });
            this.LegsMatch.LegsPlayed.Value.Add(leg);
            var match = new MatchService(this.LegsMatch);

            Assert.AreEqual(this.Players.Skip(1).First(), match.GetTurn());

            this.LegsMatch.LegsPlayed.Value.Last().LegByPlayers.Last().Scores.Add(55);
            match = new MatchService(this.LegsMatch);
            Assert.AreEqual(this.Players.First(), match.GetTurn());
        }
Exemple #10
0
        public void GetMatches_CorrectValue()
        {
            var matchService = new MatchService();
            var matches      = matchService.GetMatches();

            Assert.AreEqual("Getting Matches", matches);
        }
Exemple #11
0
        public BetDetails(DALBase.Data.Bet bet)
        {
            MatchService matchService = new MatchService();
            Match        match        = matchService.Get(bet.MatchId);

            Team1Name = match.Team1Name;
            Team2Name = match.Team2Name;

            IEnumerable <Game> games = matchService.GetGamesFromMatch(bet.MatchId);

            foreach (Game game in games)
            {
                if (game.WinnerId == match.Team1Id)
                {
                    Team1Score++;
                }
                else if (game.WinnerId == match.Team2Id)
                {
                    Team2Score++;
                }
            }

            if (bet.BettedWinner == match.Team1Id && Team1Score > Team2Score)
            {
                isWon = true;
            }
            else if (bet.BettedWinner == match.Team2Id && Team2Score > Team1Score)
            {
                isWon = true;
            }
            else
            {
                isWon = false;
            }
        }
Exemple #12
0
        public void EndLeg()
        {
            var leg = new Leg();

            leg.LegByPlayers.Add(new LegByPlayer("PlayerOne")
            {
                DartsThrown = { 5, 5, 5, 5 },
                HasStarted  = true,
                IsWon       = true.ToMaybe(),
                Scores      = new List <int> {
                    46, 83, 41, 60, 180
                }
            });
            leg.LegByPlayers.Add(new LegByPlayer("PlayerTwo")
            {
                DartsThrown = { 5, 5, 5, 5 },
                HasStarted  = true,
                IsWon       = true.ToMaybe(),
                Scores      = new List <int> {
                    46, 83, 41, 60, 180
                }
            });
            this.LegsMatch.LegsPlayed.Value.Add(leg);
            var match = new MatchService(this.LegsMatch);

            Assert.AreEqual(19, match.EndLeg(2).LegByPlayers.First(x => x.PlayerId == this.Players.First().Name).DartsThrown);
        }
Exemple #13
0
        public async Task GetByTeamId_Success()
        {
            List <RugbyMatch> matchResponse     = RugbyMatchMocks.GetData();
            string            matchResponseJson = JsonSerializer.Serialize(matchResponse);

            HttpResponseMessage response = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(matchResponseJson)
            };

            IHttpClientFactory            mockFactory        = BuildMockHttpClient(response);
            IOptions <ExternalApiOptions> externalApiOptions = CreateMockConfiguration();
            IMatchService matchService = new MatchService(externalApiOptions, mockFactory);

            List <RugbyMatch> result = await matchService.GetByTeamId(103969);

            Assert.AreEqual(3, result.Count);

            RugbyMatch firstMatch = result.First(m => m.matchId == 1);

            Assert.AreEqual("W", firstMatch.result);
            Assert.AreEqual("Old Trafford", firstMatch.stadiumName);

            RugbyMatch secondMatch = result.First(m => m.matchId == 2);

            Assert.AreEqual("W", secondMatch.result);
            Assert.AreEqual("Signal Iduna Park", secondMatch.stadiumName);

            RugbyMatch thirdMatch = result.First(m => m.matchId == 3);

            Assert.AreEqual("L", thirdMatch.result);
            Assert.AreEqual("Bernabeu", thirdMatch.stadiumName);
        }
Exemple #14
0
        public void IsGameFinished()
        {
            this.LegsMatch.Legs = 3;
            var match = new MatchService(this.LegsMatch);

            Assert.AreEqual(true, match.IsGameFinished(this.Players.Last()));
        }
Exemple #15
0
        public void SaveMatchVliadDay()
        {
            var baseMoney = Request["baseMoney"] != null?Convert.ToDecimal(Request["baseMoney"]) : 0;

            var startDate = Request["startDate"] != null?Convert.ToDateTime(Request["startDate"]) : DateTime.MinValue;

            DateTime endtime;
            var      endDate = Request["endDate"] != null && DateTime.TryParse(Request["endDate"], out endtime) ? Convert.ToDateTime(Request["endDate"]) : DateTime.MaxValue;
            var      matchID = Request["matchID"] != null?Convert.ToInt32(Request["matchID"]) : 0;

            try
            {
                var entity = MatchService.GetMatchByMatchID(matchID);
                if (entity.BaseMoney > 0)
                {
                    RedirectToAction("Top");
                }
                MatchService.UpdateMatch(baseMoney, startDate, endDate, matchID);
                Response.Write("ok");
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Exemple #16
0
        public void AddScore()
        {
            var match = new MatchService(this.LegsMatch);

            match.AddScore(377, this.Players.First());
            Assert.AreEqual(377, match.GetCurrentLeg().LegByPlayers.First(x => x.PlayerId == this.Players.First().Name).Scores.Last());
        }
Exemple #17
0
        public async Task GetMatchStatus_ReturnsCorrectModel()
        {
            //Arrange
            var userId  = Guid.NewGuid();
            var matchId = Guid.NewGuid();

            var mockMatch = new Mock <ApplicationCore.Models.Match>();

            var mockMatchmakingService = new Mock <IMatchmakingService>();

            var stubMatchEngine = new Mock <IMatchEngine>();

            var mockBus             = new Mock <IBus>();
            var mockMatchRepository = new Mock <IMatchRepository>();

            mockMatchRepository.Setup(x => x.HasUnclaimedAsync(userId)).ReturnsAsync(true);
            mockMatchRepository.Setup(x => x.GetInProgressAsync(userId)).ReturnsAsync((Guid?)null);

            _matchService = new MatchService(mockMatchmakingService.Object, stubMatchEngine.Object,
                                             mockMatchRepository.Object, mockBus.Object);

            //Act
            var result = await _matchService.GetMatchStatus(userId);

            //Assert
            Assert.True(result.HasUnclaimedRewards);
            Assert.Null(result.InProgressMatchId);
        }
Exemple #18
0
        public async Task GetLineupAsync_CallsGetAsyncOnce()
        {
            //Arrange
            var userId  = Guid.NewGuid();
            var matchId = Guid.NewGuid();

            var mockMatch = new Mock <ApplicationCore.Models.Match>();

            mockMatch.SetupGet(x => x.HomeTeam).Returns(new TeamDetails()
            {
                UserId = userId,
                Squad  = new Squad()
            });

            var mockMatchmakingService = new Mock <IMatchmakingService>();

            var stubMatchEngine = new Mock <IMatchEngine>();

            var mockBus             = new Mock <IBus>();
            var mockMatchRepository = new Mock <IMatchRepository>();

            mockMatchRepository.Setup(x => x.GetAsync(It.IsAny <Guid>())).ReturnsAsync(mockMatch.Object);

            _matchService = new MatchService(mockMatchmakingService.Object, stubMatchEngine.Object,
                                             mockMatchRepository.Object, mockBus.Object);

            //Act
            var result = await _matchService.GetLineupAsync(matchId, userId);

            //Assert
            mockMatchRepository.Verify(x => x.GetAsync(matchId), Times.Once);
        }
Exemple #19
0
 private void OnTeamSelected(object sender, TeamSelectedEventArgs args)
 {
     SELECTED_TEAM_ID = args.SelectedTeamId;
     OPPONENT_TEAM_ID = args.OpponentTeamId;
     MatchService.CreateMatch(SELECTED_TEAM_ID, OPPONENT_TEAM_ID);
     SceneManager.LoadScene("Main", LoadSceneMode.Single);
 }
Exemple #20
0
        public async Task Get_ReturnsMatch()
        {
            var mockMatchmakingService = new Mock <IMatchmakingService>();
            var mockMatchRepository    = new Mock <IMatchRepository>();

            var matchId = Guid.NewGuid();
            var match   = new ApplicationCore.Models.Match {
                Id = matchId
            };

            mockMatchRepository.Setup(x => x.GetAsync(matchId)).Returns(Task.FromResult(match));

            var stubMatchEngine = new Mock <IMatchEngine>();

            var mockBus = new Mock <IBus>();

            _matchService = new MatchService(mockMatchmakingService.Object, stubMatchEngine.Object,
                                             mockMatchRepository.Object, mockBus.Object);

            //Act
            var returnedMatch = await _matchService.GetAsync(matchId);

            //Assert
            Assert.Equal(returnedMatch, match);
        }
        public override Task <ParseResult> ParseAsync(ChatState state, Chat_ParseField chatParseField, ChatMessage message)
        {
            var tokens = TextClassificationService.Tokenize(message.UserInput);

            // HTC One and iPhone match words quite easily
            var cleanedTokens = (from t in tokens
                                 where t != "phone" && t != "phones" && t != "phone's" && t != "the" && t != "tone"
                                 select t.ToLower()).ToArray();

            (string matchedText, int matchedIndex, float ratio) = MatchService.FindMatch(cleanedTokens, 1, 4, deviceCatalog.MatchCharacters);
            var device = deviceCatalog.MakeModelList[matchedIndex];

            var deviceMatch = new DeviceMatchResult
            {
                Id          = device.Id,
                Make        = device.Make,
                Model       = device.Model,
                DisplayName = device.DisplayName,
                IsUncommon  = device.IsUncommon,
                Ratio       = ratio
            };

            double minConfidence = ChatConfiguration.MinimumDeviceConfidence;

            if (device.IsUncommon)
            {
                minConfidence = ChatConfiguration.MinimumUncommonDeviceConfidence;
            }
            if (deviceMatch.Ratio > minConfidence)
            {
                return(Task.FromResult(ParseResult.CreateSuccess(deviceMatch)));
            }

            return(Task.FromResult(ParseResult.Failed));
        }
Exemple #22
0
        public fmMain()
        {
            InitializeComponent();

            _match = new Match();
            new FmStart(_match).ShowDialog();

            _players = _match.SetPlayers;


            lblScorePlayer1.Text = "0";
            lblScorePlayer2.Text = "0";
            lblTime.Text         = "00:00:00";

            lblNamePlayer1.Text = _players[0].Name;
            lblNamePlayer2.Text = _players[1].Name;

            pbBallPlayer1.Visible = _players[0].IsServe;
            pbBallPlayer2.Visible = _players[1].IsServe;

            //добавляем игроков в таблицу и оставляем нужное кол-во сетов
            dgSummMatch.RowCount = 2;
            dgSummMatch.Rows[0].Cells[0].Value = _players[0].Name;
            dgSummMatch.Rows[1].Cells[0].Value = _players[1].Name;
            dgSummMatch.ColumnCount            = _match.CountSets + 1;

            startTime = DateTime.Now;
            tMatchDuration.Enabled = true;

            _matchService = new MatchService(_match, Victory);
        }
Exemple #23
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome To Dota Challenger!");
            PlayerService playerService = new PlayerService();
            int           accountId     = 87285329;
            Player        player        = playerService.GetPlayerProfile(accountId);

            if (player.profile == null)
            {
                Console.WriteLine($"The player with id {accountId} cannot be found");
                //exit the program if the player cannot be found
                return;
            }
            Console.WriteLine($"The player name is {player.profile.name} competitive rank: {player.solo_competitive_rank}");

            //Create a new instance of the new match service found in services folder (MatchService.cs)
            MatchService matchservice = new MatchService();

            //use the method GetMatches to retrieve the recent matches of the player using the accountId above and assign them to a variable recentMatches below

            List <Match> recentMatches = matchservice.GetMatches(accountId);



            //Print out all the received matches in the format "PLAYERNAME:  KILLS , DEATHS , MATCHDURATION , K/D RATIO (Create a method in this class to calculate this You have to calculate this)
            //HINT:  User a foreach loop i.e foreach(Match item in recentMatches){}....
            foreach (Match x in recentMatches)
            {
                Console.WriteLine("Kills:" + "\t" + x.kills + "\t" + "  Deaths:" + "\t" + x.deaths + "\t" + "  Assists:" + "\t" + x.assists);
            }

            //reffer to the entities folder fo the  Match class to find out the necessary properties of matches
        }
Exemple #24
0
        public static void Update()
        {
            HttpClient      client  = new HttpClient();
            string          Url     = PandaScoreUtils.PandaBaseAddress + $"matches?token={PandaScoreUtils.Token}&{PandaScoreUtils.MaxPerPage}";
            List <MatchApi> matches = new List <MatchApi>();

            do
            {
                HttpResponseMessage msg = client.GetAsync(Url).Result;
                matches.AddRange(JsonConvert.DeserializeObject <List <MatchApi> >(msg.Content.ReadAsStringAsync().Result));

                Url = msg.Headers.GetNextURL();
            } while (Url != null);

            MatchService matchService = new MatchService();
            GameService  gameService  = new GameService();

            foreach (MatchApi m in matches)
            {
                DALBase.Data.Match match;
                if (m.Opponents.Length >= 2)
                {
                    match = new DALBase.Data.Match()
                    {
                        BeginAt       = m.BeginAt,
                        Draw          = m.Draw,
                        EndAt         = m.EndAt,
                        Forfeit       = m.Forfeit,
                        Id            = m.Id,
                        MatchType     = m.MatchType,
                        NumberOfGames = m.NumberOfGames,
                        Team1Id       = m.Opponents[0].opponent.Id,
                        Team2Id       = m.Opponents[1].opponent.Id,
                        TournamentId  = m.TournamentId
                    };


                    if (matchService.Update(match))
                    {
                        foreach (GameApi g in m.Games)
                        {
                            Game game = new Game()
                            {
                                Id       = g.Id,
                                Forfeit  = g.Forfeit,
                                BeginAt  = g.BeginAt,
                                EndAt    = g.EndAt,
                                Finished = g.Finished,
                                Length   = g.Length,
                                Position = g.Position,
                                Status   = g.Status,
                                WinnerId = g.Winner.Id,
                                MatchId  = m.Id
                            };
                            gameService.Update(game);
                        }
                    }
                }
            }
        }
        public async Task GetAllMatches_Test()
        {
            // Arrange
            var matchesService = new MatchService(this.dbContext);

            this.dbContext.Matches.Add(new Match
            {
                HomeTeam  = "Manchester United",
                AwayTeam  = "CSKA Moscow",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });
            this.dbContext.Matches.Add(new Match
            {
                HomeTeam  = "Basel",
                AwayTeam  = "CSKA Moscow",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });
            this.dbContext.Matches.Add(new Match
            {
                HomeTeam  = "Manchester United",
                AwayTeam  = "Basel",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });
            await this.dbContext.SaveChangesAsync();

            // Act
            var matches = matchesService.GetAllMatches();

            // Assert
            Assert.AreEqual(3, matches.Count);
        }
Exemple #26
0
        public async Task GetByTeamId_Error()
        {
            HttpResponseMessage response = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content    = new StringContent("Failed to retrieve matches")
            };

            IHttpClientFactory            mockFactory        = BuildMockHttpClient(response);
            IOptions <ExternalApiOptions> externalApiOptions = CreateMockConfiguration();
            IMatchService matchService = new MatchService(externalApiOptions, mockFactory);

            Exception result = null;

            try
            {
                await matchService.GetByTeamId(103969);
            }
            catch (Exception ex)
            {
                result = ex;
            }

            Assert.AreEqual("BadRequest - Failed to retrieve matches", result.Message);
        }
        public async Task AddMultipleMatches_Test()
        {
            // Arrange
            var matchesService = new MatchService(this.dbContext);

            // Act
            await matchesService.CreateMatch(new Match
            {
                HomeTeam  = "Manchester United",
                AwayTeam  = "CSKA Moscow",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });

            await matchesService.CreateMatch(new Match
            {
                HomeTeam  = "Basel",
                AwayTeam  = "CSKA Moscow",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });

            await matchesService.CreateMatch(new Match
            {
                HomeTeam  = "Manchester United",
                AwayTeam  = "Basel",
                BeginTime = new TimeSpan(DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, DateTime.UtcNow.Second),
                Date      = DateTime.UtcNow
            });

            // Assert
            Assert.AreEqual(3, this.dbContext.Matches.Count());
        }
        private void ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                KnockoutMatches.Clear();
                var result = MatchService.GetKnockoutMatches();

                foreach (var item in result)
                {
                    KnockoutMatches.Add(item);
                }
            }
            catch (Exception)
            {
                var page = new ContentPage();
                page.DisplayAlert("Error", "Unable to load matches.", "OK", null);
            }

            IsBusy = false;
        }
        IHttpActionResult Get(int id)
        {
            MatchService ms = new MatchService();
            Match        m  = ms.Get(id);

            return(Json(m));
        }
Exemple #30
0
        public async Task InsertUpdateMatch(object matchInfo, int phaseId, bool removeMatch)
        {
            var matchDTO = convertMatchInfo(matchInfo);

            using (var matchService = new MatchService())
                using (var competitorService = new CompetitorService(matchService.DbContext))
                    using (var competitionPhaseService = new CompetitionPhaseService(matchService.DbContext))
                    {
                        var settings = competitionPhaseService.GetCompetitionPhaseInfoSettings(phaseId) as GroupPhaseSettings;
                        // update of match
                        var matchSettings = removeMatch ? null : extractMatchInfo(matchDTO);
                        matchService.UpdateMatch(matchDTO.MatchId, matchSettings);

                        // update of all competitors
                        var competitors = matchService.DbContext.CompetitorPhaseInfoes.Where(x => x.IdCompetitionPhase == phaseId).ToList();
                        var matches     = matchService.GetMatches <TableTennisMatchInfo>(phaseId);

                        // update only match group
                        var groupIndex   = matchDTO.GroupIndex;
                        var groupMatches = matches.Where(x => settings.MatchIds[groupIndex].Contains(x.MatchId)).ToList();
                        var groupPlayers = competitors.Where(x => settings.CompetitorIds[groupIndex].Contains(x.IdCompetitor)).ToList();

                        var sorter = GetNewSorter();
                        sorter.LoadSortData(groupMatches);
                        var sortedData = sorter.SortCompetitors();
                        updateCompetitors(groupPlayers, sortedData);

                        await matchService.SaveChangesAsync();
                    }
        }
Exemple #31
0
        static void Main()
        {
            new PolicyServer("clientaccesspolicy.xml");
            Console.WriteLine("Silverlight policy service has been started.");

            var service = new MatchService();
            service.Start(new IPEndPoint(IPAddress.Any, 4530));

            Console.WriteLine("Match service has been started. Press any key to quit.");
            Console.ReadKey();
        }
 public MouseLeftButtonDownCommand(MatchService matchService)
 {
     _matchService = matchService;
 }
 public MouseMoveCommand(MatchService matchService)
 {
     _matchService = matchService;
 }
 public KeyPressCommand(MatchService matchService)
 {
     _matchService = matchService;
 }
 /// <summary>Initializes a new instance of the ConnectCommand class.</summary>
 /// <param name="provider">Realm client to connect to remote service.</param>
 /// <param name="endpoint">Endpoint to connect to.</param>
 public ConnectCommand(MatchService provider, IPEndPoint endpoint)
 {
     _endpoint = endpoint;
     _provider = provider;
 }